Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling multi arity fns seems to degrade performance. #529

Open
thomasmulvaney opened this issue Mar 16, 2017 · 0 comments
Open

Calling multi arity fns seems to degrade performance. #529

thomasmulvaney opened this issue Mar 16, 2017 · 0 comments

Comments

@thomasmulvaney
Copy link
Member

Here is a basic example:

(ns bad.performance.test
  (:require [pixie.time :as time]))

(println "No issue")
(dotimes [i 10]
  (t/time (reduce (fn ([_ _] nil)) nil (range 10000000))))

(println "Multi-arity issue")
(dotimes [i 10]
  (t/time (reduce (fn ([_ _] nil) ([_])) nil (range 10000000))))  

The output is below:

"Elapsed time: 36.200522 ms"
"Elapsed time: 28.493774 ms"
"Elapsed time: 32.007228 ms"
"Elapsed time: 32.310871 ms"
"Elapsed time: 31.159702 ms"
"Elapsed time: 30.122666 ms"
"Elapsed time: 27.858281 ms"
"Elapsed time: 27.836514 ms"
"Elapsed time: 29.166467 ms"
"Elapsed time: 29.809780 ms"
Multi-arity issue
"Elapsed time: 255.087997 ms"
"Elapsed time: 294.007728 ms"
"Elapsed time: 336.469480 ms"
"Elapsed time: 369.489639 ms"
"Elapsed time: 433.686057 ms"
"Elapsed time: 539.577651 ms"
"Elapsed time: 654.685995 ms"
"Elapsed time: 776.953019 ms"
"Elapsed time: 1090.215928 ms"
"Elapsed time: 835.943882 ms"

The performance seems to constantly degrade when a multi-arity fn is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant