| 1 |
n = 1e3 ; 1e3 for testing, 1e6 for measuring |
| 2 |
|
| 3 |
array$# = { |
| 4 |
... "1-2", "1-02", "1-20", "10-20", |
| 5 |
... "file 0", "file 0b", "file0", "file00", "file0a", |
| 6 |
... "file5", "file05", "file5a", "file5a5", |
| 7 |
... "file5a05", "file05a5", |
| 8 |
... "file5a005", "file05a05", "file005a5", |
| 9 |
... "file5a0005", "file05a005", "file005a05", "file0005a5", |
| 10 |
... "file5a5a", |
| 11 |
... "fred", "jane", "jane", |
| 12 |
... "kile 0", "kile 0", "kile 0b", "kile 0b", "kile0", "kile0", "kile00", "kile00", "kile0a", "kile0a", |
| 13 |
... "pic 7", "pic 4 else", "pic 5", "pic 5 ", "pic 5 something", "pic 6", |
| 14 |
... "pic01", "pic2", "pic02", "pic02a", "pic3", |
| 15 |
... "pic4", "pic05", "pic100", "pic100a", "pic120", "pic121", |
| 16 |
... "pic02000", "tom", "x2-g8", "x2-y7", "x2-y08", "x8-y8" } |
| 17 |
|
| 18 |
stopwatch |
| 19 |
for i to n |
| 20 |
sorted$# = sort$# (shuffle$# (array$#)) |
| 21 |
endfor |
| 22 |
t = stopwatch / n |
| 23 |
|
| 24 |
writeInfoLine: "pure Unicode sort: ", round (t * 1e9), " nanoseconds" |
| 25 |
|
| 26 |
stopwatch |
| 27 |
for i to n |
| 28 |
sorted$# = sort_numberAware$# (shuffle$# (array$#)) |
| 29 |
if sorted$# <> array$# |
| 30 |
appendInfoLine: array$# |
| 31 |
appendInfoLine: sorted$# |
| 32 |
exitScript: "SORTING ERROR" |
| 33 |
endif |
| 34 |
endfor |
| 35 |
t = stopwatch / n |
| 36 |
|
| 37 |
appendInfoLine: "number-aware sort: ", round (t * 1e9), " nanoseconds" |
| 38 |
appendInfoLine: round (t * 1e9), " nanoseconds; OK" |