src/doc: introduce option --no-render in HTML phase.
[nit.git] / benchmarks / languages / bench_base.nit
index 7258d18..9f79133 100644 (file)
@@ -26,7 +26,7 @@ class Generator
        var classes = new Array[Klass]
 
        var dept writable = 5
-       var loops writable = 20000
+       var loops writable = 50000
        var middle writable = 0
        var dry writable = false
        var check writable = false
@@ -48,7 +48,7 @@ class Generator
                middle = (dept + 1) / 2
        end
 
-       var file: nullable OFStream = null
+       var file: nullable FileWriter = null
        fun write(str: String)
        do
                file.write(str)
@@ -62,7 +62,7 @@ class Generator
        do
                dir = "{dir}/nit"
                dir.mkdir
-               file = new OFStream.open("{dir}/{name}.nit")
+               file = new FileWriter.open("{dir}/{name}.nit")
 
                write "class Root\n\tfun id: Int do return 0\nend"
                for c in classes do
@@ -88,7 +88,7 @@ class Generator
                write "\t\tif {test} and x >= 0 then"
                if check then write "\t\tx += 1"
                write "\telse"
-               write "\t\t\tx -= 1"
+               write "\t\t\tx = x - 1 + i - j"
                write "\t\t\ta = b"
                write "\t\tend"
                write "\t\tj += 1"
@@ -117,7 +117,7 @@ class Generator
        do
                dir = "{dir}/java"
                dir.mkdir
-               file = new OFStream.open("{dir}/{name}.java")
+               file = new FileWriter.open("{dir}/{name}.java")
 
                var cl = ""
                if interfaces then cl = "X"
@@ -166,8 +166,9 @@ class Generator
                var test = "true"
                if not dry then test = testjava(interfaces)
                write "\t\t\tif({test} && x>=0) \{"
-               if check then write "\t\t\t\tx -= 2"
-               write "\t\t\t\} else \{ x--; a = b;\}"
+               if check then write "\t\t\t\tx = x + 1;"
+               write "\t\t\t\} else \{ x = x - 1 + i - j; a = b;\}"
+               #write "\t\t\t\} else \{ x = x - 1; a = b;\}"
                write "\t\t}"
                write "\t\}"
                write "\tSystem.out.println(x);"
@@ -182,7 +183,7 @@ class Generator
        do
                dir = "{dir}/cs"
                dir.mkdir
-               file = new OFStream.open("{dir}/{name}.cs")
+               file = new FileWriter.open("{dir}/{name}.cs")
 
                var cl = ""
                if interfaces then cl = "X"
@@ -232,7 +233,7 @@ class Generator
                if not dry then test = testcsharp(interfaces)
                write "\t\t\tif({test} && x>=0) \{"
                if check then write "\t\t\t\tx++;"
-               write "\} else \{ x--; a = b; \};"
+               write "\} else \{ x = x - 1 + i - j; a = b; \};"
                write "\t\t}"
                write "\t\}"
                write "\tSystem.Console.WriteLine(x);"
@@ -247,7 +248,7 @@ class Generator
        do
                dir = "{dir}/scala"
                dir.mkdir
-               file = new OFStream.open("{dir}/{name}.scala")
+               file = new FileWriter.open("{dir}/{name}.scala")
 
                var cl = ""
                write "object {name} \{"
@@ -295,7 +296,8 @@ class Generator
                var test = "true"
                if not dry then test = testscala(interfaces)
                write "\t\tif ({test} && x>=0) \{"
-               if check then write "\t\t\tx += 1"
+               if check then write "\t\t\tx += 1;"
+               #write "\} else \{ x = x - 1 + i - j; a = b; \}"
                write "\} else \{ x = x - 1; a = b; \}"
                write "\t\tj += 1"
                write "\t\t\}"
@@ -314,7 +316,7 @@ class Generator
        do
                dir = "{dir}/cpp"
                dir.mkdir
-               file = new OFStream.open("{dir}/{name}.cpp")
+               file = new FileWriter.open("{dir}/{name}.cpp")
 
                write "#include <iostream>"
                write "#include <stdlib.h>"
@@ -339,8 +341,8 @@ class Generator
                var test = "true"
                if not dry then test = testcpp
                write "\t\tif({test} && x>=0) \{"
-               if check then write "\t\t\tx += 1"
-               write "\} else \{ x--; a = b;\}"
+               if check then write "\t\t\tx += 1;"
+               write "\} else \{ x = x - 1 + i - j; a = b;\}"
                write "\t\t}"
                write "\t\}"
                write "\tstd::cout << x << std::endl;"
@@ -372,7 +374,7 @@ class Generator
                        dir = "{dir}/es/{name}"
                end
                dir.mkdir
-               file = new OFStream.open("{dir}/root.e")
+               file = new FileWriter.open("{dir}/root.e")
 
                var istk = ""
                if se then istk = " is"
@@ -382,7 +384,7 @@ class Generator
                file.close
 
                for c in classes do
-                       file = new OFStream.open("{dir}/{c}.e")
+                       file = new FileWriter.open("{dir}/{c}.e")
                        write "class {c}[E] "
                        if c.supers.is_empty then
                                write "\tinherit ROOT"
@@ -396,7 +398,7 @@ class Generator
                        file.close
                end
 
-               file = new OFStream.open("{dir}/app{name}.e")
+               file = new FileWriter.open("{dir}/app{name}.e")
                write "class APP{name.to_upper}"
                if se then
                        write "insert ARGUMENTS"
@@ -442,7 +444,7 @@ class Generator
                if not dry then test = teste(se)
                write "\t\t\t\t\tif {test} and then x >= 0 then" 
                if check then write "\t\t\t\t\tx := x + 1"
-               write "\t\t\t\t\telse x := x - 1; a := b end"
+               write "\t\t\t\t\telse x := x - 1 + i - j; a := b end"
                write "\t\t\t\t\tj := j + 1"
                write "\t\t\t\tend"
                write "\t\t\t\ti := i + 1"