diff options
author | Stuart Halloway <stu@thinkrelevance.com> | 2010-04-12 21:26:48 -0400 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2010-04-12 21:26:48 -0400 |
commit | 6dd033d9e12337f6630faa3d3f5c2e901a28c4f4 (patch) | |
tree | f54058280a93ae8b10a4d7e2d3671489aad14468 | |
parent | ebf0d212dcc076ebee6984d276ff037ce1a7ecbe (diff) |
fixed corner case in c.c.profile print-summary
-rw-r--r-- | src/main/clojure/clojure/contrib/profile.clj | 2 | ||||
-rw-r--r-- | src/test/clojure/clojure/contrib/test_profile.clj | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/main/clojure/clojure/contrib/profile.clj b/src/main/clojure/clojure/contrib/profile.clj index bd26ddfa..2af2a014 100644 --- a/src/main/clojure/clojure/contrib/profile.clj +++ b/src/main/clojure/clojure/contrib/profile.clj @@ -95,7 +95,7 @@ profiling code."} *enable-profiling* true) (defn print-summary "Prints a table of the results returned by summarize." [profile-summary] - (let [name-width (apply max (map (comp count name) (keys profile-summary))) + (let [name-width (apply max 1 (map (comp count name) (keys profile-summary))) fmt-string (str "%" name-width "s %8d %8d %8d %8d %8d%n")] (printf (.replace fmt-string \d \s) "Name" "mean" "min" "max" "count" "sum") diff --git a/src/test/clojure/clojure/contrib/test_profile.clj b/src/test/clojure/clojure/contrib/test_profile.clj new file mode 100644 index 00000000..560b58db --- /dev/null +++ b/src/test/clojure/clojure/contrib/test_profile.clj @@ -0,0 +1,8 @@ +(ns clojure.contrib.test-profile + (:use clojure.test + clojure.contrib.profile)) + +(deftest test-print-summary + (testing "doesn't blow up with no data (assembla #31)" + (is (= "Name mean min max count sum\n" + (with-out-str (print-summary {})))))) |