nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src: move pseudo-toplevel methods from Object
[nit.git]
/
tests
/
bench_complex_sort.nit
diff --git
a/tests/bench_complex_sort.nit
b/tests/bench_complex_sort.nit
index
ad72cc6
..
5d96859
100644
(file)
--- a/
tests/bench_complex_sort.nit
+++ b/
tests/bench_complex_sort.nit
@@
-22,15
+22,16
@@
end
class A
super Elt
class A
super Elt
- var _a: Int
+ var a: Int
redef fun val1: Int do return _a
init(i: Int) do _a = i
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
end
class Elt2
super Elt
- var _b: Int
+ 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
init initelt2(i: Int) do _b = i
@@
-39,12
+40,13
@@
end
class B
super Elt2
init(i: Int) do initelt2(i)
class B
super Elt2
init(i: Int) do initelt2(i)
+ redef fun to_s do return "Bb{b}"
end
class C
super Elt
end
class C
super Elt
- var _c: Int
- var _d: Int
+ 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 end
redef fun val2: Int do return _d end
@@
-52,6
+54,7
@@
class C
_c = i
_d = j
end
_c = i
_d = j
end
+ redef fun to_s do return "Cc{c}d{d}"
end
class D
end
class D
@@
-64,6
+67,7
@@
class D
init(i)
initelt2(j)
end
init(i)
initelt2(j)
end
+ redef fun to_s do return "Da{a}b{b}"
end
class E
end
class E
@@
-71,11
+75,13
@@
class E
redef fun val1: Int do return 5 end
init(i: Int) do initelt2(i)
redef fun val1: Int do return 5 end
init(i: Int) do initelt2(i)
+ redef fun to_s do return "Eb{b}"
end
end
-class EltSorter
- super AbstractSorter[Elt]
- redef fun compare(a: Elt, b: Elt): Int
+class EltComparator
+ super Comparator
+ redef type COMPARED: Elt
+ redef fun compare(a, b)
do
if _is_val1 then
return a.val1 <=> b.val1
do
if _is_val1 then
return a.val1 <=> b.val1
@@
-89,7
+95,7
@@
class EltSorter
_is_val1 = not _is_val1
end
_is_val1 = not _is_val1
end
- var _is_val1: Bool = false
+ var is_val1: Bool = false
init do end
end
init do end
end
@@
-110,7
+116,8
@@
do
end
end
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
+128,12
@@
for i in [0..n[ do
array.push(generator)
end
array.push(generator)
end
-var sorter = new EltSorter
+print array.join(", ")
+
+var comparator = new EltComparator
for i in [0..n[ do
for i in [0..n[ do
- sorter.sort(array)
- sorter.toggle
+ comparator.sort(array)
+ comparator.toggle
end
end
+print array.join(", ")