@@ -112,7 +112,7 @@ module Benchmarker =
112112 member val Statistics = statistics with get, set
113113 member val Memory = memory with get, set
114114
115- type BenchmarkReport ( title : string , totalTime : TimeSpan , date : DateTime , commit : string , branchName : string , host : HostEnvironmentInfo , benchmarks : Benchmark list ) =
115+ type BenchmarkReports ( title : string , totalTime : TimeSpan , date : DateTime , commit : string , branchName : string , host : HostEnvironmentInfo , benchmarks : Benchmark list ) =
116116 member val Title = title with get, set
117117 member val TotalTime = totalTime with get, set
118118 member val Date = date with get, set
@@ -121,6 +121,15 @@ module Benchmarker =
121121 member val HostEnvironmentInfo = host with get, set
122122 member val Benchmarks = benchmarks with get, set
123123
124+ type BenchmarkReport ( title : string , totalTime : TimeSpan , date : DateTime , commit : string , branchName : string , host : HostEnvironmentInfo , benchmark : Benchmark ) =
125+ member val Title = title with get, set
126+ member val TotalTime = totalTime with get, set
127+ member val Date = date with get, set
128+ member val Commit = commit with get, set
129+ member val BranchName = branchName with get, set
130+ member val HostEnvironmentInfo = host with get, set
131+ member val Benchmark = benchmark with get, set
132+
124133 let private testsProjectDirectory = Path.GetFullPath( Paths.Source( " Tests" ))
125134 let private benchmarkOutput = Path.GetFullPath( Paths.Output( " benchmarks" )) |> directoryInfo
126135 let private copyToOutput file = CopyFile benchmarkOutput.FullName file
@@ -129,9 +138,6 @@ module Benchmarker =
129138
130139 ensureDirExists benchmarkOutput
131140
132- let projectJson = testsProjectDirectory @@ " project.json"
133-
134- // running benchmarks can timeout so clean up any generated benchmark files
135141 try
136142 if runInteractive then
137143 DotNetCli.RunCommand( fun p ->
@@ -144,6 +150,7 @@ module Benchmarker =
144150 WorkingDir = testsProjectDirectory
145151 }) " run -f net46 -c Release Benchmark non-interactive"
146152 finally
153+ // running benchmarks can timeout so clean up any generated benchmark files
147154 let benchmarkOutputFiles =
148155 let output = combinePaths testsProjectDirectory " BenchmarkDotNet.Artifacts"
149156 Directory.EnumerateFiles( output, " *.*" , SearchOption.AllDirectories)
@@ -154,25 +161,37 @@ module Benchmarker =
154161
155162 let IndexResult ( client : ElasticClient , file : string , date : DateTime , commit : string , branchName : string , indexName , typeName ) =
156163
157- trace ( sprintf " Indexing report %s into Elasticsearch" file)
164+ trace ( sprintf " Indexing benchmark results (class) %s " file)
165+
166+ let benchmarkReports = JsonConvert.DeserializeObject< BenchmarkReports>( File.ReadAllText( file))
167+ benchmarkReports.Date <- date
168+ benchmarkReports.Commit <- commit
169+ benchmarkReports.BranchName <- branchName
158170
159- let document = JsonConvert.DeserializeObject< BenchmarkReport>( File.ReadAllText( file))
160- document.Date <- date
161- document.Commit <- commit
162- document.BranchName <- branchName
171+ for benchmarkReportSingle in benchmarkReports.Benchmarks do
163172
164- let indexRequest = new IndexRequest< BenchmarkReport>( indexName, typeName)
165- indexRequest.Document <- document
166- indexRequest.Pipeline <- pipelineName
173+ trace ( sprintf " Indexing benchmark result (method) %s " benchmarkReportSingle.MethodTitle)
167174
168- let indexResponse = client.Index( indexRequest)
175+ let document = new BenchmarkReport( benchmarkReports.Title,
176+ benchmarkReports.TotalTime,
177+ benchmarkReports.Date,
178+ benchmarkReports.Commit,
179+ benchmarkReports.BranchName,
180+ benchmarkReports.HostEnvironmentInfo,
181+ benchmarkReportSingle)
182+
183+ let indexRequest = new IndexRequest< BenchmarkReport>( indexName, typeName)
184+ indexRequest.Document <- document
185+ indexRequest.Pipeline <- pipelineName
186+
187+ let indexResponse = client.Index( indexRequest)
169188
170- if indexResponse.IsValid = false then
171- raise ( Exception( " Unable to index report into Elasticsearch : " + indexResponse.ServerError.Error.ToString()))
189+ if indexResponse.IsValid = false then
190+ raise ( Exception( " Unable to index benchmark result (method) : " + indexResponse.ServerError.Error.ToString()))
172191
173192 let IndexResults ( url , username , password ) =
174193 if ( String.IsNullOrEmpty url = false ) then
175- trace " Indexing benchmark reports into Elasticsearch "
194+ trace " Indexing benchmark reports"
176195
177196 let date = DateTime.UtcNow
178197 let commit = getSHA1 " ." " HEAD"
@@ -196,11 +215,6 @@ module Benchmarker =
196215
197216 let typeMapping = new TypeMappingDescriptor< BenchmarkReport>()
198217 typeMapping.AutoMap() |> ignore
199- typeMapping.Properties( fun p ->
200- p.Nested< Benchmark>( fun n ->
201- n.AutoMap() .Name( PropertyName.op_ Implicit( " benchmarks" )) :> INestedProperty
202- ) :> IPromise< IProperties>
203- ) |> ignore
204218
205219 let mappings = new Mappings()
206220 mappings.Add( typeName, typeMapping :> ITypeMapping)
@@ -218,13 +232,9 @@ module Benchmarker =
218232 if putIndexTemplateResponse.IsValid = false then
219233 raise ( Exception( " Unable to create index template into Elasticsearch" ))
220234
221- let processor = new GrokProcessor();
222- processor.Field <- new Field( " _ingest._value.displayInfo" )
223- processor.Patterns <- [ " %{WORD:_ingest._value.class}.%{DATA:_ingest._value.method}: Job-%{WORD:_ingest._value.jobName}\\ (Jit=%{WORD:_ingest._value.jit}, Runtime=%{WORD:_ingest._value.clr}, LaunchCount=%{NUMBER:_ingest._value.launchCount}, RunStrategy=%{WORD:_ingest._value.runStrategy}, TargetCount=%{NUMBER:_ingest._value.targetCount}, UnrollFactor=%{NUMBER:_ingest._value.unrollFactor}, WarmupCount=%{NUMBER:_ingest._value.warmupCount}\\ )" ]
224-
225- let forEachProcessor = new ForeachProcessor()
226- forEachProcessor.Field <- new Field( " benchmarks" )
227- forEachProcessor.Processor <- processor
235+ let grokProcessor = new GrokProcessor();
236+ grokProcessor.Field <- new Field( " benchmark.displayInfo" )
237+ grokProcessor.Patterns <- [ " %{WORD:class}.%{DATA:method}: Job-%{WORD:jobName}\\ (Jit=%{WORD:jit}, Runtime=%{WORD:clr}, LaunchCount=%{NUMBER:launchCount}, RunStrategy=%{WORD:runStrategy}, TargetCount=%{NUMBER:targetCount}, UnrollFactor=%{NUMBER:unrollFactor}, WarmupCount=%{NUMBER:warmupCount}\\ )" ]
228238
229239 let dateIndexProcessor = new DateIndexNameProcessor();
230240 dateIndexProcessor.Field <- new Field( " date" )
@@ -234,7 +244,7 @@ module Benchmarker =
234244
235245 let request = new PutPipelineRequest( Id.op_ Implicit( pipelineName))
236246 request.Description <- " Benchmark settings pipeline"
237- request.Processors <- [ dateIndexProcessor; forEachProcessor ]
247+ request.Processors <- [ dateIndexProcessor; grokProcessor ]
238248
239249 let createPipeline = client.PutPipeline( request)
240250
@@ -244,4 +254,4 @@ module Benchmarker =
244254 for file in benchmarkJsonFiles
245255 do IndexResult ( client, file, date, commit, branchName, indexName, typeName)
246256
247- trace " Indexed benchmark reports into Elasticsearch "
257+ trace " Indexed benchmark reports"
0 commit comments