Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hello.

I'm trying to implement a simple custom column that would contain Mean / N value where mean is a mean time from the standard result attributes, and N is a custom parameter that controls the number of iterations inside of my benchmark.
I understand how to get the value of N for a custom column, but I can't seem to find how to get the Mean value.

You must be logged in to vote

In the GetValue implementation of your column, you can get to the the parameter's value and benchmark's statistics like so:

public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) {
  int n = (int)benchmarkCase.Parameters["N"];
  Statistics statistics = summary[benchmarkCase]!.ResultStatistics!;
  double mean = TimeInterval.FromNanoseconds(statistics.Mean).ToSeconds();
  double result = mean / n;
  return string.Create(style.CultureInfo, $"{result:F3} s");
}

In another column, you can calculate the error, assuming the error of N is zero:

double result = ...; double mean = ...; as above
double meanStdDev = TimeInterval.FromNanoseconds(statistics.StandardDe…

Replies: 1 comment · 1 reply

Comment options

In the GetValue implementation of your column, you can get to the the parameter's value and benchmark's statistics like so:

public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) {
  int n = (int)benchmarkCase.Parameters["N"];
  Statistics statistics = summary[benchmarkCase]!.ResultStatistics!;
  double mean = TimeInterval.FromNanoseconds(statistics.Mean).ToSeconds();
  double result = mean / n;
  return string.Create(style.CultureInfo, $"{result:F3} s");
}

In another column, you can calculate the error, assuming the error of N is zero:

double result = ...; double mean = ...; as above
double meanStdDev = TimeInterval.FromNanoseconds(statistics.StandardDeviation).ToSeconds();
double resultStdDev = result * meanStdDev / mean;
return string.Create(style.CultureInfo, $"{resultStdDev:F3} s");
You must be logged in to vote
1 reply
@quixoticaxis
Comment options

Thank you.

Answer selected by quixoticaxis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.