From fdff6aacd110efd014419692dbd925d85a4f85ff Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Sun, 20 Jan 2013 19:37:08 +0700 Subject: [PATCH] Add autobench to tests --- {benchmarks => src/taoensso/nippy}/benchmarks.clj | 2 ++ test/test_nippy/main.clj | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) rename {benchmarks => src/taoensso/nippy}/benchmarks.clj (97%) diff --git a/benchmarks/benchmarks.clj b/src/taoensso/nippy/benchmarks.clj similarity index 97% rename from benchmarks/benchmarks.clj rename to src/taoensso/nippy/benchmarks.clj index 4f56786..eeed80a 100644 --- a/benchmarks/benchmarks.clj +++ b/src/taoensso/nippy/benchmarks.clj @@ -14,6 +14,8 @@ (def roundtrip (comp thaw-from-bytes freeze-to-bytes)) (def reader-roundtrip (comp reader-thaw reader-freeze)) +(defn autobench [] (bench (roundtrip data))) + (comment ;;; Times diff --git a/test/test_nippy/main.clj b/test/test_nippy/main.clj index ec4e41a..bec0e6a 100644 --- a/test/test_nippy/main.clj +++ b/test/test_nippy/main.clj @@ -1,10 +1,17 @@ (ns test-nippy.main (:use [clojure.test]) - (:require [taoensso.nippy :as nippy])) + (:require [taoensso.nippy :as nippy] + [taoensso.nippy.benchmarks :as benchmarks])) ;; Remove stuff from stress-data that breaks roundtrip equality (def test-data (dissoc nippy/stress-data :bytes)) (def roundtrip (comp nippy/thaw-from-bytes nippy/freeze-to-bytes)) -(deftest test-roundtrip (is (= test-data (roundtrip test-data)))) \ No newline at end of file +(deftest test-roundtrip (is (= test-data (roundtrip test-data)))) + +(println "Benchmarking roundtrips (x3)") +(println "----------------------------") +(println (benchmarks/autobench)) +(println (benchmarks/autobench)) +(println (benchmarks/autobench))