-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathBenchmarksBase.cs
42 lines (38 loc) · 1.33 KB
/
BenchmarksBase.cs
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
namespace Benchmarks
{
[Config(typeof(ConfigWithCustomEnvVars))]
public class BenchmarksBase
{
private class ConfigWithCustomEnvVars : ManualConfig
{
private const string JitTieredCompilation = "COMPlus_TieredCompilation";
public ConfigWithCustomEnvVars()
{
Add(Job.ShortRun.With(new[] { new EnvironmentVariable(JitTieredCompilation, "1") }));
Add(Job.ShortRun.With(new[] { new EnvironmentVariable(JitTieredCompilation, "0") }));
}
}
public IEnumerable<object[]> TestData()
{
string jsonExamples = Environment.GetEnvironmentVariable("pathToJsonExamples");
string[] files = Directory.GetFiles(jsonExamples, "*.json", SearchOption.AllDirectories).ToArray();
foreach (var file in files)
{
byte[] bytes = File.ReadAllBytes(file);
yield return new object[]
{
bytes,
Path.GetFileName(file),
Math.Round(bytes.Length / 1000.0, 2).ToString("N") + " Kb"
};
}
}
}
}