Merge: Microbenches for niti
authorJean Privat <jean@pryen.org>
Sat, 18 Apr 2015 09:47:26 +0000 (16:47 +0700)
committerJean Privat <jean@pryen.org>
Sat, 18 Apr 2015 09:47:26 +0000 (16:47 +0700)
Some update on tests/ so that niti (and nitvm) can pass more tests

Pull-Request: #1275
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>

35 files changed:
tests/bench_421.nit
tests/bench_add_all.nit
tests/bench_complex_sort.nit
tests/bench_fib.nit
tests/bench_int_range_iterator.nit
tests/bench_netsim.nit
tests/bench_nsieve_bool.nit
tests/bench_send.nit
tests/bench_send2.nit
tests/bench_strfib.nit
tests/bench_string_append.nit
tests/bench_string_super.nit
tests/bench_string_tos.nit
tests/bench_tak.nit
tests/niti.skip
tests/nitvm.skip
tests/sav/bench_421.res
tests/sav/bench_add_all.res
tests/sav/bench_complex_sort.res [new file with mode: 0644]
tests/sav/bench_fib.res
tests/sav/bench_int_range_iterator.res
tests/sav/bench_netsim.res
tests/sav/bench_nsieve_bool.res
tests/sav/bench_send.res [new file with mode: 0644]
tests/sav/bench_send2.res [new file with mode: 0644]
tests/sav/bench_strfib.res
tests/sav/bench_string_append.res
tests/sav/bench_string_append_alt1.res
tests/sav/bench_string_super.res
tests/sav/bench_string_tos.res
tests/sav/test_hash.res
tests/sav/test_map.res
tests/sav/test_mem.res
tests/test_map.nit
tests/test_mem.nit

index b87347c..a868768 100644 (file)
@@ -29,7 +29,7 @@ do
        return steps
 end
 
-var n = 10
+var n = 456
 if not args.is_empty then
        n = args.first.to_i
 end
index 733ac9b..0c9bc5e 100644 (file)
 
 # Performance test for Array::add_all
 
-import standard::collection
+var n = 10
+if args.not_empty then n = args.first.to_i
+
+var nn = 1.lshift(n)
 
 var a = new Array[Numeric]
 var b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
-for i in 10000.times do
+for i in nn.times do
        a.add_all b
 end
 
 var c = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
-for i in 10000.times do
+for i in nn.times do
        a.add_all c
 end
 
index 2eef2cb..5d96859 100644 (file)
@@ -26,6 +26,7 @@ class A
        redef fun val1: Int do return _a
 
        init(i: Int) do _a = i
+       redef fun to_s do return "Aa{a}"
 end
 
 class Elt2
@@ -39,6 +40,7 @@ end
 class B
        super Elt2
        init(i: Int) do initelt2(i)
+       redef fun to_s do return "Bb{b}"
 end
 
 class C
@@ -52,6 +54,7 @@ class C
                _c = i
                _d = j
        end
+       redef fun to_s do return "Cc{c}d{d}"
 end
 
 class D
@@ -64,6 +67,7 @@ class D
                init(i)
                initelt2(j)
        end
+       redef fun to_s do return "Da{a}b{b}"
 end
 
 class E
@@ -71,6 +75,7 @@ class E
        redef fun val1: Int do return 5 end
 
        init(i: Int) do initelt2(i)
+       redef fun to_s do return "Eb{b}"
 end
 
 class EltComparator
@@ -111,7 +116,8 @@ do
        end
 end
 
-var n = 100
+srand_from(0)
+var n = 20
 
 if not args.is_empty then
        n = args.first.to_i
@@ -122,9 +128,12 @@ for i in [0..n[ do
        array.push(generator)
 end
 
+print array.join(", ")
+
 var comparator = new EltComparator
 for i in [0..n[ do
        comparator.sort(array)
        comparator.toggle
 end
 
+print array.join(", ")
index 69dc371..8c7d4da 100644 (file)
@@ -30,7 +30,7 @@ redef class Int
        end
 end
 
-var n = 10
+var n = 20
 if not args.is_empty then
        n = args.first.to_i
 end
index 17f24d2..3d906f0 100644 (file)
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-var nb = 5
+var nb = 25
 if not args.is_empty then nb = args.first.to_i
 
 var cpt = 0
index f784635..0e13e59 100644 (file)
@@ -267,11 +267,11 @@ e1.attach(a1)
 b1.start
 b2.start
 
-var nb = 100000
+var nb = 10
 if not args.is_empty then
        nb = args.first.to_i
 end
 
-s.run_for(nb)
+s.run_for(1.lshift(nb))
 print(c1.count)
 
index 36da71a..634e3cb 100644 (file)
@@ -38,11 +38,11 @@ end
 
 fun test(n: Int)
 do
-       var m = 10000.lshift(n)
+       var m = 1000.lshift(n)
        print("Primes up to {m} {nsieve(m)}")
 end
 
-var n = 2
+var n = 3
 if args.length == 1 then
        n = args.first.to_i
 end
index 03218dc..d3c1b7c 100644 (file)
@@ -44,8 +44,11 @@ class A
        end
        fun baz
        do
+               i += 1
        end
 
+       var i = 0
+
        init
        do
        end
@@ -97,7 +100,16 @@ b.val = 1
 c.val = 2
 d.val = 3
 var i = 0
-while i < 100000 do
+
+var n = 10
+if args.not_empty then n = args.first.to_i
+
+while i < 1.lshift(n) do
        a.hop(b, c, d)
        i = i + 1
 end
+
+print a.i
+print b.i
+print c.i
+print d.i
index e296465..a4f53ad 100644 (file)
@@ -18,8 +18,9 @@ redef class Object
        fun foo do end
 end
 class A
-       redef fun foo do end
+       redef fun foo do i += 1 end
        init do end
+       var i = 0
 end
 class B
        super A
@@ -53,6 +54,9 @@ class F
 
 end
 
+var n = 10
+if args.not_empty then n = args.first.to_i
+
 var nb = 60
 var a = new Array[Object].with_capacity(nb)
 for i in [0..(nb/6)[ do
@@ -63,9 +67,12 @@ for i in [0..(nb/6)[ do
        a[i*6+4] = new E
        a[i*6+5] = new F
 end
-for i in [0..1000000[ do
+for i in [0..1.lshift(n)[ do
        for j in [0..nb[ do
                a[j].foo
        end
 end
 
+for j in [0..nb[ do
+       print a[j].as(A).i
+end
index 2357686..f65d436 100644 (file)
@@ -32,7 +32,7 @@ if args.has("-q") then
        args.remove("-q")
 end
 
-var n = 5
+var n = 15
 if args.length > 0 then n = args.first.to_i
 var res = strfib(n)
 
index c99dc83..df00536 100644 (file)
@@ -17,7 +17,7 @@
 #alt1 import standard
 #alt1 import standard::ropes
 
-var n = 7
+var n = 4
 if not args.is_empty then
        n = args.first.to_i
 end
index ad27304..c78f448 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+var n = 10
+if args.not_empty then n = args.first.to_i
+
 var s = "*"
-var i = 0
-while i < 8 do
+var i = 1
+while i < n do
        s = "Je dis «{s}» et redis «{s}» et trois fois de plus : «{s}{s}{s}».\n"
        i = i + 1
 end
index 1d59691..dbc8ac9 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+var n = 10
+if args.not_empty then n = args.first.to_i
+
 var s = "*"
 var i = 0
-while i < 8 do
+while i < n do
        s = ["Je dis «", s, "» et redis «", s, "» et trois fois de plus : «", s, s, s, "».\n"].to_s
        i = i + 1
 end
index d5be5e8..ac128d3 100644 (file)
@@ -27,4 +27,7 @@ do
        end
 end
 
-print(tak(37,12,6))
+var n = 17
+if args.not_empty then n = args.first.to_i
+
+print(tak(n,12,6))
index a78f621..61b016a 100644 (file)
@@ -1,6 +1,4 @@
-test_mem
 shoot_logic
-bench_
 nit_args1
 nit_args3
 nit_args4
@@ -20,6 +18,5 @@ nitunit_args
 nitpretty_args
 hamming_number
 hailstone
-test_map
-nitls
-nituml
+nitls_args
+nituml_args
index a78f621..61b016a 100644 (file)
@@ -1,6 +1,4 @@
-test_mem
 shoot_logic
-bench_
 nit_args1
 nit_args3
 nit_args4
@@ -20,6 +18,5 @@ nitunit_args
 nitpretty_args
 hamming_number
 hailstone
-test_map
-nitls
-nituml
+nitls_args
+nituml_args
index 5079bf7..4e2232f 100644 (file)
@@ -1 +1 @@
-9: 19
+327: 143
diff --git a/tests/sav/bench_complex_sort.res b/tests/sav/bench_complex_sort.res
new file mode 100644 (file)
index 0000000..3f09c96
--- /dev/null
@@ -0,0 +1,2 @@
+Eb3, Da7b9, Aa3, Da2b5, Cc6d3, Cc9d9, Da7b1, Da0b2, Aa8, Aa4, Aa1, Eb2, Cc8d6, Bb6, Cc4d9, Bb7, Cc7d4, Eb2, Bb8, Eb0
+Da0b2, Aa1, Da2b5, Bb6, Aa3, Bb7, Bb8, Aa4, Cc4d9, Eb3, Eb2, Eb2, Eb0, Cc6d3, Cc7d4, Da7b1, Da7b9, Cc8d6, Aa8, Cc9d9
index d9e91fa..134debf 100644 (file)
@@ -1,3 +1,3 @@
-Primes up to 40000 4203
-Primes up to 20000 2262
-Primes up to 10000 1229
+Primes up to 8000 1007
+Primes up to 4000 550
+Primes up to 2000 303
diff --git a/tests/sav/bench_send.res b/tests/sav/bench_send.res
new file mode 100644 (file)
index 0000000..cb4ed12
--- /dev/null
@@ -0,0 +1,4 @@
+8192
+14336
+22528
+33792
diff --git a/tests/sav/bench_send2.res b/tests/sav/bench_send2.res
new file mode 100644 (file)
index 0000000..44053db
--- /dev/null
@@ -0,0 +1,60 @@
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
index 4e58388..aa267d1 100644 (file)
@@ -1 +1 @@
-((()(()))((())(()(()))))
+(((((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))(((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))))((((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))))(((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))(((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))))))(((((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))))(((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))(((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))))))((((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))(((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))))((((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))))(((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))(((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))))))))
index dc72c30..5cbab16 100644 (file)
@@ -11,8 +11,8 @@ true
 2
 0
 * test 2 *
-1000
-334
+100
+34
 * test 3 *
 * start:
 true
index dabb78b..48cdded 100644 (file)
@@ -10,8 +10,8 @@ true
 2
 0
 * test 2 *
-1000
-334
+100
+34
 * test 3 *
 * start:
 true
index a9be79e..2a5b99a 100644 (file)
@@ -1 +1 @@
-1234567891011121314151617181920212223
+12345678910
index c5b9eea..8e147f7 100644 (file)
@@ -40,7 +40,7 @@ end
 fun test2(h: Map[Int, Int])
 do
        print("* test 2 *")
-       var nb = 999
+       var nb = 99
        
        var i = 0
        while i <= nb do
index 9487e82..dc9d167 100644 (file)
@@ -27,4 +27,7 @@ fun foo(n: Int): List[Int]
        return a
     end
 
-print(foo(23))
+var n = 10
+if args.not_empty then n = args.first.to_i
+
+print(foo(n))