Move name and sample analysis in benchmarks into BenchmarkStats

This always saves 1 allocation per benchmark, and another two
allocations if the benchmark name is longer than the SSO buffer.
This commit is contained in:
Martin Hořeňovský 2023-01-28 21:40:51 +01:00
parent e5d1eb757f
commit 356dfc1439
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A

View File

@ -64,7 +64,7 @@ namespace Catch {
});
BenchmarkInfo info {
name,
CATCH_MOVE(name),
plan.estimated_duration.count(),
plan.iterations_per_sample,
cfg->benchmarkSamples(),
@ -80,7 +80,7 @@ namespace Catch {
});
auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end());
BenchmarkStats<FloatDuration<Clock>> stats{ info, analysis.samples, analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance };
BenchmarkStats<FloatDuration<Clock>> stats{ CATCH_MOVE(info), CATCH_MOVE(analysis.samples), analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance };
getResultCapture().benchmarkEnded(stats);
} CATCH_CATCH_ANON (TestFailureException) {
getResultCapture().benchmarkFailed("Benchmark failed due to failed assertion"_sr);