-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
253 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md |
82 changes: 0 additions & 82 deletions
82
CPU-Benchmark-Database-Aggregator/Aggregators/ByCPUAggregator.cs
This file was deleted.
Oops, something went wrong.
108 changes: 108 additions & 0 deletions
108
CPU-Benchmark-Database-Aggregator/Aggregators/ByScoreAggregator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#region using | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using CPU_Benchmark_Database_Aggregator.Models; | ||
using CPU_Benchmark_Server_Aggregator.Models; | ||
|
||
#endregion | ||
|
||
namespace CPU_Benchmark_Database_Aggregator.Aggregators | ||
{ | ||
internal class ByScoreAggregator : IAggregator | ||
{ | ||
private readonly Dictionary<string, List<Save>> byBenchmarkResults = new Dictionary<string, List<Save>>(); | ||
private readonly Dictionary<uint, List<Save>> byCoreResults = new Dictionary<uint, List<Save>>(); | ||
|
||
public void ProcessSave(Save save) | ||
{ | ||
foreach (var result in save.Results) | ||
{ | ||
if (!byCoreResults.ContainsKey(result.Key)) | ||
{ | ||
byCoreResults.Add(result.Key, new List<Save> {save}); | ||
} | ||
else | ||
{ | ||
var inserted = false; | ||
|
||
for (var i = 0; i < byCoreResults[result.Key].Count; i++) | ||
{ | ||
var currentSave = byCoreResults[result.Key][i]; | ||
var eligibleResults = currentSave.Results[result.Key] | ||
.Where(r => !r.Benchmark.StartsWith("Category:")).ToList(); | ||
var score = eligibleResults.Sum(r => r.Points) / eligibleResults.Count; | ||
|
||
var newEligibleResults = save.Results[result.Key] | ||
.Where(r => !r.Benchmark.StartsWith("Category:")) | ||
.ToList(); | ||
var newScore = newEligibleResults.Sum(r => r.Points) / newEligibleResults.Count; | ||
|
||
if (newScore > score) | ||
{ | ||
byCoreResults[result.Key].Insert(i, save); | ||
inserted = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!inserted && byCoreResults[result.Key].Count < 100) | ||
{ | ||
byCoreResults[result.Key].Add(save); | ||
} | ||
} | ||
|
||
foreach (var res in result.Value) | ||
{ | ||
var key = $"{res.Benchmark} @ {result.Key} Threads"; | ||
|
||
if (!byBenchmarkResults.ContainsKey(key)) | ||
{ | ||
byBenchmarkResults.Add(key, new List<Save> {save}); | ||
} | ||
else | ||
{ | ||
var inserted = false; | ||
|
||
for (var i = 0; i < byBenchmarkResults[key].Count; i++) | ||
{ | ||
var currentScore = byBenchmarkResults[key][i].Results[result.Key] | ||
.First(r => r.Benchmark == res.Benchmark); | ||
|
||
if (res.Points > currentScore.Points) | ||
{ | ||
byBenchmarkResults[key].Insert(i, save); | ||
inserted = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!inserted && byBenchmarkResults[key].Count < 100) | ||
{ | ||
byBenchmarkResults[key].Add(save); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
public IEnumerable<Aggregate> GetAggregatedResults() | ||
{ | ||
var list = new List<Aggregate>(); | ||
|
||
foreach (var byCoreResult in byCoreResults) | ||
{ | ||
list.Add(new Aggregate($"Threads {byCoreResult.Key}", "byCores", | ||
byCoreResult.Value.GetRange(0, 100).Select(s => s.UUID))); | ||
} | ||
|
||
foreach (var byBenchmarkResult in byBenchmarkResults) | ||
{ | ||
list.Add(new Aggregate(byBenchmarkResult.Key, "byBenchmarks", | ||
byBenchmarkResult.Value.GetRange(0, 100).Select(s => s.UUID))); | ||
} | ||
|
||
return list; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM mcr.microsoft.com/dotnet/core/runtime:3.0-buster-slim AS base | ||
WORKDIR /app | ||
|
||
FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build | ||
WORKDIR /src | ||
COPY ["CPU-Benchmark-Database-Aggregator/CPU-Benchmark-Database-Aggregator.csproj", "CPU-Benchmark-Database-Aggregator/"] | ||
RUN dotnet restore "CPU-Benchmark-Database-Aggregator/CPU-Benchmark-Database-Aggregator.csproj" | ||
COPY . . | ||
WORKDIR "/src/CPU-Benchmark-Database-Aggregator" | ||
RUN dotnet build "CPU-Benchmark-Database-Aggregator.csproj" -c Release -o /app/build | ||
|
||
FROM build AS publish | ||
RUN dotnet publish "CPU-Benchmark-Database-Aggregator.csproj" -c Release -o /app/publish | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["dotnet", "CPU-Benchmark-Database-Aggregator.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
using CPU_Benchmark_Server_Aggregator.Models; | ||
using HardwareInformation; | ||
using System; | ||
#region using | ||
|
||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
#endregion | ||
|
||
namespace CPU_Benchmark_Database_Aggregator.Models | ||
{ | ||
class Aggregate | ||
{ | ||
public List<Result> ResultsST = new List<Result>(); | ||
public List<Result> ResultsMT = new List<Result>(); | ||
public MachineInformation MachineInformation = new MachineInformation(); | ||
} | ||
} | ||
internal class Aggregate | ||
{ | ||
public Aggregate(string name, string category, IEnumerable<string> resultSaveUUIDs) | ||
{ | ||
Name = name; | ||
Category = category; | ||
ResultSaveUUIDs = resultSaveUUIDs; | ||
} | ||
|
||
public string Name { get; set; } | ||
|
||
public string Category { get; set; } | ||
|
||
public IEnumerable<string> ResultSaveUUIDs { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,78 @@ | ||
using System; | ||
#region using | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using CPU_Benchmark_Database_Aggregator.Aggregators; | ||
using CPU_Benchmark_Database_Aggregator.Models; | ||
using CPU_Benchmark_Server_Aggregator.Models; | ||
using Newtonsoft.Json; | ||
|
||
#endregion | ||
|
||
namespace CPU_Benchmark_Database_Aggregator | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var saves = Directory.GetFiles(Environment.GetEnvironmentVariable("GITHUB_WORKSPACE") + "/saves"); | ||
} | ||
} | ||
} | ||
internal class Program | ||
{ | ||
private static readonly IEnumerable<IAggregator> aggregators = new[] | ||
{ | ||
new ByScoreAggregator() | ||
}; | ||
|
||
private static void Main(string[] args) | ||
{ | ||
var baseDirectory = Environment.GetEnvironmentVariable("GITHUB_WORKSPACE") + "/saves"; | ||
var saves = Directory.GetFiles(baseDirectory, "*.json"); | ||
var aggregates = new List<Aggregate>(); | ||
|
||
foreach (var saveFile in saves) | ||
{ | ||
try | ||
{ | ||
var save = JsonConvert.DeserializeObject<Save>(saveFile); | ||
|
||
foreach (var aggregator in aggregators) | ||
{ | ||
aggregator.ProcessSave(save); | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e); | ||
} | ||
} | ||
|
||
foreach (var aggregator in aggregators) | ||
{ | ||
aggregates.AddRange(aggregator.GetAggregatedResults()); | ||
} | ||
|
||
foreach (var aggregate in aggregates) | ||
{ | ||
var dir = $"{baseDirectory}/{aggregate.Category}"; | ||
|
||
if (!Directory.Exists(dir)) | ||
{ | ||
Directory.CreateDirectory(dir); | ||
} | ||
|
||
var validName = new StringBuilder(aggregate.Name); | ||
|
||
foreach (var c in Path.GetInvalidFileNameChars()) | ||
{ | ||
validName = validName.Replace(c, '_'); | ||
} | ||
|
||
var file = $"{dir}/{validName}"; | ||
|
||
if (File.Exists(file)) | ||
{ | ||
File.Delete(file); | ||
} | ||
|
||
File.WriteAllText(file, JsonConvert.SerializeObject(aggregate)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# action.yml | ||
name: 'CPU-Benchmark-Database-Aggregator' | ||
description: 'Aggregator for the CPU Benchmark Database' | ||
runs: | ||
using: 'docker' | ||
image: 'CPU-Benchmark-Database-Aggregator/Dockerfile' |