diff --git a/MyBenchmark.cs b/MyBenchmark.cs index 0d2d979..0557f95 100644 --- a/MyBenchmark.cs +++ b/MyBenchmark.cs @@ -1,4 +1,6 @@ -using System.Security.Cryptography; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Security.Cryptography; using System.Threading; using System.Timers; using BenchmarkDotNet.Attributes; @@ -85,6 +87,8 @@ public void FullCpuLoad() MaxDegreeOfParallelism = Environment.ProcessorCount, }; + Process.GetCurrentProcess().ProcessorAffinity = (IntPtr)0xFF; + Parallel.For(0, NumIterations, options, i => { DoWork(i); @@ -93,7 +97,10 @@ public void FullCpuLoad() private void DoWork(int index) { - Thread.CurrentThread.Priority = ThreadPriority.Normal; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; + } double result = 1; for (int i = 1; i <= 100; i++) diff --git a/Program.cs b/Program.cs index 9fd3a80..79c5f61 100644 --- a/Program.cs +++ b/Program.cs @@ -42,9 +42,12 @@ static void Main(string[] args) RunBenchmark(); } - // Prevent the console from closing immediately - Console.WriteLine("Press Enter to exit to exit..."); - Console.ReadLine(); + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + // Prevent app exit on macOS + Console.WriteLine("Press Enter to exit to exit..."); + Console.ReadLine(); + } } static void DisplayMacInfo() @@ -382,7 +385,7 @@ static void RunBenchmark() Console.WriteLine("3. Multithread Benchmark"); Console.WriteLine("4. Run all benchmarks"); #if DEBUG - Console.WriteLine("5. Debug CPU bench"); + Console.WriteLine("5. Debug Mode"); #endif Console.ForegroundColor = ConsoleColor.White; @@ -397,7 +400,7 @@ static void RunBenchmark() ["3"] = () => BenchmarkRunner.Run(), ["4"] = () => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).RunAll(), #if DEBUG - ["5"] = () => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(new[] { "Benchmark.CPUBenchmark" }, new DebugInProcessConfig()) + ["5"] = () => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(new[] { "Benchmarks" }, new DebugInProcessConfig()) #endif }; diff --git a/README.md b/README.md index 0234845..2650431 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Benchmark (.NET 8) -- A C# console program that gets your system specs then lets you run benchmarks on your system. +- A C# console program displays system specs then lets you run benchmarks on your system. - This program will attempt to get your CPU,RAM & GPU specs. - You can run a Hashing benchmark with MD5, SHA256 and SHA512. -- Or a single thread and multi thread benchmark. -- Or a encrypt/decrypt benchmark (May need admin privileges) +- Or an intensive CPU benchmark. +- Or an encrypt/decrypt benchmark (May need admin privileges) - Using `BenchmarkDotNet` , `SharpDX`, `NvAPIWrapper` and `Hardware.info` # Maintenance @@ -46,6 +46,13 @@ - .NET 8.0.2 from `here` +# Debugging +- Set a breakpoint anywhere. +- Run the program in `Debug` mode. +- Use option `5` to start debugging. +- Select the benchmark you want to debug. +- The program will pause at the breakpoint. + # Output @@ -64,79 +71,70 @@ - `Global Runtime` in `seconds(s)` can also be the benchmark. - There might be a 20 seconds delay on first use due to hardware detection by `Hardware.Info`. -# Compare your results to mine! +# Specs for tested systems. -## MacBookPro 16" 2021 `macOS 13.6` +## MacBookPro 16" 2021 ```ini -Apple M1 Max 10/32, 1 CPU, 10 logical and 10 physical cores (8P/2E) +Apple M1 Max 10/32, 10 Cores 10 Threads (8P/2E) +32GB LPDDR5 6400MHz +macOS 13.6 ``` -- .NET 7 Runtime: `98s` -- .NET 8 Runtime: `42s` - -## MacBookPro 14" 2023 `macOS 13.6` +## MacBookPro 14" 2023 ```ini -Apple M2 Pro 10/16, 1 CPU, 10 logical and 10 physical cores (6P/4E) +Apple M2 Pro 10/16, 10 Cores 10 Threads (6P/4E) +16GB LPDDR5 6400MHz +macOS 13.6 ``` -- .NET 7 Runtime: `92s` -- .NET 8 Runtime: `35s` - -## MacBookPro 13" 2017 `MacOS 13` +## MacBookPro 13" 2017 ```ini -Intel Core i5-7660U CPU 2.20GHz (Kaby Lake), 1 CPU, 4 logical and 2 physical cores (2P/0E) +Intel Core i5-7660U CPU 2.20GHz (Kaby Lake), 2 Cores 4 Threads (2P/0E) +8GB DDR3 2133MHz +macOS 12 ``` -- .Net 7 Runtime: `573s` -- .Net 8 Runtime: `401s` - -## MacBookPro 15" 2018 `Windows 10 bootcamp` +## MacBookPro 15" 2018 ```ini -Intel Core i7-8850H CPU 2.60GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores (6P/0E) +Intel Core i7-8850H CPU 2.60GHz (Coffee Lake), 6 Cores 12 Threads (6P/0E) +16GB DDR4 2400MHz +Windows 10 bootcamp ``` -- .NET 7 Runtime: `216s` -- .NET 8 Runtime: `191s` - -## MacBookPro 15" 2018 `MacOS 13` +## MacBookPro 15" 2018 ```ini -Intel Core i7-8850H CPU 2.60GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores (6P/0E) +Intel Core i7-8850H CPU 2.60GHz (Coffee Lake), 6 Cores 12 Threads (6P/0E) +16GB DDR4 2400MHz +macOS 13 ``` -- .NET 7 Runtime: `216s` -- .NET 8 Runtime: `133s` - -## Desktop i7 +## Desktop PC ```ini -Intel Core i7-8700K CPU 3.70GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores (6P/0E) +Intel Core i7-8700K CPU 3.70GHz (Coffee Lake), 6 Cores 12 Threads (6P/0E) +16GB DDR4 3600MHz +Windows 11 ``` -- .NET 8 Runtime: `105s` -- .NET 7 Runtime: `151s` - -## Desktop ThreadRipper +## Workstation ```ini -Ryzen Thread Ripper 1950X CPU 3.9GHz (Zen 1), 1 CPU, 32 logical and 16 physical cores (16P/0E) +Ryzen Thread Ripper 1950X CPU 3.9GHz (Zen 1), 16 Cores 32 Threads (16P/0E) +32GB DDR4 3400MHz +Windows 10 ``` -- Runtime: `49s` - ## Dell latitude 5531 ```ini -Intel Core i7-12800H CPU 1.80GHz (Alder Lake), 1 CPU, 20 logical and 14 physical cores (6P/8E) +Intel Core i7-12800H CPU 1.80GHz (Alder Lake), 14 Cores 20 Threads (6P/8E) ``` -- .NET7 Runtime: `46s` -- .NET8 Runtime: `32s` - ## .NET 7 Ranking: 1. Dell latitude 5531 - i7-12800H @ 55W `46s`