[plt-dev] range mini benchmark
Here is a benchmark for a few implementations of `range':
Nat Nat -> [Listof Nat]
(range 0 5) => (list 0 1 2 3 4 5)
(range 5 0) => (list 5 4 3 2 1 0)
One uses build-list, another uses sequences. I threw in an
implementation using an iterative build-list as well.
I was surprised the build-list version beat out sequences -- thoroughly,
with the iterative build-list being an improvement over the built in
recursive one.
David
$ mzc range-bench.scm
$ mzscheme range-bench.scm
(for ((j (in-range 5))) (range 0 1000000))
range-rbl: cpu time: 862 real time: 865 gc time: 387
range-ibl: cpu time: 905 real time: 905 gc time: 642
range-seq: cpu time: 2283 real time: 2289 gc time: 1138
(for ((j (in-range 50))) (range 0 100000))
range-rbl: cpu time: 518 real time: 519 gc time: 95
range-ibl: cpu time: 365 real time: 366 gc time: 116
range-seq: cpu time: 1560 real time: 1560 gc time: 443
(for ((j (in-range 500))) (range 0 10000))
range-rbl: cpu time: 357 real time: 358 gc time: 26
range-ibl: cpu time: 267 real time: 281 gc time: 18
range-seq: cpu time: 1153 real time: 1155 gc time: 54
(for ((j (in-range 5000))) (range 0 1000))
range-rbl: cpu time: 339 real time: 339 gc time: 12
range-ibl: cpu time: 258 real time: 258 gc time: 11
range-seq: cpu time: 1126 real time: 1156 gc time: 27
(for ((j (in-range 50000))) (range 0 100))
range-rbl: cpu time: 342 real time: 343 gc time: 9
range-ibl: cpu time: 264 real time: 265 gc time: 11
range-seq: cpu time: 1151 real time: 1151 gc time: 18
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: range-bench.scm
URL: <http://lists.racket-lang.org/dev/archive/attachments/20090502/d4975186/attachment.ksh>