Skip to content

Commit

Permalink
Do some performance tests using Criterium
Browse files Browse the repository at this point in the history
  • Loading branch information
hlship committed Feb 11, 2016
1 parent 759fd7a commit c37cba0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
[org.clojure/tools.logging "0.3.1" :optional true]]
:plugins [[lein-codox "0.9.0"]]
:profiles {:1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}
:1.8 {:dependencies [[org.clojure/clojure "1.8.0-RC3"]]}}
:1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}
:dev {:dependencies [[criterium "0.4.3"]]}}
;; Part of release is currently manual; copy target/docs to the AvisoNovate/docs/pretty folder
:aliases {"release" ["do"
"clean,"
Expand Down
27 changes: 23 additions & 4 deletions test/user.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
(ns user (import (java.sql SQLException))
(use [io.aviso ansi binary exception repl]
[clojure test pprint]))
(ns user
(:use [io.aviso ansi binary exception repl]
[clojure test pprint])
(:require [clojure.java.io :as io]
[criterium.core :as c])
(:import (java.sql SQLException)))

(install-pretty-exceptions)

Expand Down Expand Up @@ -52,4 +55,20 @@
[n]
(if (zero? n)
(throw (RuntimeException. "Boom!"))
(countdown (dec n))))
(countdown (dec n))))

(comment

;; 11 Feb 2016 - 553 µs (14 µs std dev) - Clojure 1.8

(let [out (io/writer "target/output.txt")
e (make-ex-info)]
(c/bench (write-exception out e)))

;; 11 Feb 2016 - 213 µs (4 µs std dev) - Clojure 1.8

(let [e (make-ex-info)]
(c/bench (doseq [x (analyze-exception e nil)]
(-> x :stack-trace doall))))

)

0 comments on commit c37cba0

Please sign in to comment.