-
Notifications
You must be signed in to change notification settings - Fork 86
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
first benchmark is expensive #273
Comments
My guess is that sharing is the problem. Do things improve if you write it like this? main = defaultMain
[ bench "1" $ nf length [1 .. 10^7 + 3 :: Int ]
, bench "2" $ nf length [1 .. 10^7 + 2 :: Int ]
, bench "3" $ nf length [1 .. 10^7 + 1 :: Int ]
] |
no change, see #274 |
Also, same behaviour when I write it like this
|
@treeowl I have the feeling that your analysis might be right. But why would your example reduce sharing? It still has @jwaldmann also, your example has the same expression (I might be totally wrong about the kind of optimizations that may be at play here.) |
I think I can reproduce, but the effect is not as strong as with your machine:
I changed the code a bit to try and avoid the problem: main = defaultMain
[ bench "1" $ nf length [1 * 10^7 .. 2 * 10^7 :: Int ]
, bench "2" $ nf length [3 * 10^7 .. 4 * 10^7 :: Int ]
, bench "3" $ nf length [5 * 10^7 .. 6 * 10^7 :: Int ]
] But still the effect is visible:
So I guess my comments about sharing are incomplete. |
I expect identical output for the three benchmarks, but the first one (consistently) needs double time. (Possibly related: #60)
For criterion-1.6.0.0, with ghc-8.10.7 .. ghc-9.6.1
The text was updated successfully, but these errors were encountered: