why Seq.iter is 2x faster than for loop if target is for x64?

后端 未结 2 915
一生所求
一生所求 2021-02-20 17:00

Disclaim: This is micro-benchmark, please do not comment quotes such as \"premature optimization is evil\" if you feel unhappy about the topic.

Examples are release targ

2条回答
  •  说谎
    说谎 (楼主)
    2021-02-20 17:49

    When I run the experiment on my machine (using F# 3.0 in VS 2012 in Release mode), I do not get the times you describe. Do you consistently get the same numbers when you run it repeatedly?

    I tried it about 4 times and I always get numbers that are very similar. The version with Seq.iter tends to be slightly faster, but this is probably not statistically significant. Something like (using Stopwatch):

    test(1) = 15321ms
    test(2) = 5149ms
    test(3) = 14290ms
    test(4) = 4999ms
    

    I'm running the test on a laptop with Intel Core2 Duo (2.26Ghz), using 64bit Windows 7.

提交回复
热议问题