11namespace GraphBLAS.FSharp.Benchmarks
22
3- open GraphBLAS.FSharp .Algorithms
4- open BenchmarkDotNet.Attributes
53open BenchmarkDotNet.Configs
64open BenchmarkDotNet.Columns
75open BenchmarkDotNet.Reports
86open BenchmarkDotNet.Running
97open BenchmarkDotNet.Filters
10- open System.IO
8+ open GraphBLAS.FSharp
9+
10+ type InputMatrixFormat = {
11+ MatrixName: string
12+ MatrixStructure: COOFormat < float >
13+ }
14+ with
15+ override this.ToString () =
16+ sprintf " %s " this.MatrixName
17+
18+ type MatrixShapeColumn ( columnName : string , getShape : InputMatrixFormat -> int ) =
19+ interface IColumn with
20+ member this.AlwaysShow : bool = true
21+ member this.Category : ColumnCategory = ColumnCategory.Params
22+ member this.ColumnName : string = columnName
23+ member this.GetValue ( summary : Summary , benchmarkCase : BenchmarkCase ): string =
24+ let inputMatrix = benchmarkCase.Parameters.[ " InputMatrix" ] :?> InputMatrixFormat
25+ sprintf " %i " <| getShape inputMatrix
26+ member this.GetValue ( summary : Summary , benchmarkCase : BenchmarkCase , style : SummaryStyle ): string =
27+ ( this :> IColumn) .GetValue( summary, benchmarkCase)
28+ member this.Id : string = sprintf " %s .%s " " MatrixShapeColumn" columnName
29+ member this.IsAvailable ( summary : Summary ): bool = true
30+ member this.IsDefault ( summary : Summary , benchmarkCase : BenchmarkCase ): bool = false
31+ member this.IsNumeric : bool = true
32+ member this.Legend : string = sprintf " %s of input matrix" columnName
33+ member this.PriorityInCategory : int = 1
34+ member this.UnitType : UnitType = UnitType.Size
1135
1236type TEPSColumn () =
1337 interface IColumn with
1438 member this.AlwaysShow : bool = true
1539 member this.Category : ColumnCategory = ColumnCategory.Statistics
1640 member this.ColumnName : string = " TEPS"
1741 member this.GetValue ( summary : Summary , benchmarkCase : BenchmarkCase ): string =
42+ let inputMatrix = benchmarkCase.Parameters.[ " InputMatrix" ] :?> InputMatrixFormat
43+ let ( nrows , ncols , nnz ) =
44+ inputMatrix.MatrixStructure.RowCount,
45+ inputMatrix.MatrixStructure.ColumnCount,
46+ inputMatrix.MatrixStructure.Values.Length
47+ let ( vertices , edges ) = if nrows = ncols then ( nrows, nnz) else ( ncols, nrows)
1848 let meanTime = summary.[ benchmarkCase]. ResultStatistics.Mean
19- let pathToFirstGraph = benchmarkCase.Parameters.[ " PathToGraphPair" ] :?> ( string * string) |> fst
20- let getFullPathToGraph filename =
21- Path.Join [| __ SOURCE_ DIRECTORY__
22- " Datasets"
23- " EWiseAddDatasets"
24- filename |]
25- match Path.GetExtension pathToFirstGraph with
26- | " .mtx" ->
27- use streamReader = new StreamReader( pathToFirstGraph |> getFullPathToGraph)
28- while streamReader.Peek() = int '%' do
29- streamReader.ReadLine() |> ignore
30- let matrixInfo = streamReader.ReadLine() .Split( ' ' ) |> Array.map int
31- let ( nrows , ncols , nnz ) = matrixInfo.[ 0 ], matrixInfo.[ 1 ], matrixInfo.[ 2 ]
32- let ( vertices , edges ) = if nrows = ncols then ( nrows, nnz) else ( ncols, nrows)
33- sprintf " %f " <| float edges / ( meanTime * 1e-6 )
34- | another -> sprintf " %s files not supported" another
49+ sprintf " %f " <| float edges / ( meanTime * 1e-6 )
3550 member this.GetValue ( summary : Summary , benchmarkCase : BenchmarkCase , style : SummaryStyle ): string =
3651 ( this :> IColumn) .GetValue( summary, benchmarkCase)
3752 member this.Id : string = " TEPSColumn"
@@ -46,5 +61,18 @@ type Config() =
4661 inherit ManualConfig()
4762
4863 do
49- // base.AddColumn [| TEPSColumn() :> IColumn |] |> ignore
50- base .AddFilter [| NameFilter( fun name -> name.Contains " MathNet" || name.Contains " COO" ) :> IFilter |] |> ignore
64+ base .AddColumn(
65+ MatrixShapeColumn( " RowCount" , fun matrix -> matrix.MatrixStructure.RowCount) :> IColumn,
66+ MatrixShapeColumn( " ColumnCount" , fun matrix -> matrix.MatrixStructure.ColumnCount) :> IColumn,
67+ MatrixShapeColumn( " NNZ" , fun matrix -> matrix.MatrixStructure.Values.Length) :> IColumn,
68+ TEPSColumn() :> IColumn
69+ )
70+ |> ignore
71+
72+ base .AddFilter(
73+ DisjunctionFilter(
74+ NameFilter( fun name -> name.Contains " MathNet" ) :> IFilter,
75+ NameFilter( fun name -> name.Contains " COO" ) :> IFilter
76+ )
77+ )
78+ |> ignore
0 commit comments