Don't allow compiling with stock LLVM versions, only the Mono LLVM repo at https...
[mono-project/dkf.git] / mono / benchmark / life.cs
bloba154fb1c694e74a2d7bfd05e6cc602409ae1b087
1 // created on 03/03/2002 at 15:12
2 using System;
4 class App {
5 static String s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15;
6 static int[] offsets = {-16, -15, -14, -1, 1, 14, 15, 16};
7 public static int Main(String[] args) {
8 int i2 = 500;
9 int i0;
10 double n2;
11 DateTime start, end;
12 start = DateTime.Now;
13 s0 = " ";
14 s1 = " ";
15 s2 = " ";
16 s3 = " *** ";
17 s4 = " ";
18 s5 = " ";
19 s6 = " * ";
20 s7 = " * ";
21 s8 = " * ";
22 s9 = " * ";
23 s10 =" * ";
24 s11 =" * ";
25 s12 =" ";
26 s13 =" ";
27 s14 =" ";
28 s15 ="";
29 s15 = s0+s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12+s13+s14;
30 dump();
31 i0 =0;
32 while (i0++ < i2) {
33 generate();
34 dump();
36 end = DateTime.Now;
37 n2 = (end-start).TotalMilliseconds;
38 Console.WriteLine("{0} generations in {1} milliseconds, {2} gen/sec.",
39 i2, (int)n2, (int)(i2/(n2/1000)));
40 return 0;
42 static void generate() {
43 int i0, i1, i2, i3;
44 i0 = s15.Length;
45 s1 = "";
46 i1 = 0;
47 do {
48 i2 = 0;
49 foreach (int offset in offsets) {
50 i3 = (offset + i0 + i1) % i0;
51 if (s15.Substring(i3, 1) == "*")
52 i2++;
54 if (s15.Substring(i1, 1) == "*") {
55 if (i2 < 2 || i2 > 3) {
56 s1 += " ";
57 } else {
58 s1 += "*";
60 } else {
61 if (i2 == 3) {
62 s1 += "*";
63 } else {
64 s1 += "*";
67 } while (++i1 < i0);
68 s15 = s1;
70 static void dump() {