Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: lynaghk/profile-cljs
base: 359350f386
...
head fork: lynaghk/profile-cljs
compare: 6e06c801a7
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
9 src/clj/util/macros.clj
@@ -14,12 +14,13 @@
(defmacro profile [opts & body]
(let [timing (merge (if (string? opts) {:group opts} opts)
- {:lang "cljs"
- :src (join "\n" (map pr-str body))})]
+ {:lang "cljs"
+ :src (join "\n" (map pr-str body))})
+ n (get timing :n 1)]
`(let [start# (.getTime (js/Date.))
- ret# (do ~@body)
+ ret# (dotimes [_# ~n] ~@body)
dt# (- (.getTime (js/Date.)) start#)]
-
+
(js/add_timing (apply ~'js-obj
(flatten (map (fn [[k# v#]] [(name k#) v#])
(assoc ~timing :dt dt#)))))
View
15 src/cljs/microbenchmarks/seqs.cljs
@@ -6,3 +6,18 @@
(profile "map inc"
(doall (map inc (range 100000))))
+
+(let [l (list 1 2 3)]
+ (profile {:group "lists" :n 100000} (satisfies? ISeq l))
+ (profile {:group "lists" :n 100000} (first l))
+ (profile {:group "lists" :n 100000} (-first l))
+ (profile {:group "lists" :n 100000} (rest l))
+ (profile {:group "lists" :n 100000} (next l)))
+
+(let [v [1 2 3]]
+ (profile {:group "vectors" :n 100000} (satisfies? ISeq v))
+ (profile {:group "vectors" :n 100000} (first v))
+ (profile {:group "vectors" :n 100000} (rest v))
+ (profile {:group "vectors" :n 100000} (next v)))
+
+
View
6 src/cljs/viewer/core.cljs
@@ -1,6 +1,7 @@
(ns viewer.core
(:use-macros [c2.util :only [p pp]])
- (:use [c2.core :only [unify!]])
+ (:use [c2.core :only [unify!]]
+ [c2.maths :only [median]])
(:require [c2.dom :as dom]
[c2.event :as event]))
@@ -36,7 +37,8 @@
[:tbody
(map (fn [[src timings]]
[:tr
- [:td.time (pr-str (map :dt timings))]
+ ;;[:td.time (pr-str (map :dt timings))]
+ [:td.time (median (map :dt timings))]
[:td.code [:pre [:code src]]]])
(group-by :src timings))]]])
:key-fn (fn [[group timings]] group))
View
5 src/sass/style.sass
@@ -1,2 +1,7 @@
td.code
vertical-align: top
+
+td.time
+ text-align: right
+ font-family: monospace
+ font-size: 2em

No commit comments for this range

Something went wrong with that request. Please try again.