3 ms·
Sorry, I can't seem to edit my answer anymore, but I was mistaken, C# version is using AOT. But the are other significant differences here: > var rounds = in
by mrsmrtss 10mo ago
Sorry, I can't seem to edit my answer anymore, but I was mistaken, C# version is using AOT. But the are other significant differences here:
> var rounds = int.Parse(File.ReadAllText("rounds.txt"));
> var pi = 1.0D;
> var x = 1.0D;
> for (var i = 2; i < rounds + 2; i++) {
> x = -x;
> pi += x / (2 \* i - 1);
> }
> pi \*= 4;
> Console.WriteLine(pi);
For example, if we change the type of 'rounds' variable here from int to double (like it is also in Go version), the code runs significantly faster on my machine.
- neonsunset 10mo agoTry that on ARM64 and the result will be the opposite :) On M4 Max, Go takes 0.982s to run while C# (non-SIMD) and F# are ~0.51s. Changing it to be closer to Go makes the performance worse in a similar manner.