Skip to content

Commit

Permalink
Merge pull request #69 from OudomMunint/feature
Browse files Browse the repository at this point in the history
Feature => Master
  • Loading branch information
OudomMunint authored Jan 14, 2025
2 parents 79900e0 + ab38d0f commit 0541f0b
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 16 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
tag: v1.4.9.8
tag: v1.4.10
4 changes: 2 additions & 2 deletions Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -15,4 +15,4 @@
<PackageReference Include="SharpDX.Direct3D11" Version="4.2.0" />
</ItemGroup>

</Project>
</Project>
81 changes: 81 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static void Main(string[] args)
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
DisplayMacInfo();
//DisplayMacInfoByPowermetrics();
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 <a href="https://dotnet.microsoft.com/download/dotnet/8.0"> `here` </a>
- Install `.NET 9 SDK` from <a href="https://dotnet.microsoft.com/download/dotnet/9.0"> `here` </a>
- `.Net 9.0.0 Runtime` from <a href="https://dotnet.microsoft.com/download/dotnet/9.0"> `here` </a>
- Open the solution and set as startup project
- Run the benchmark in `Release` mode.
- Check your if system specs is correct
Expand All @@ -28,7 +29,8 @@
- If not you can use the provided JSON files.

# Running on OSX
- Install `.NET 8 SDK` for macOS from <a href="https://dotnet.microsoft.com/download/dotnet/8.0"> `here` </a>
- Install `.NET 9 SDK` for macOS from <a href="https://dotnet.microsoft.com/download/dotnet/9.0"> `here` </a>
- `.Net 9.0.0 Runtime` from <a href="https://dotnet.microsoft.com/download/dotnet/9.0"> `here` </a>
- 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.
Expand All @@ -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\<Path to project>\Benchmark\bin\Release\net8.0\publish\` folder.
- Run `Benchmark.exe` in the `C:\Users\<Path to project>\Benchmark\bin\Release\net9.0\publish\` folder.

# Required SDKs
# Required SDKs & Runtimes

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

# Debugging
- Set a breakpoint anywhere.
Expand All @@ -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

<table>
Expand All @@ -62,14 +71,14 @@
</tr>
<tr>
<td> <img src="results.png"/> </td>
<td> <img src="macos.png" width="700"/> </td>
<td> <img src="macosoutput.png" width="700"/> </td>
</tr>
</table>

- 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.

Expand Down Expand Up @@ -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
Expand Down
Binary file removed macos.png
Binary file not shown.
Binary file added macosoutput.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0541f0b

Please sign in to comment.