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 #26

Merged
merged 5 commits into from
Feb 21, 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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
if: matrix.os == 'windows-latest'
uses: ncipollo/release-action@v1.14.0
with:
tag: v1.4.7
tag: v1.4.7.1
4 changes: 3 additions & 1 deletion Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -9,6 +9,8 @@

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="SharpDX" Version="4.2.0" />
<PackageReference Include="SharpDX.Direct3D11" Version="4.2.0" />
</ItemGroup>

</Project>
20 changes: 17 additions & 3 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
using System.Management;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using SharpDX.Direct3D11;
using SharpDX.DXGI;
using SharpDX.Direct3D;
using System;
using Device = SharpDX.Direct3D11.Device;

Console.WriteLine("Welcome to the best benchmark in the entire universe");
Console.WriteLine("-----------------------------------------------------------");
Expand All @@ -23,7 +29,7 @@

while (!process.StandardOutput.EndOfStream)
{
string line = process.StandardOutput.ReadLine();

Check warning on line 32 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

Converting null literal or possible null value to non-nullable type.

Check warning on line 32 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

Converting null literal or possible null value to non-nullable type.

Check warning on line 32 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

Converting null literal or possible null value to non-nullable type.
Console.WriteLine(line);
}

Expand All @@ -35,17 +41,17 @@
{
// GET CPU info
// Windows specific
using (var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor"))

Check warning on line 44 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

This call site is reachable on all platforms. 'ManagementObjectSearcher' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
{
foreach (var item in searcher.Get())
{
Console.WriteLine("[CPU information]");
Console.WriteLine("Processor Name: {0}", item["Name"]);

Check warning on line 49 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

This call site is reachable on all platforms. 'ManagementBaseObject.this[string]' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 49 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

This call site is reachable on all platforms. 'ManagementBaseObject.this[string]' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
Console.WriteLine("Manufacturer: {0}", item["Manufacturer"]);
Console.WriteLine("Core: {0}", item["NumberOfCores"]);
Console.WriteLine("Threads: {0}", item["NumberOfLogicalProcessors"]);

Check warning on line 52 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

This call site is reachable on all platforms. 'ManagementBaseObject.this[string]' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
Console.WriteLine("Clock Speed: {0}MHz", item["MaxClockSpeed"]);
Console.WriteLine("L3 Cache: {0}MB", (Convert.ToInt64(item["L3CacheSize"]) / 1024));

Check warning on line 54 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

This call site is reachable on all platforms. 'ManagementBaseObject.this[string]' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
Console.WriteLine("Voltage: {0}V", item["CurrentVoltage"]);
Console.WriteLine("-----------------------------------------------------------");
}
Expand All @@ -57,11 +63,11 @@
{
// GET total MEM
long totalCapacity = 0;
string manufacturer = null;

Check warning on line 66 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

Converting null literal or possible null value to non-nullable type.

Check warning on line 66 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

Converting null literal or possible null value to non-nullable type.

Check warning on line 66 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

Converting null literal or possible null value to non-nullable type.
foreach (ManagementObject item in searcher.Get())

Check warning on line 67 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

This call site is reachable on all platforms. 'ManagementObjectSearcher.Get()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
{
totalCapacity += Convert.ToInt64(item["Capacity"]);
manufacturer = item["Manufacturer"].ToString().Trim();

Check warning on line 70 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

Dereference of a possibly null reference.

Check warning on line 70 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 70 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

Dereference of a possibly null reference.
}

Console.WriteLine("[Memory Information]");
Expand All @@ -69,7 +75,7 @@
Console.WriteLine("Manufacturer: {0}", manufacturer);

// GET Capacity per stick
searcher.Query = new ObjectQuery("SELECT * FROM Win32_PhysicalMemory");

Check warning on line 78 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

This call site is reachable on all platforms. 'ManagementObjectSearcher.Query' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
int slotNumber = 1;
foreach (ManagementObject item in searcher.Get())
{
Expand All @@ -90,31 +96,39 @@
{
var manufacturer = item["AdapterCompatibility"].ToString();
var VideoMemoryType = item["VideoMemoryType"].ToString();
if (manufacturer.ToLower().Contains("intel") || manufacturer.ToLower().Contains("amd"))

Check warning on line 99 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

Dereference of a possibly null reference.

Check warning on line 99 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 99 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

Dereference of a possibly null reference.
{
Console.WriteLine("[Integrated GPU]");
Console.WriteLine("Name: {0}", item["Name"]);

Check warning on line 102 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

This call site is reachable on all platforms. 'ManagementBaseObject.this[string]' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 102 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

This call site is reachable on all platforms. 'ManagementBaseObject.this[string]' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
Console.WriteLine("Manufacturer: {0}", manufacturer);
Console.WriteLine("Driver Version: {0}", item["DriverVersion"]);
Console.WriteLine("VRAM: {0}MB", Convert.ToUInt64(item["AdapterRAM"]) / (1024 * 1024));

Check warning on line 105 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

This call site is reachable on all platforms. 'ManagementBaseObject.this[string]' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
Console.WriteLine("-----------------------------------------------------------");
}
else
{
Console.WriteLine("[Dedicated GPU]");
Console.WriteLine("Name: {0}", item["Name"]);

Check warning on line 111 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

This call site is reachable on all platforms. 'ManagementBaseObject.this[string]' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
Console.WriteLine("Manufacturer: {0}", manufacturer);
Console.WriteLine("Driver Version: {0}", item["DriverVersion"]);

Check warning on line 113 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

This call site is reachable on all platforms. 'ManagementBaseObject.this[string]' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
Console.WriteLine("VRAM: {0}MB", Convert.ToUInt64(item["AdapterRAM"]) / (1024 * 1024));
}
}
}

using (var factory = new Factory1())
{
using (var adapter = factory.GetAdapter(0))
{
var desc = adapter.Description;
Console.WriteLine("Total VRAM: {0}MB", desc.DedicatedVideoMemory / (1024 * 1024));
Console.WriteLine("-----------------------------------------------------------");
}
}
}
}

Console.Write("Continue to benchmark? (y/n): ");
var input = Console.ReadLine();
if (input.ToLower() == "y")
if (string.Equals("y", "Y"))
{

Console.WriteLine("Choose a benchmark to run:");
Expand All @@ -124,7 +138,7 @@
Console.WriteLine("4. Run all benchmarks");
Console.Write("Enter the number of your choice: ");

string choice = Console.ReadLine();

Check warning on line 141 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

Converting null literal or possible null value to non-nullable type.

Check warning on line 141 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

Converting null literal or possible null value to non-nullable type.

Check warning on line 141 in Program.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

Converting null literal or possible null value to non-nullable type.

switch (choice)
{
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
- For `VSCode` you also need to create `launch.JSON` and `task.JSON` files if you want to run in different configurations.
- If not you can use the provided JSON files.

# Running the EXE
- Open the solution with preferred IDE
- 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.

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

# Output
<table>
<tr>
Expand Down
Loading