Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: feature => master #61

Merged
merged 4 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions MyBenchmark.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -85,6 +87,8 @@
MaxDegreeOfParallelism = Environment.ProcessorCount,
};

Process.GetCurrentProcess().ProcessorAffinity = (IntPtr)0xFF;

Check warning on line 90 in MyBenchmark.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

This call site is reachable on all platforms. 'Process.ProcessorAffinity' is only supported on: 'linux', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 90 in MyBenchmark.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

This call site is reachable on all platforms. 'Process.ProcessorAffinity' is only supported on: 'linux', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 90 in MyBenchmark.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

This call site is reachable on all platforms. 'Process.ProcessorAffinity' is only supported on: 'linux', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 90 in MyBenchmark.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

This call site is reachable on all platforms. 'Process.ProcessorAffinity' is only supported on: 'linux', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 90 in MyBenchmark.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

This call site is reachable on all platforms. 'Process.ProcessorAffinity' is only supported on: 'linux', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 90 in MyBenchmark.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

This call site is reachable on all platforms. 'Process.ProcessorAffinity' is only supported on: 'linux', 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Parallel.For(0, NumIterations, options, i =>
{
DoWork(i);
Expand All @@ -93,7 +97,10 @@

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++)
Expand Down
13 changes: 8 additions & 5 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
Expand All @@ -397,7 +400,7 @@ static void RunBenchmark()
["3"] = () => BenchmarkRunner.Run<CPUBenchmark>(),
["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
};

Expand Down
82 changes: 40 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <a href="https://github.com/dotnet/BenchmarkDotNet"> `BenchmarkDotNet` </a>, `SharpDX`, `NvAPIWrapper` and `Hardware.info`

# Maintenance
Expand Down Expand Up @@ -46,6 +46,13 @@

- .NET 8.0.2 from <a href="https://dotnet.microsoft.com/download/dotnet/8.0"> `here` </a>

# 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

<table>
Expand All @@ -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`
Expand Down
Loading