Skip to content

Instantly share code, notes, and snippets.

@noisesmith
Created December 28, 2015 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noisesmith/71b0c6c8d48c91fcb30d to your computer and use it in GitHub Desktop.
Save noisesmith/71b0c6c8d48c91fcb30d to your computer and use it in GitHub Desktop.
comparison of subs vs. apply str butlast
user=> (crit/bench (apply str (butlast "abcdefghijklmnopqrstuvwxyz")))
WARNING: Final GC required 1.1330059801880759 % of runtime
Evaluation count : 23463000 in 60 samples of 391050 calls.
Execution time mean : 2.565453 µs
Execution time std-deviation : 35.362281 ns
Execution time lower quantile : 2.508671 µs ( 2.5%)
Execution time upper quantile : 2.643954 µs (97.5%)
Overhead used : 1.563540 ns
nil
user=> (crit/bench (let [s "abcdefghijklmnopqrstuvwxyz"] (subs s 0 (max 0 (dec (count s))))))
WARNING: Final GC required 1.352930832614215 % of runtime
Evaluation count : 951202200 in 60 samples of 15853370 calls.
Execution time mean : 62.722740 ns
Execution time std-deviation : 0.805427 ns
Execution time lower quantile : 61.060393 ns ( 2.5%)
Execution time upper quantile : 63.973552 ns (97.5%)
Overhead used : 1.853935 ns
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment