Skip to content
Open
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
46 changes: 46 additions & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: PR Build
on:
pull_request:
branches: "**"

jobs:
build:
strategy:
matrix:
dotnet: ['8.x']
name: "Test on .NET ${{ matrix.dotnet }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Setup .NET ${{ matrix.dotnet }}"
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Restore dependencies
run: dotnet restore
- name: "Build on ${{ matrix.dotnet }}"
run: dotnet build --no-restore ./DemLock.Tests/DemLock.Tests.csproj
- name: "Test on ${{ matrix.dotnet }}"
run: dotnet test --no-build --verbosity normal

benchmark:
strategy:
matrix:
dotnet: ['8.x']
name: "Benchmark on ${{ matrix.dotnet }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Setup .NET ${{ matrix.dotnet }}"
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Restore dependencies
run: dotnet restore
- name: "Build on ${{ matrix.dotnet }}"
run: dotnet build --no-restore -c Release ./DemLock.Benchmarks/DemLock.Benchmarks.csproj
# We need sudo so BenchmarkDotNet can set itself as high priority on the CPU.
# We're still running without any Github credentials/can only do stuff within
# the branch, so we should be good security wise.
- name: "Benchmark on ${{ matrix.dotnet }}"
run: sudo dotnet run -c Release --project ./DemLock.Benchmarks/DemLock.Benchmarks.csproj
46 changes: 46 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Push
on:
push:
branches: "main"

jobs:
build:
strategy:
matrix:
dotnet: ['8.x']
name: "Test on .NET ${{ matrix.dotnet }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Setup .NET ${{ matrix.dotnet }}"
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Restore dependencies
run: dotnet restore
- name: "Build on ${{ matrix.dotnet }}"
run: dotnet build --no-restore ./DemLock.Tests/DemLock.Tests.csproj
- name: "Test on ${{ matrix.dotnet }}"
run: dotnet test --no-build --verbosity normal

benchmark:
strategy:
matrix:
dotnet: ['8.x']
name: "Benchmark on ${{ matrix.dotnet }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Setup .NET ${{ matrix.dotnet }}"
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Restore dependencies
run: dotnet restore
- name: "Build on ${{ matrix.dotnet }}"
run: dotnet build --no-restore -c Release ./DemLock.Benchmarks/DemLock.Benchmarks.csproj
# We need sudo so BenchmarkDotNet can set itself as high priority on the CPU.
# We're still running without any Github credentials/can only do stuff within
# the branch, so we should be good security wise.
- name: "Benchmark on ${{ matrix.dotnet }}"
run: sudo dotnet run -c Release --project ./DemLock.Benchmarks/DemLock.Benchmarks.csproj
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ obj/
riderModule.iml
/_ReSharper.Caches/
.idea
DemLock.sln.DotSettings.user
DemLock.sln.DotSettings.user
BenchmarkDotNet.Artifacts/
41 changes: 41 additions & 0 deletions DemLock.Benchmarks/BenchmarkTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using DemLock.Parser;

namespace DemLock.Tests;

public class BenchmarkTests
{
private readonly DemoParserConfig config;
private readonly DemoParser parser;
private readonly string demosPath;

public BenchmarkTests()
{
config = new DemoParserConfig
{
LogMessageReads = false,
LogReadFrames = false
};
parser = new DemoParser(config);
demosPath = Path.Combine(Directory.GetCurrentDirectory(), @"TestData");
}

[Benchmark]
public void FullMatch()
{
// Arrange
parser.Events.OnEntityUpdated += static (sender, eventArgs) => {};

// Act
parser.ProcessDemo(Path.Combine(demosPath, "benchmark_20240825_361e4b053.dem"));
}
}

public class Program
{
public static void Main()
{
_ = BenchmarkRunner.Run<BenchmarkTests>();
}
}
22 changes: 22 additions & 0 deletions DemLock.Benchmarks/DemLock.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
<Content Include="TestData\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DemLock.Parser\DemLock.Parser.csproj" />
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions DemLock.Benchmarks/TestData/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# DemLock benchmarks

This folder contains benchmark demos for the parser, sourced from
tournaments whose files are available publically. The files are named according to the format
`benchmark_<YYYYMMDD>_<commit>.dem`, where `YYYYMMDD` is the day the match
was played and `commit` is the [SteamDatabase/Protobufs](https://github.com/SteamDatabase/Protobufs) commit
of the version of protobuf being used.
Binary file not shown.
6 changes: 6 additions & 0 deletions DemLock.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemLock.Entities", "DemLock
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemLock.ClassMappingGenerator", "DemLock.ClassMappingGenerator\DemLock.ClassMappingGenerator\DemLock.ClassMappingGenerator.csproj", "{2BCD54C5-6D09-4ADF-BEF7-FF67FFF0F1D8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemLock.Benchmarks", "DemLock.Benchmarks\DemLock.Benchmarks.csproj", "{FF3B0F1B-3BE0-40B8-B508-5198AF2209BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -42,5 +44,9 @@ Global
{2BCD54C5-6D09-4ADF-BEF7-FF67FFF0F1D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BCD54C5-6D09-4ADF-BEF7-FF67FFF0F1D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2BCD54C5-6D09-4ADF-BEF7-FF67FFF0F1D8}.Release|Any CPU.Build.0 = Release|Any CPU
{FF3B0F1B-3BE0-40B8-B508-5198AF2209BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF3B0F1B-3BE0-40B8-B508-5198AF2209BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF3B0F1B-3BE0-40B8-B508-5198AF2209BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF3B0F1B-3BE0-40B8-B508-5198AF2209BC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal