3 ms·
Another possibility is that GCC discovered that the loop had no side effects in the benchmark harness and eliminated it. This is a very common thing that happen
by pcwalton 9y ago
Another possibility is that GCC discovered that the loop had no side effects in the benchmark harness and eliminated it. This is a very common thing that happens in microbenchmarks.
- gizmo686 9y agoThe c code defines a function that returns the sum computed in the loop. This function is than run using Haskell's FFI. GCC has no way of knowing there is no side effects, because other code might link to it and use the result of the function. GHC, in concept, does know that there are no side effects, but that would apply to all of the functions being tested. Further, since it is using a benchmarking library, I assume the authors of said library were aware of the issue, and wrote it in such a way as to force evalutation of the function. https://gist.github.com/snoyberg/9b1c77b595c4adf90880213fc49f2a21#file-main-hs https://gist.github.com/snoyberg/9b1c77b595c4adf90880213fc49...