Rust script runs fine, but executing binary working unexpected


I created a simple cpu_benchmarking script.
When I run this directly using it looks fine. The output looks like this:

Total runtime: 27.16s
Calculations per second: 14814814.81 seconds.

When I push to itHub some actions trigger to create executable binaries for Linux and Windows (I failed to get MacOS running).

Afterward I downloaded the binaries to Linux and tried to execute them. I granted permissions:

chmod +x ./cpu_benchmark_linux

And then I ran the code:


Now things get unexpected. The result is the following:

Total runtime: 36.25ms
Calculations per second: inf seconds.

So technically the script runs through, but it actually does not do the calculations I guess? I thought that it might be an issue that the script takes command line arguments, but actuallyit took the default value as it printed:

Running 400000000 calculations for 100 times split across all cores.

So I wonder what could lead to such a behaviour...

Let me guess, you ran the code locally without --release cargo flag?
It is likely that your benchmark was entirely optimised out in release build.


Ohhhhh what a blunder. Thank you so much!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.