@@ -27,7 +27,7 @@ module Benchmarker =
27
27
28
28
let pipelineName = " benchmark-pipeline"
29
29
let indexName = IndexName.op_ Implicit( " benchmark-reports" )
30
- let typeName = TypeName.op_ Implicit( " report " )
30
+ let typeName = TypeName.op_ Implicit( " benchmarkreport " )
31
31
32
32
type Memory ( gen0Collections : int , gen1Collections : int , gen2Collections : int , totalOperations : int64 , bytesAllocatedPerOperation : int64 ) =
33
33
member val Gen0Collections = gen0Collections with get, set
@@ -111,7 +111,7 @@ module Benchmarker =
111
111
member val Statistics = statistics with get, set
112
112
member val Memory = memory with get, set
113
113
114
- type Report ( title : string , totalTime : TimeSpan , date : DateTime , commit : string , host : HostEnvironmentInfo , benchmarks : Benchmark list ) =
114
+ type BenchmarkReport ( title : string , totalTime : TimeSpan , date : DateTime , commit : string , host : HostEnvironmentInfo , benchmarks : Benchmark list ) =
115
115
member val Title = title with get, set
116
116
member val TotalTime = totalTime with get, set
117
117
member val Date = date with get, set
@@ -152,13 +152,13 @@ module Benchmarker =
152
152
153
153
let IndexResult ( client : ElasticClient , file : string , date : DateTime , commit : string , indexName , typeName ) =
154
154
155
- trace ( " Indexing report " + file + " into Elasticsearch" )
155
+ trace ( sprintf " Indexing report %s into Elasticsearch" file )
156
156
157
- let document = JsonConvert.DeserializeObject< Report >( File.ReadAllText( file))
157
+ let document = JsonConvert.DeserializeObject< BenchmarkReport >( File.ReadAllText( file))
158
158
document.Date <- date
159
159
document.Commit <- commit
160
160
161
- let indexRequest = new IndexRequest< Report >( indexName, typeName)
161
+ let indexRequest = new IndexRequest< BenchmarkReport >( indexName, typeName)
162
162
indexRequest.Document <- document
163
163
indexRequest.Pipeline <- pipelineName
164
164
@@ -169,7 +169,7 @@ module Benchmarker =
169
169
170
170
let IndexResults ( url , username , password ) =
171
171
if ( String.IsNullOrEmpty url = false ) then
172
- trace " Indexing benchmark results into Elasticsearch"
172
+ trace " Indexing benchmark reports into Elasticsearch"
173
173
174
174
let date = DateTime.UtcNow
175
175
let commit = getSHA1 " ." " HEAD"
@@ -185,26 +185,35 @@ module Benchmarker =
185
185
connectionSettings.BasicAuthentication( username, password) |> ignore
186
186
187
187
let client = new ElasticClient( connectionSettings)
188
-
189
- let indexExists = client.IndexExists( Indices.op_ Implicit( indexName)) .Exists
190
-
191
- if indexExists = false then
192
- let createIndex = client.CreateIndex( indexName, fun c ->
193
- c.Mappings( fun m ->
194
- m.Map< Report>( fun mm ->
195
- mm.AutoMap()
196
- .Properties( fun p ->
197
- p.Nested< Benchmark>( fun n ->
198
- n.AutoMap() .Name( PropertyName.op_ Implicit( " benchmarks" )) :> INestedProperty
199
- ) :> IPromise< IProperties>
200
- ) :> ITypeMapping
201
- ) :> IPromise< IMappings>
202
- ) :> ICreateIndexRequest
203
- )
204
-
205
- if createIndex.IsValid = false then
206
- raise ( Exception( " Unable to create index into Elasticsearch" ))
207
-
188
+
189
+ let indexTemplateExists = client.IndexTemplateExists( Name.op_ Implicit( " benchmarks" )) .Exists
190
+
191
+ if indexTemplateExists |> not then
192
+
193
+ let typeMapping = new TypeMappingDescriptor< BenchmarkReport>()
194
+ typeMapping.AutoMap() |> ignore
195
+ typeMapping.Properties( fun p ->
196
+ p.Nested< Benchmark>( fun n ->
197
+ n.AutoMap() .Name( PropertyName.op_ Implicit( " benchmarks" )) :> INestedProperty
198
+ ) :> IPromise< IProperties>
199
+ ) |> ignore
200
+
201
+ let mappings = new Mappings()
202
+ mappings.Add( typeName, typeMapping :> ITypeMapping)
203
+
204
+ let indexSettings = new IndexSettings()
205
+ indexSettings.NumberOfShards <- Nullable 1
206
+
207
+ let putIndexTemplateRequest = new PutIndexTemplateRequest( Name.op_ Implicit( " benchmarks" ))
208
+ putIndexTemplateRequest.Template <- " benchmark-reports-*"
209
+ putIndexTemplateRequest.Mappings <- mappings
210
+ putIndexTemplateRequest.Settings <- indexSettings
211
+
212
+ let putIndexTemplateResponse = client.PutIndexTemplate( putIndexTemplateRequest)
213
+
214
+ if putIndexTemplateResponse.IsValid = false then
215
+ raise ( Exception( " Unable to create index template into Elasticsearch" ))
216
+
208
217
let processor = new GrokProcessor();
209
218
processor.Field <- new Field( " _ingest._value.displayInfo" )
210
219
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}\\ )" ]
@@ -213,15 +222,22 @@ module Benchmarker =
213
222
forEachProcessor.Field <- new Field( " benchmarks" )
214
223
forEachProcessor.Processor <- processor
215
224
225
+ let dateIndexProcessor = new DateIndexNameProcessor();
226
+ dateIndexProcessor.Field <- new Field( " date" )
227
+ dateIndexProcessor.IndexNamePrefix <- " benchmark-reports-"
228
+ dateIndexProcessor.DateRounding <- DateRounding.Month
229
+ dateIndexProcessor.DateFormats <- [ " yyyy-MM-dd'T'HH:mm:ss.SSSSSSSZ" ]
230
+
216
231
let request = new PutPipelineRequest( Id.op_ Implicit( pipelineName))
217
- request.Description <- " Grok benchmark settings"
218
- request.Processors <- [ forEachProcessor]
232
+ request.Description <- " Benchmark settings pipeline "
233
+ request.Processors <- [ dateIndexProcessor ; forEachProcessor]
219
234
220
235
let createPipeline = client.PutPipeline( request)
221
236
222
237
if createPipeline.IsValid = false then
223
238
raise ( Exception( " Unable to create pipeline" ))
224
239
225
- for file in benchmarkJsonFiles do IndexResult ( client, file, date, commit, indexName, typeName)
240
+ for file in benchmarkJsonFiles
241
+ do IndexResult ( client, file, date, commit, indexName, typeName)
226
242
227
- trace " Indexed benchmark results into Elasticsearch"
243
+ trace " Indexed benchmark reports into Elasticsearch"
0 commit comments