Created
June 1, 2015 17:15
-
-
Save halgari/5d7780e6f068ae217bb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Code: | |
(ns vararg-bench.core | |
(:require [criterium.core :refer [quick-bench]]) | |
(:gen-class)) | |
(defn varargs [arg1 & [arg2 arg3]] | |
42) | |
(defn multi-arity | |
([arg1] 42) | |
([arg1 arg2 arg3] 42)) | |
(defn -main [& args] | |
(println "Multi 1 arg") | |
(quick-bench | |
(multi-arity 0)) | |
(println "Multi 3 args") | |
(quick-bench | |
(multi-arity 0 1 2)) | |
(println "Varargs 3 args") | |
(quick-bench | |
(varargs 0 1 2)) | |
(println "Varargs 1 arg") | |
(quick-bench | |
(varargs 0)) | |
(println "done") | |
) | |
Results: | |
Multi 1 arg | |
WARNING: Final GC required 11.96553987877032 % of runtime | |
Evaluation count : 178108254 in 6 samples of 29684709 calls. | |
Execution time mean : 1.705851 ns | |
Execution time std-deviation : 0.374609 ns | |
Execution time lower quantile : 1.440546 ns ( 2.5%) | |
Execution time upper quantile : 2.217680 ns (97.5%) | |
Overhead used : 2.025919 ns | |
Multi 3 args | |
WARNING: Final GC required 8.825457788652507 % of runtime | |
Evaluation count : 88559226 in 6 samples of 14759871 calls. | |
Execution time mean : 4.772424 ns | |
Execution time std-deviation : 0.193746 ns | |
Execution time lower quantile : 4.575359 ns ( 2.5%) | |
Execution time upper quantile : 5.033764 ns (97.5%) | |
Overhead used : 2.025919 ns | |
Varargs 3 args | |
WARNING: Final GC required 5.84196898525402 % of runtime | |
Evaluation count : 2284332 in 6 samples of 380722 calls. | |
Execution time mean : 275.363710 ns | |
Execution time std-deviation : 10.114462 ns | |
Execution time lower quantile : 261.470808 ns ( 2.5%) | |
Execution time upper quantile : 286.310783 ns (97.5%) | |
Overhead used : 2.025919 ns | |
Varargs 1 arg | |
WARNING: Final GC required 9.368379907246801 % of runtime | |
Evaluation count : 50935794 in 6 samples of 8489299 calls. | |
Execution time mean : 10.233299 ns | |
Execution time std-deviation : 0.621089 ns | |
Execution time lower quantile : 9.613323 ns ( 2.5%) | |
Execution time upper quantile : 11.154822 ns (97.5%) | |
Overhead used : 2.025919 ns | |
Found 1 outliers in 6 samples (16.6667 %) | |
low-severe 1 (16.6667 %) | |
Variance from outliers : 14.7029 % Variance is moderately inflated by outliers | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment