Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added definline; ambiguous results

  • Loading branch information...
commit b67bab9aaef5439463543f4e453001c911daa09e 1 parent 3c7ea0c
Stuart Sierra authored
Showing with 15 additions and 0 deletions.
  1. +15 −0 time-trials.clj
15 time-trials.clj
View
@@ -125,3 +125,18 @@
(compare-times "Avoiding Var lookups" 1000000
(* *value* *value*)
(* value value)))
+
+(defn square [x] (* x x))
+
+(definline square-inline [x] `(let [z# ~x] (* z# z#)))
+
+(compare-times "Using definline" 10000
+ (loop [i 1]
+ (when (< i 100)
+ (square i)
+ (recur (inc i))))
+ (loop [i 1]
+ (when (< i 100)
+ (square-inline i)
+ (recur (inc i)))))
+
Please sign in to comment.
Something went wrong with that request. Please try again.