Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
compare loop, recursive calls, recurring calls
(use 'criterium.core)
(defn looping [n]
(loop [i n]
(when (< 1 i)
(recur (dec i)))))
(defn recursive [n]
(when (< 1 n) (recursive (dec n))))
(defn tco [n]
(when (< 1 n) (recur (dec n))))
(defn tco2
([] (tco2 5))
([n] (when (< 1 n) (recur (dec n)))))
(defn bmark [n]
(println "looping" n)
(bench (looping n) :verbose)
(println "recursive" n)
(bench (recursive n) :verbose)
(println "tco" n)
(bench (tco n) :verbose)
(println "tco2" n)
(bench (tco2 n) :verbose))
(defn bmarks []
(bmark 10)
(bmark 1000))
(xampl.core/bmarks)
looping 10
x86_64 Mac OS X 10.6.6 8 cpu(s)
Java HotSpot(TM) 64-Bit Server VM 17.1-b03-307
Runtime arguments: -Dfile.encoding=UTF-8
Evaluation count : 780043500
Execution time mean : 78.084013 ns 95.0% CI: (78.070892 ns, 78.093285 ns)
Execution time std-deviation : 4.832753 us 95.0% CI: (4.782522 us, 4.883957 us)
Found 5 outliers in 60 samples (8.3333 %)
low-severe 3 (5.0000 %)
low-mild 2 (3.3333 %)
Variance from outliers : 6.2739 % Variance is slightly inflated by outliers
recursive 10
x86_64 Mac OS X 10.6.6 8 cpu(s)
Java HotSpot(TM) 64-Bit Server VM 17.1-b03-307
Runtime arguments: -Dfile.encoding=UTF-8
Evaluation count : 339902040
Execution time mean : 182.255031 ns 95.0% CI: (182.220704 ns, 182.283222 ns)
Execution time std-deviation : 8.083124 us 95.0% CI: (7.949713 us, 8.238344 us)
Found 4 outliers in 60 samples (6.6667 %)
low-severe 2 (3.3333 %)
low-mild 2 (3.3333 %)
Variance from outliers : 7.8125 % Variance is slightly inflated by outliers
tco 10
x86_64 Mac OS X 10.6.6 8 cpu(s)
Java HotSpot(TM) 64-Bit Server VM 17.1-b03-307
Runtime arguments: -Dfile.encoding=UTF-8
Evaluation count : 377653680
Execution time mean : 160.908237 ns 95.0% CI: (160.882899 ns, 160.928526 ns)
Execution time std-deviation : 5.652590 us 95.0% CI: (5.592985 us, 5.726846 us)
Found 2 outliers in 60 samples (3.3333 %)
low-severe 1 (1.6667 %)
low-mild 1 (1.6667 %)
Variance from outliers : 1.6389 % Variance is slightly inflated by outliers
tco2 10
x86_64 Mac OS X 10.6.6 8 cpu(s)
Java HotSpot(TM) 64-Bit Server VM 17.1-b03-307
Runtime arguments: -Dfile.encoding=UTF-8
Evaluation count : 376112760
Execution time mean : 158.737037 ns 95.0% CI: (158.725460 ns, 158.748836 ns)
Execution time std-deviation : 3.775872 us 95.0% CI: (3.748230 us, 3.807094 us)
Found 2 outliers in 60 samples (3.3333 %)
low-severe 1 (1.6667 %)
low-mild 1 (1.6667 %)
Variance from outliers : 1.6389 % Variance is slightly inflated by outliers
looping 1000
x86_64 Mac OS X 10.6.6 8 cpu(s)
Java HotSpot(TM) 64-Bit Server VM 17.1-b03-307
Runtime arguments: -Dfile.encoding=UTF-8
Evaluation count : 5890560
Execution time mean : 10.354814 us 95.0% CI: (10.354087 us, 10.355570 us)
Execution time std-deviation : 32.552575 us 95.0% CI: (32.326223 us, 32.780239 us)
Found 1 outliers in 60 samples (1.6667 %)
low-severe 1 (1.6667 %)
Variance from outliers : 1.6389 % Variance is slightly inflated by outliers
recursive 1000
x86_64 Mac OS X 10.6.6 8 cpu(s)
Java HotSpot(TM) 64-Bit Server VM 17.1-b03-307
Runtime arguments: -Dfile.encoding=UTF-8
Evaluation count : 2782620
Execution time mean : 22.024989 us 95.0% CI: (22.021495 us, 22.027931 us)
Execution time std-deviation : 81.761040 us 95.0% CI: (80.771783 us, 82.584477 us)
Found 6 outliers in 60 samples (10.0000 %)
low-severe 4 (6.6667 %)
low-mild 2 (3.3333 %)
Variance from outliers : 6.2771 % Variance is slightly inflated by outliers
tco 1000
x86_64 Mac OS X 10.6.6 8 cpu(s)
Java HotSpot(TM) 64-Bit Server VM 17.1-b03-307
Runtime arguments: -Dfile.encoding=UTF-8
Evaluation count : 3197460
Execution time mean : 19.138813 us 95.0% CI: (19.135399 us, 19.143925 us)
Execution time std-deviation : 96.733389 us 95.0% CI: (95.850014 us, 97.654636 us)
Found 1 outliers in 60 samples (1.6667 %)
low-severe 1 (1.6667 %)
Variance from outliers : 9.4567 % Variance is slightly inflated by outliers
tco2 1000
x86_64 Mac OS X 10.6.6 8 cpu(s)
Java HotSpot(TM) 64-Bit Server VM 17.1-b03-307
Runtime arguments: -Dfile.encoding=UTF-8
Evaluation count : 3177360
Execution time mean : 19.117219 us 95.0% CI: (19.115299 us, 19.119325 us)
Execution time std-deviation : 79.230725 us 95.0% CI: (77.715232 us, 80.942765 us)
Found 5 outliers in 60 samples (8.3333 %)
low-severe 3 (5.0000 %)
low-mild 2 (3.3333 %)
Variance from outliers : 7.7758 % Variance is slightly inflated by outliers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.