Created
December 28, 2020 16:51
-
-
Save urza/5ff111dab30fd0764d6e3bb858053886 to your computer and use it in GitHub Desktop.
c# microbenchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// needs C# 9.0 or newer (top level statements) | |
// will utilize 100 % CPU and print elapsed seconds when finished | |
// Ryzen 5900x - cca 150 seconds | |
// you can also use int.MaxValue / 100 for shorter run | |
using System; | |
using System.Threading.Tasks; | |
var d = DateTime.Now; | |
Parallel.For(0, int.MaxValue, _ => new Random() ); | |
Console.WriteLine((DateTime.Now - d).TotalSeconds); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment