Same program faster on Linux than Windows — why?

前端 未结 3 1992
臣服心动
臣服心动 2020-12-19 07:27

The solution to this was found in the question Executable runs faster on Wine than Windows -- why? Glibc\'s floor() is probably implemented in

3条回答
  •  清酒与你
    2020-12-19 08:16

    You'd be surprised what system libraries are involved. Just do ldd on your app, and see which are used (ok, not that much, but certainly glibc).

    In order to completely trust your findings about execution speed, you would need to run your app a couple of times sequentially and take the mean execution time. It might be that the OS loader is just slower (although 4s is a long loading time).

    Other very possible reasons are:

    1. Different malloc implementation
    2. Exception handling, if used to the extreme might cause slowdown (Windows GCC, MinGW, might not be the optimal exception handling star of the show)
    3. OS-dependent initialization: stuff that needs to be done at program startup on Windows, but not on Linux.

    Most of these are easily benchmarkable ;-)


    An update to your update: the only thing you can now do is profile. Stop guessing, and let a profiler tell you where time is being spent. Use gprof and the Visual Studio built-in profiler and compare time spent in different functions.

提交回复
热议问题