diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3279476..ae12dd3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,25 +21,25 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest, ubuntu-latest, macos-latest] + os: [windows-latest, ubuntu-latest, macos-15] steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup .NET Core V8 + - name: Setup .NET Core SDK / .NET 9 uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.x' + dotnet-version: '9.x' - name: Restore dependencies run: dotnet restore Benchmark.csproj - name: Build sln - run: dotnet build Benchmark.sln -c Release -f net8.0 + run: dotnet build Benchmark.sln -c Release -f net9.0 - name: Create Release if: matrix.os == 'windows-latest' uses: ncipollo/release-action@v1.14.0 with: - tag: v1.4.9.8 \ No newline at end of file + tag: v1.4.10 \ No newline at end of file diff --git a/Benchmark.csproj b/Benchmark.csproj index e7d9f3a..14f6ccc 100644 --- a/Benchmark.csproj +++ b/Benchmark.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 enable enable @@ -15,4 +15,4 @@ - + \ No newline at end of file diff --git a/Program.cs b/Program.cs index 5c684cc..119a32a 100644 --- a/Program.cs +++ b/Program.cs @@ -27,6 +27,7 @@ static void Main(string[] args) if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { DisplayMacInfo(); + //DisplayMacInfoByPowermetrics(); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { @@ -50,6 +51,62 @@ static void Main(string[] args) } } + static void PasswordPrompt() + { + Console.ForegroundColor = ConsoleColor.Cyan; + + Console.Write("Enter your password for sudo access: "); + string? password = ReadPassword(); + + var startInfo = new ProcessStartInfo + { + FileName = "/usr/bin/sudo" + }; + + var process = new Process { StartInfo = startInfo }; + process.Start(); + + using (var writer = process.StandardInput) + { + writer.WriteLine(password); + } + + while (!process.StandardOutput.EndOfStream) + { + string? line = process.StandardOutput.ReadLine(); + if (line != null) + { + Console.WriteLine(line); + } + } + + string? error = process.StandardError.ReadToEnd(); + if (!string.IsNullOrEmpty(error)) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($"Error: {error}"); + } + } + + // Read pw w/o echoing to console + static string ReadPassword() + { + string password = string.Empty; + ConsoleKeyInfo keyInfo; + + do + { + keyInfo = Console.ReadKey(intercept: true); + if (keyInfo.Key != ConsoleKey.Enter) + { + password += keyInfo.KeyChar; + } + } while (keyInfo.Key != ConsoleKey.Enter); + + Console.WriteLine(); + return password; + } + static void DisplayMacInfo() { Console.ForegroundColor = ConsoleColor.Cyan; @@ -82,6 +139,30 @@ static void DisplayMacInfo() } } + static void DisplayMacInfoByPowermetrics() + { + Console.ForegroundColor = ConsoleColor.Cyan; + var startInfo = new ProcessStartInfo + { + FileName = "/usr/bin/powermetrics", + Arguments = "sudo powermetrics --samplers cpu_power,gpu_power -n 1s", + RedirectStandardOutput = true, + UseShellExecute = false + }; + + var process = new Process { StartInfo = startInfo }; + process.Start(); + + while (!process.StandardOutput.EndOfStream) + { + string? line = process.StandardOutput.ReadLine(); + if (line != null) + { + Console.WriteLine(line); + } + } + } + static void DisplayWindowsInfo() { ConsoleSpinner.Start(); diff --git a/README.md b/README.md index dae6f63..4854e11 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Benchmark (.NET 8) +# Benchmark (.NET 9) - 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. @@ -16,7 +16,8 @@ [![CI Build](https://github.com/OudomMunint/Benchmark/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/OudomMunint/Benchmark/actions/workflows/main.yml) [![CodeQL](https://github.com/OudomMunint/Benchmark/actions/workflows/codeql.yml/badge.svg)](https://github.com/OudomMunint/Benchmark/actions/workflows/codeql.yml) # Getting Started -- Install `.NET 8 SDK` from `here` +- Install `.NET 9 SDK` from `here` +- `.Net 9.0.0 Runtime` from `here` - Open the solution and set as startup project - Run the benchmark in `Release` mode. - Check your if system specs is correct @@ -28,7 +29,8 @@ - If not you can use the provided JSON files. # Running on OSX -- Install `.NET 8 SDK` for macOS from `here` +- Install `.NET 9 SDK` for macOS from `here` +- `.Net 9.0.0 Runtime` from `here` - Open the solution and set as startup project. - Run the benchmark in `Release` mode. - If the app is terminated, open Benchmark.sln or csproj in terminal. @@ -40,11 +42,12 @@ - Set the startup project to `Benchmark` - Build with `dotnet build -c Release` - Publish with `dotnet publish -c Release` -- Run `Benchmark.exe` in the `C:\Users\\Benchmark\bin\Release\net8.0\publish\` folder. +- Run `Benchmark.exe` in the `C:\Users\\Benchmark\bin\Release\net9.0\publish\` folder. -# Required SDKs +# Required SDKs & Runtimes -- .NET 8.0.2 from `here` +- `.NET 9.0.x` from `here` +- `.Net 9.0.0 Runtime` from `here` # Debugging - Set a breakpoint anywhere. @@ -53,6 +56,12 @@ - Select the benchmark you want to debug. - The program will pause at the breakpoint. +# Use older versions of .NET +- Install the required SDKs and Runtimes. +- Change the target framework in the `Benchmark.csproj` file. +- Change `net9.0` to `net7.0` or `net8.0`. +- Run in `Release` mode. + # Output @@ -62,14 +71,14 @@ - +
- Scroll down to see results. - `Runtime` in `seconds(s)` should be the benchmark. - `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`. +- There might be up to a 20 seconds delay on first use due to hardware detection by `Hardware.Info`. # Specs for tested systems. @@ -155,9 +164,12 @@ Intel Core i7-12800H CPU 1.80GHz (Alder Lake), 14 Cores 20 Threads (6P/8E) 6. MacBook Pro 15" 2018 - i7-8850H @ 45W `133s` 7. MacBook Pro 13" 2017 - i5-7660U @ 15W `401s` +## .NET 9 Ranking: +Testing in progress... + # Minimum system requirements -- .NET 8.0.2 +- .NET 9.0.x - Dual core CPU - Windows 10 or MacOS 12 - 4GB RAM diff --git a/macos.png b/macos.png deleted file mode 100644 index 60fd4b2..0000000 Binary files a/macos.png and /dev/null differ diff --git a/macosoutput.png b/macosoutput.png new file mode 100644 index 0000000..5d0ee63 Binary files /dev/null and b/macosoutput.png differ