This repository was archived by the owner on Jul 22, 2023. It is now read-only.
forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaselineComparisonConfig.cs
More file actions
52 lines (45 loc) · 1.91 KB
/
BaselineComparisonConfig.cs
File metadata and controls
52 lines (45 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Horology;
namespace Python.PerformanceTests
{
public class BaselineComparisonConfig : ManualConfig
{
public const string EnvironmentVariableName = "PythonRuntimeDLL";
public BaselineComparisonConfig()
{
this.Options |= ConfigOptions.DisableOptimizationsValidator;
string deploymentRoot = BenchmarkTests.DeploymentRoot;
var baseJob = Job.Default
.WithLaunchCount(1)
.WithWarmupCount(3)
.WithMaxIterationCount(100)
.WithIterationTime(TimeInterval.FromMilliseconds(100));
this.Add(baseJob
.WithId("baseline")
.WithEnvironmentVariable(EnvironmentVariableName,
Path.Combine(deploymentRoot, "baseline", "Python.Runtime.dll"))
.WithBaseline(true));
this.Add(baseJob
.WithId("new")
.WithEnvironmentVariable(EnvironmentVariableName,
Path.Combine(deploymentRoot, "new", "Python.Runtime.dll")));
}
static BaselineComparisonConfig() {
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;
}
static Assembly CurrentDomainOnAssemblyResolve(object sender, ResolveEventArgs args) {
Console.WriteLine(args.Name);
if (!args.Name.StartsWith("Python.Runtime"))
return null;
string pythonRuntimeDll = Environment.GetEnvironmentVariable(EnvironmentVariableName);
if (string.IsNullOrEmpty(pythonRuntimeDll))
pythonRuntimeDll = Path.Combine(BenchmarkTests.DeploymentRoot, "baseline", "Python.Runtime.dll");
return Assembly.LoadFrom(pythonRuntimeDll);
}
}
}