Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-28 Thread Timur Sungur
Thanks everyone for their answers and extra efforts. They are really helpful. On Mon, Apr 27, 2015, 18:56 Alex Miller a...@puredanger.com wrote: I fleshed out some of this a bit more in a blog post with perf numbers in case anyone's interested: http://insideclojure.org/2015/04/27/poly-perf/

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread Andy-
You're right. I didn't check it enough. I did check out the source (and btw, was very impressed with the result) but it looks like the function call ended up doing nothing. I just put in a side effect and I got the following results: [a :one], (multi-test), 100 runs, 2933 msecs [a :one],

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread David Nolen
A quick glance at your benchmarking setup, it's not clear that you are benchmarking what you think you are benchmarking, and jsperf is not a suitable benchmarking harness (irrespective of it's popularity). Benchmarking is hard, benchmarking JavaScript is harder, and benchmarking JavaScript that

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread Andy-
Looks like they're pretty slow compared to a simple case: http://jsperf.com/cljs-multimethods https://github.com/rauhs/cljs-perf On Saturday, April 25, 2015 at 10:33:18 AM UTC-4, Timur wrote: Hi everyone, There are situations where I want to dispatch functions using based on their

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread Phillip Lord
I think that the answer is, it depends, and, there might be some surprises in store. In my own use, I found multimethods collapse in performance as a result of changes to the interface hierarchy in the library I was using (my tests cases went from 45s to over 4mins). I circumvented this by

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread Phillip Lord
Alex Miller a...@puredanger.com writes: Sounds like you might have been running into the absence of multimethod caching for the default case (http://dev.clojure.org/jira/browse/CLJ-1429), which has been fixed in 1.7. No, I don't think; my default case was and is throw an exception.

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread Alex Miller
Sounds like you might have been running into the absence of multimethod caching for the default case (http://dev.clojure.org/jira/browse/CLJ-1429), which has been fixed in 1.7. Just on a side note, that repo does not change the default lein :jvm-opts, which are bad for benchmarking. I

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-27 Thread Alex Miller
I fleshed out some of this a bit more in a blog post with perf numbers in case anyone's interested: http://insideclojure.org/2015/04/27/poly-perf/ On Saturday, April 25, 2015 at 9:39:06 PM UTC-5, Alex Miller wrote: On Saturday, April 25, 2015 at 9:33:18 AM UTC-5, Timur wrote: Hi everyone,

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-26 Thread Ivan Reese
Thanks for that great rundown, Alex! I am also very interested in how the different approaches to dynamic dispatch compare in CLJS, if anyone is able to shed some light on that. Especially, whether or not case is const time — the doc string says it is, but your comments seem to suggest that it

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-26 Thread David Nolen
Nearly all the performance notes about Clojure multimethods apply to ClojureScript. On Saturday, April 25, 2015, Alex Miller a...@puredanger.com wrote: I should say all of that is for Clojure and likely bears no similarity to the nuances in ClojureScript. On Saturday, April 25, 2015 at

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-25 Thread Alex Miller
I should say all of that is for Clojure and likely bears no similarity to the nuances in ClojureScript. On Saturday, April 25, 2015 at 9:39:06 PM UTC-5, Alex Miller wrote: On Saturday, April 25, 2015 at 9:33:18 AM UTC-5, Timur wrote: Hi everyone, There are situations where I want to

Re: Performance of defmulti in both ClojureScript and Clojure

2015-04-25 Thread Alex Miller
On Saturday, April 25, 2015 at 9:33:18 AM UTC-5, Timur wrote: Hi everyone, There are situations where I want to dispatch functions using based on their certain properties. I can also use case statements instead but it looks more coupled and more change is required if I want to add new

Performance of defmulti in both ClojureScript and Clojure

2015-04-25 Thread Timur
Hi everyone, There are situations where I want to dispatch functions using based on their certain properties. I can also use case statements instead but it looks more coupled and more change is required if I want to add new types. What I want to ask is if I need to avoid using multi-methods