private List CreateBenchmarkDocuments()

in src/Elastic.CommonSchema.BenchmarkDotNetExporter/ElasticsearchBenchmarkExporter.cs [103:212]


		private List<BenchmarkDocument> CreateBenchmarkDocuments(Summary summary)
		{
			var benchmarks = summary.Reports.Select(r =>
				{
					var gc = r.BenchmarkCase.Job.Environment.Gc;
					var run = r.BenchmarkCase.Job.Run;
					var jobConfig = new BenchmarkJobConfig
					{
						Platform = Enum.GetName(typeof(Platform), r.BenchmarkCase.Job.Environment.Platform),
						Launch = new BenchmarkLaunchInformation
						{
							RunStrategy = Enum.GetName(typeof(RunStrategy), run.RunStrategy),
							LaunchCount = run.LaunchCount,
							WarmCount = run.WarmupCount,
							UnrollFactor = run.UnrollFactor,
							IterationCount = run.IterationCount,
							InvocationCount = run.InvocationCount,
							MaxIterationCount = run.MaxIterationCount,
							MinIterationCount = run.MinIterationCount,
							MaxWarmupIterationCount = run.MaxWarmupIterationCount,
							MinWarmupIterationCount = run.MinWarmupIterationCount,
							IterationTimeInMilliseconds = run.IterationTime.ToMilliseconds(),
						},
						RunTime = r.BenchmarkCase.Job.Environment.Runtime?.Name,
						Jit = Enum.GetName(typeof(Jit), r.BenchmarkCase.Job.Environment.Jit),
						Gc = new BenchmarkGcInfo
						{
							Force = gc.Force,
							Server = gc.Server,
							Concurrent = gc.Concurrent,
							RetainVm = gc.RetainVm,
							CpuGroups = gc.CpuGroups,
							HeapCount = gc.HeapCount,
							NoAffinitize = gc.NoAffinitize,
							HeapAffinitizeMask = gc.HeapAffinitizeMask,
							AllowVeryLargeObjects = gc.AllowVeryLargeObjects,
						},
						Id = r.BenchmarkCase.Job.Environment.Id,
					};
					var host = CreateHostEnvironmentInformation(summary);
					var git = new BenchmarkGit
					{
						Sha = Options.GitCommitSha,
						BranchName = Options.GitBranch,
						CommitMessage = Options.GitCommitMessage,
						Repository = Options.GitRepositoryIdentifier
					};
					var runtimeVersion = new BenchmarkLanguage
					{
						Version = summary.HostEnvironmentInfo.RuntimeVersion,
						DotNetSdkVersion = summary.HostEnvironmentInfo.DotNetSdkVersion.Value,
						HasRyuJit = summary.HostEnvironmentInfo.HasRyuJit,
						//JitModules = summary.HostEnvironmentInfo.,
						JitInfo = summary.HostEnvironmentInfo.JitInfo,
						BuildConfiguration = summary.HostEnvironmentInfo.Configuration,
						BenchmarkDotNetCaption = HostEnvironmentInfo.BenchmarkDotNetCaption,
						BenchmarkDotNetVersion = summary.HostEnvironmentInfo.BenchmarkDotNetVersion,
					};
					var agent = new BenchmarkAgent { Git = git, Language = runtimeVersion, };

					var @event = new BenchmarkEvent
					{
						Description = r.BenchmarkCase.Descriptor.WorkloadMethodDisplayInfo,
						Action = r.BenchmarkCase.Descriptor.WorkloadMethod.Name,
						Module = r.BenchmarkCase.Descriptor.Type.Namespace,
						Category = new [] { summary.Title },
						Type = new [] { FullNameProvider.GetTypeName(r.BenchmarkCase.Descriptor.Type) },
						Duration = summary.TotalTime.Ticks * 100,
						Original = r.BenchmarkCase.DisplayInfo,
						JobConfig = jobConfig,
						Method = FullNameProvider.GetBenchmarkName(r.BenchmarkCase),
						Parameters = r.BenchmarkCase.Parameters.PrintInfo,
					};
					var data = new BenchmarkDocument
					{
						Timestamp = DateTime.UtcNow,
						Host = host,
						Agent = agent,
						Event = @event,
						Benchmark = new BenchmarkData(r.ResultStatistics, r.Success),
					};

					if (summary.BenchmarksCases.Any(c => c.Config.HasMemoryDiagnoser()))
						data.Benchmark.Memory = new BenchmarkGcStats(r.GcStats, r.BenchmarkCase);

					var grouped = r.AllMeasurements
						.GroupBy(m => $"{m.IterationStage.ToString()}-{m.IterationMode.ToString()}")
						.Where(g => g.Any())
						.ToList();

					@event.MeasurementStages = grouped
						.Select(g => new BenchmarkMeasurementStage
						{
							IterationMode = g.First().IterationMode.ToString(),
							IterationStage = g.First().IterationStage.ToString(),
							Operations = g.First().Operations,
						});

					var warmupCount = grouped.Select(g => g.First())
						.FirstOrDefault(s => s.IterationStage == IterationStage.Warmup && s.IterationMode == IterationMode.Workload)
						.Operations;
					var measuredCount = grouped.Select(g => g.First())
						.FirstOrDefault(s => s.IterationStage == IterationStage.Result && s.IterationMode == IterationMode.Workload)
						.Operations;
					@event.Repetitions = new BenchmarkSimplifiedWorkloadCounts { Warmup = warmupCount, Measured = measuredCount };
					return data;
				})
				.ToList();
			return benchmarks;
		}