Skip to content

Instantly share code, notes, and snippets.

@noahlz
Created July 7, 2013 20:40
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 noahlz/5944853 to your computer and use it in GitHub Desktop.
Save noahlz/5944853 to your computer and use it in GitHub Desktop.
Benchmarking ^char type-hint vs (char)
====== Benching (Character/isLetter ^char c) ======
WARNING: Final GC required 3.956775511289807 % of runtime
amd64 Linux 3.2.0-48-generic 2 cpu(s)
Java HotSpot(TM) 64-Bit Server VM 23.21-b01
Runtime arguments: -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Dclojure.compile.path=/tmp/oneoff/classes -Doneoff.version=0.1 -Dfile.encoding=UTF-8 -Dclojure.debug=false
Evaluation count : 5580540 in 60 samples of 93009 calls.
Execution time sample mean : 11.046857 µs
Execution time mean : 11.046903 µs
Execution time sample std-deviation : 24.758483 ns
Execution time std-deviation : 24.947300 ns
Execution time lower quantile : 10.982341 µs ( 2.5%)
Execution time upper quantile : 11.089820 µs (97.5%)
Overhead used : 22.302964 ns
Found 4 outliers in 60 samples (6.6667 %)
low-severe 3 (5.0000 %)
low-mild 1 (1.6667 %)
Variance from outliers : 1.6389 % Variance is slightly inflated by outliers
====== Benching (Character/isLetter (char c)) ======
amd64 Linux 3.2.0-48-generic 2 cpu(s)
Java HotSpot(TM) 64-Bit Server VM 23.21-b01
Runtime arguments: -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Dclojure.compile.path=/tmp/oneoff/classes -Doneoff.version=0.1 -Dfile.encoding=UTF-8 -Dclojure.debug=false
Evaluation count : 5460840 in 60 samples of 91014 calls.
Execution time sample mean : 11.294136 µs
Execution time mean : 11.294148 µs
Execution time sample std-deviation : 26.541266 ns
Execution time std-deviation : 26.966371 ns
Execution time lower quantile : 11.226729 µs ( 2.5%)
Execution time upper quantile : 11.340594 µs (97.5%)
Overhead used : 22.302964 ns
Found 10 outliers in 60 samples (16.6667 %)
low-severe 2 (3.3333 %)
low-mild 3 (5.0000 %)
high-mild 4 (6.6667 %)
high-severe 1 (1.6667 %)
Variance from outliers : 1.6389 % Variance is slightly inflated by outliers
;; INSTRUCTIONS: add lein oneoff (https://github.com/mtyaka/lein-oneoff) to your profiles.clj
;; and run "lein oneoff char-benchmark.clj"
#_(defdeps [[org.clojure/clojure "1.5.1"]
[criterium "0.4.1"]])
(use 'criterium.core)
(def data "abcdefghijklmnopqrstuvwxyz1234567890")
(println "====== Benching (Character/isLetter ^char c) ====== ")
(bench (dorun (filter #(Character/isLetter ^char %) data)) :verbose)
(println)
(println "====== Benching (Character/isLetter (char c)) ====== ")
(bench (dorun (filter #(Character/isLetter (char %)) data)) :verbose)
@noahlz
Copy link
Author

noahlz commented Jul 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment