Skip to content

Commit

Permalink
move benchmarking to a separate lein benchmark command
Browse files Browse the repository at this point in the history
  • Loading branch information
dakrone committed Dec 3, 2012
1 parent 18a1b4a commit 178e176
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
1 change: 1 addition & 0 deletions .travis.yml
@@ -1,5 +1,6 @@
language: clojure
lein: lein2
script: lein2 test :all
branches:
only:
- master
Expand Down
4 changes: 3 additions & 1 deletion ChangeLog.md
@@ -1,7 +1,9 @@
## Changes between Cheshire 5.0.0 and 5.0.1

No changes yet.
* Protocol custom encoders now take precedence over regular map
encoders.

* Benchmarking is now a separate lein command, not a test selector.

## Changes between Cheshire 5.0.0 and 4.0.x

Expand Down
7 changes: 3 additions & 4 deletions README.md
Expand Up @@ -298,10 +298,9 @@ to true:


<del>Benchmarks for custom encoding coming soon.</del> - check out the
benchmarks in `cheshire.test.benchmark`; or run `lein test
:benchmark`. If you have scenarios where Cheshire is not performing as
well as expected (compared to a different library), please let me
know.
benchmarks in `cheshire.test.benchmark`; or run `lein benchmark`. If
you have scenarios where Cheshire is not performing as well as
expected (compared to a different library), please let me know.

## Advanced customization for factories
See
Expand Down
Expand Up @@ -21,26 +21,26 @@
"set" #{"a" "b"}
"keyword" :foo})

(deftest ^{:benchmark true} t-bench-clj-json
(deftest t-bench-clj-json
(println "-------- clj-json Benchmarks --------")
(bench/with-progress-reporting
(bench/bench (clj-json/parse-string
(clj-json/generate-string test-obj)) :verbose))
(bench/quick-bench (clj-json/parse-string
(clj-json/generate-string test-obj)) :verbose))
(println "-------------------------------------"))

(deftest ^{:benchmark true} t-bench-clojure-json
(deftest t-bench-clojure-json
(println "-------- Data.json Benchmarks -------")
(bench/with-progress-reporting
(bench/bench (cj/read-str (cj/write-str test-obj)) :verbose))
(bench/quick-bench (cj/read-str (cj/write-str test-obj)) :verbose))
(println "-------------------------------------"))

(deftest ^{:benchmark true} t-bench-core
(deftest t-bench-core
(println "---------- Core Benchmarks ----------")
(bench/with-progress-reporting
(bench/bench (core/decode (core/encode test-obj)) :verbose))
(bench/quick-bench (core/decode (core/encode test-obj)) :verbose))
(println "-------------------------------------"))

(deftest ^{:benchmark true} t-bench-custom
(deftest t-bench-custom
(println "--------- Custom Benchmarks ---------")
(custom/add-encoder java.net.URL custom/encode-str)
(is (= "\"http://foo.com\"" (core/encode (java.net.URL. "http://foo.com"))))
Expand All @@ -50,7 +50,7 @@
(bench/quick-bench (core/decode (core/encode custom-obj)) :verbose)))
(println "-------------------------------------"))

(deftest ^{:benchmark true} t-bench-custom-kw-coercion
(deftest t-bench-custom-kw-coercion
(println "---- Custom keyword-fn Benchmarks ---")
(let [t (core/encode test-obj)]
(println "[+] (fn [k] (keyword k))")
Expand Down
15 changes: 8 additions & 7 deletions project.clj
Expand Up @@ -8,17 +8,18 @@
:dependencies [[com.fasterxml.jackson.core/jackson-core "2.1.1"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.1.1"]]
:profiles {:dev {:dependencies [[org.clojure/clojure "1.4.0"]
[criterium "0.3.0"]
[org.clojure/test.generative "0.1.4"]
[org.clojure/data.json "0.2.0"]
[clj-json "0.5.0"]]}
[org.clojure/test.generative "0.1.4"]]}
:1.2 {:dependencies [[org.clojure/clojure "1.2.1"]]}
:1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]}
:1.5 {:dependencies [[org.clojure/clojure "1.5.0-beta1"]]}}
:aliases {"all" ["with-profile" "dev,1.2:dev,1.3:dev:dev,1.5"]}
:1.5 {:dependencies [[org.clojure/clojure "1.5.0-beta1"]]}
:benchmark {:test-paths ["benchmarks"]
:dependencies [[criterium "0.3.1"]
[org.clojure/data.json "0.2.1"]
[clj-json "0.5.0"]]}}
:aliases {"all" ["with-profile" "dev,1.2:dev,1.3:dev:dev,1.5"]
"benchmark" ["with-profile" "dev,benchmark" "test"]}
:test-selectors {:default #(and (not (:benchmark %))
(not (:generative %)))
:benchmark :benchmark
:generative :generative
:all (constantly true)}
:jvm-opts ["-Xmx512M"])

0 comments on commit 178e176

Please sign in to comment.