Last active
December 31, 2015 19:09
-
-
Save qerub/8031665 to your computer and use it in GitHub Desktop.
[Clojure/Java] Benchmarks of different ways of splitting a string by a char
This file contains 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
# Benchmarking (.split test-input "\\.") | |
Evaluation count : 72101040 in 60 samples of 1201684 calls. | |
Execution time mean : 828.458928 ns | |
Execution time std-deviation : 29.055494 ns | |
Execution time lower quantile : 800.771006 ns ( 2.5%) | |
Execution time upper quantile : 895.752028 ns (97.5%) | |
Overhead used : 2.778847 ns | |
Found 5 outliers in 60 samples (8.3333 %) | |
low-severe 2 (3.3333 %) | |
low-mild 3 (5.0000 %) | |
Variance from outliers : 22.1807 % Variance is moderately inflated by outliers | |
# Benchmarking (.split #"\." test-input) | |
Evaluation count : 96236220 in 60 samples of 1603937 calls. | |
Execution time mean : 629.194967 ns | |
Execution time std-deviation : 17.581353 ns | |
Execution time lower quantile : 611.170657 ns ( 2.5%) | |
Execution time upper quantile : 685.200170 ns (97.5%) | |
Overhead used : 2.778847 ns | |
Found 5 outliers in 60 samples (8.3333 %) | |
low-severe 2 (3.3333 %) | |
low-mild 3 (5.0000 %) | |
Variance from outliers : 15.7402 % Variance is moderately inflated by outliers | |
# Benchmarking (org.apache.commons.lang3.StringUtils/split test-input \.) | |
Evaluation count : 335815860 in 60 samples of 5596931 calls. | |
Execution time mean : 177.416984 ns | |
Execution time std-deviation : 5.619332 ns | |
Execution time lower quantile : 171.281009 ns ( 2.5%) | |
Execution time upper quantile : 191.734901 ns (97.5%) | |
Overhead used : 2.778847 ns | |
Found 7 outliers in 60 samples (11.6667 %) | |
low-severe 2 (3.3333 %) | |
low-mild 5 (8.3333 %) | |
Variance from outliers : 18.9616 % Variance is moderately inflated by outliers |
This file contains 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
;; lein try criterium org.apache.commons/commons-lang3 | |
(use 'criterium.core) | |
(defmacro multibench [& exprs] | |
`(do ~@(for [expr# exprs] | |
`(do (println "#" "Benchmarking" (pr-str '~expr#)) | |
(println) | |
(bench ~expr#) | |
(println))))) | |
(def ^String test-input "foo.bar.baz.foo.bar.baz") | |
(multibench (.split test-input "\\.") | |
(.split #"\." test-input) | |
(org.apache.commons.lang3.StringUtils/split test-input \.)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment