Skip to content

Instantly share code, notes, and snippets.

@thefloweringash
Created October 10, 2013 22:37
Show Gist options
  • Save thefloweringash/6926689 to your computer and use it in GitHub Desktop.
Save thefloweringash/6926689 to your computer and use it in GitHub Desktop.
apply str vs reduce str
user=> (def input (take 10000 (cycle (map char (range (int \a) (int \z))))))
#'user/input
user=> (bench (reduce str input))
Evaluation count : 1800 in 60 samples of 30 calls.
Execution time mean : 33.756996 ms
Execution time std-deviation : 278.588482 µs
Execution time lower quantile : 33.542863 ms ( 2.5%)
Execution time upper quantile : 34.797430 ms (97.5%)
Overhead used : 4.038278 ns
Found 6 outliers in 60 samples (10.0000 %)
low-severe 2 (3.3333 %)
low-mild 4 (6.6667 %)
Variance from outliers : 1.6389 % Variance is slightly inflated by outliers
nil
user=> (bench (apply str input))
Evaluation count : 86580 in 60 samples of 1443 calls.
Execution time mean : 692.983707 µs
Execution time std-deviation : 1.606027 µs
Execution time lower quantile : 688.212871 µs ( 2.5%)
Execution time upper quantile : 694.883263 µs (97.5%)
Overhead used : 4.038278 ns
Found 10 outliers in 60 samples (16.6667 %)
low-severe 5 (8.3333 %)
low-mild 2 (3.3333 %)
high-mild 2 (3.3333 %)
high-severe 1 (1.6667 %)
Variance from outliers : 1.6389 % Variance is slightly inflated by outliers
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment