nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gamnit: make `SpriteSet` public so clients can use its services
[nit.git]
/
tests
/
bench_complex_sort.nit
diff --git
a/tests/bench_complex_sort.nit
b/tests/bench_complex_sort.nit
index
116d7d7
..
cf460cd
100644
(file)
--- a/
tests/bench_complex_sort.nit
+++ b/
tests/bench_complex_sort.nit
@@
-23,61
+23,57
@@
end
class A
super Elt
var a: Int
class A
super Elt
var a: Int
- redef fun val1: Int do return _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
super Elt
var b: Int
end
class Elt2
super Elt
var b: Int
- redef fun val1: Int do return _b/2
- redef fun val2: Int do return _b
- init initelt2(i: Int) do _b = i
+ redef fun val1: Int do return b/2
+ redef fun val2: Int do return b
end
class B
super Elt2
end
class B
super Elt2
- init(i: Int) do initelt2(i)
+ redef fun to_s do return "Bb{b}"
end
class C
super Elt
var c: Int
var d: Int
end
class C
super Elt
var c: Int
var d: Int
- redef fun val1: Int do return _c end
- redef fun val2: Int do return _d end
+ redef fun val1: Int do return c
+ redef fun val2: Int do return d
- init init2(i: Int, j: Int) do
- _c = i
- _d = j
- end
+ redef fun to_s do return "Cc{c}d{d}"
end
class D
super A
super Elt2
end
class D
super A
super Elt2
- redef fun val1: Int do return _a end
- redef fun val2: Int do return _b end
+ redef fun val1: Int do return a
+ redef fun val2: Int do return b
- init init2(i: Int, j: Int) do
- init(i)
- initelt2(j)
- end
+ autoinit a=, b=
+
+ redef fun to_s do return "Da{a}b{b}"
end
class E
super Elt2
end
class E
super Elt2
- redef fun val1: Int do return 5 end
+ redef fun val1: Int do return 5
- init(i: Int) do initelt2(i)
+ redef fun to_s do return "Eb{b}"
end
class EltComparator
end
class EltComparator
- super Comparator[Elt]
- redef fun compare(a: Elt, b: Elt): Int
+ super Comparator
+ redef type COMPARED: Elt
+ redef fun compare(a, b)
do
do
- if _is_val1 then
+ if is_val1 then
return a.val1 <=> b.val1
else
return a.val2 <=> b.val2
return a.val1 <=> b.val1
else
return a.val2 <=> b.val2
@@
-86,7
+82,7
@@
class EltComparator
fun toggle
do
fun toggle
do
- _is_val1 = not _is_val1
+ is_val1 = not is_val1
end
var is_val1: Bool = false
end
var is_val1: Bool = false
@@
-102,15
+98,16
@@
do
else if r == 1 then
return new B(10.rand)
else if r == 2 then
else if r == 1 then
return new B(10.rand)
else if r == 2 then
- return new C.init2(10.rand, 10.rand)
+ return new C(10.rand, 10.rand)
else if r == 3 then
else if r == 3 then
- return new D.init2(10.rand, 10.rand)
+ return new D(10.rand, 10.rand)
else
return new E(10.rand)
end
end
else
return new E(10.rand)
end
end
-var n = 100
+srand_from(0)
+var n = 20
if not args.is_empty then
n = args.first.to_i
if not args.is_empty then
n = args.first.to_i
@@
-121,9
+118,12
@@
for i in [0..n[ do
array.push(generator)
end
array.push(generator)
end
+print array.join(", ")
+
var comparator = new EltComparator
for i in [0..n[ do
comparator.sort(array)
comparator.toggle
end
var comparator = new EltComparator
for i in [0..n[ do
comparator.sort(array)
comparator.toggle
end
+print array.join(", ")