-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMFloatPersecColumn.cs
100 lines (56 loc) · 2.85 KB
/
MFloatPersecColumn.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Reports;
using System.IO;
using System.Linq;
namespace csFastFloat.Benchmark
{
public class MFloatPerSecColumn : IColumn
{
public string Id => nameof(MFloatPerSecColumn);
public string ColumnName => "MFloat/s";
public string Legend => "Million of floats parsed per second";
public UnitType UnitType => UnitType.Size;
public bool AlwaysShow => true;
public ColumnCategory Category => ColumnCategory.Metric;
public int PriorityInCategory => 1;
public bool IsNumeric => true;
public bool IsAvailable(Summary summary) => true;
public bool IsDefault(Summary summary, BenchmarkCase benchmarkCase) => false;
public string GetValue(Summary summary, BenchmarkCase benchmarkCase) => GetValue(summary, benchmarkCase, SummaryStyle.Default);
public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style)
{
var disp_info = benchmarkCase.DisplayInfo;
var fileName = benchmarkCase.Parameters.Items.FirstOrDefault(x => x.Name == "FileName").ToString();
var nbFloat = System.IO.File.ReadAllLines(fileName).Count();
var s= summary.Reports.Where(x => x.BenchmarkCase.DisplayInfo == disp_info).FirstOrDefault();
double fps = nbFloat * 1000 / s.ResultStatistics.Min;
return string.Format("{0,8:f2}",fps);
}
public override string ToString() => ColumnName;
}
public class VolumePerSecColumn : IColumn
{
public string Id => nameof(VolumePerSecColumn);
public string ColumnName => "MB/s";
public string Legend => "Volume of data parsed per second (in MB)";
public UnitType UnitType => UnitType.Size;
public bool AlwaysShow => true;
public ColumnCategory Category => ColumnCategory.Metric;
public int PriorityInCategory => 2;
public bool IsNumeric => true;
public bool IsAvailable(Summary summary) => true;
public bool IsDefault(Summary summary, BenchmarkCase benchmarkCase) => false;
public string GetValue(Summary summary, BenchmarkCase benchmarkCase) => GetValue(summary, benchmarkCase, SummaryStyle.Default);
public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style)
{
var disp_info = benchmarkCase.DisplayInfo;
var fileName = benchmarkCase.Parameters.Items.FirstOrDefault(x => x.Name == "FileName").ToString();
var volume = new FileInfo(fileName).Length/1024;
var s= summary.Reports.Where(x => x.BenchmarkCase.DisplayInfo == disp_info).FirstOrDefault();
double vps = volume * 1000000 / s.ResultStatistics.Min;
return string.Format("{0,8:f2}",vps);
}
public override string ToString() => ColumnName;
}
}