Closed zarkone closed 6 years ago
Yeah, it looks nice and neat, but the performance is lower.
On my mac, for 300000 runs, I get ~3000 msecs with your solution and ~2000 with the original one.
(with-out-str (time (dotimes [_ 300000] (nano-id.core/nano-id))))
"\"Elapsed time: 3082.928719 msecs\"\n"
user=> (with-out-str (time (dotimes [_ 300000] (nano-id.core/nano-id))))
"\"Elapsed time: 3334.916919 msecs\"\n"
user=> (with-out-str (time (dotimes [_ 300000] (nano-id.core/nano-id))))
"\"Elapsed time: 2823.433563 msecs\"\n"
user=> (with-out-str (time (dotimes [_ 300000] (nano-id.core/nano-id))))
"\"Elapsed time: 1973.260103 msecs\"\n"
user=> (with-out-str (time (dotimes [_ 300000] (nano-id.core/nano-id))))
"\"Elapsed time: 1933.902395 msecs\"\n"
user=> (with-out-str (time (dotimes [_ 300000] (nano-id.core/nano-id))))
"\"Elapsed time: 1874.54506 msecs\"\n"
Got it, makes sense! Nevermind then, sorry for disturbing :)
No problem, man. (:
Looking at definition of str at clojure.core, I think this version of
core/nano-id
implementation is totally equivalent, but a little bit more readable and easier to maintain. But it's just my opinion, no pushing :)