|
| 1 | +namespace GraphBLAS.FSharp.Benchmarks |
| 2 | + |
| 3 | +open GraphBLAS.FSharp.Algorithms |
| 4 | +open BenchmarkDotNet.Attributes |
| 5 | +open BenchmarkDotNet.Configs |
| 6 | +open BenchmarkDotNet.Columns |
| 7 | +open BenchmarkDotNet.Reports |
| 8 | +open BenchmarkDotNet.Running |
| 9 | +open System.IO |
| 10 | + |
| 11 | +type TEPSColumn() = |
| 12 | + interface IColumn with |
| 13 | + member this.AlwaysShow: bool = true |
| 14 | + member this.Category: ColumnCategory = ColumnCategory.Statistics |
| 15 | + member this.ColumnName: string = "TEPS" |
| 16 | + member this.GetValue(summary: Summary, benchmarkCase: BenchmarkCase): string = |
| 17 | + let meanTime = summary.[benchmarkCase].ResultStatistics.Mean |
| 18 | + let pathToGraph = benchmarkCase.Parameters.["PathToGraph"].ToString() |
| 19 | + match Path.GetExtension pathToGraph with |
| 20 | + | ".mtx" -> |
| 21 | + use streamReader = new StreamReader(pathToGraph) |
| 22 | + while streamReader.Peek() = int '%' do |
| 23 | + streamReader.ReadLine() |> ignore |
| 24 | + let matrixInfo = streamReader.ReadLine().Split(' ') |
| 25 | + let (nrows, ncols, nnz) = float matrixInfo.[0], float matrixInfo.[1], float matrixInfo.[2] |
| 26 | + let (vertices, edges) = if nrows = ncols then (nrows, nnz) else (ncols, nrows) |
| 27 | + sprintf "%f" (edges / meanTime) |
| 28 | + | another -> sprintf "%s files not supported" another |
| 29 | + member this.GetValue(summary: Summary, benchmarkCase: BenchmarkCase, style: SummaryStyle): string = |
| 30 | + (this :> IColumn).GetValue(summary, benchmarkCase) |
| 31 | + member this.Id: string = "TEPSColumn" |
| 32 | + member this.IsAvailable(summary: Summary): bool = true |
| 33 | + member this.IsDefault(summary: Summary, benchmarkCase: BenchmarkCase): bool = false |
| 34 | + member this.IsNumeric: bool = true |
| 35 | + member this.Legend: string = "Traversed edges per second" |
| 36 | + member this.PriorityInCategory: int = 0 |
| 37 | + member this.UnitType: UnitType = UnitType.Dimensionless |
| 38 | + |
| 39 | +type Config() = |
| 40 | + inherit ManualConfig() |
| 41 | + |
| 42 | + do |
| 43 | + base.AddColumn [| TEPSColumn() :> IColumn |] |> ignore |
0 commit comments