Show / Hide Table of Contents

Struct Measurement

The basic captured statistics for a benchmark

Implements
IComparable<Measurement>
Inherited Members
ValueType.Equals(Object)
ValueType.GetHashCode()
Namespace: BenchmarkDotNet.Reports
Assembly: BenchmarkDotNet.dll
Syntax
public struct Measurement : IComparable<Measurement>

Constructors

Measurement(Int32, IterationMode, IterationStage, Int32, Int64, Double)

Creates an instance of Measurement struct.

Declaration
public Measurement(int launchIndex, IterationMode iterationMode, IterationStage iterationStage, int iterationIndex, long operations, double nanoseconds)
Parameters
Type Name Description
Int32 launchIndex
IterationMode iterationMode
IterationStage iterationStage
Int32 iterationIndex
Int64 operations

The number of operations performed.

Double nanoseconds

The total number of nanoseconds it took to perform all operations.

Properties

IterationIndex

Declaration
public readonly int IterationIndex { get; }
Property Value
Type Description
Int32

IterationMode

Declaration
public readonly IterationMode IterationMode { get; }
Property Value
Type Description
IterationMode

IterationStage

Declaration
public readonly IterationStage IterationStage { get; }
Property Value
Type Description
IterationStage

LaunchIndex

Declaration
public readonly int LaunchIndex { get; }
Property Value
Type Description
Int32

Nanoseconds

Gets the total number of nanoseconds it took to perform all operations.

Declaration
public readonly double Nanoseconds { get; }
Property Value
Type Description
Double

Operations

Gets the number of operations performed.

Declaration
public readonly long Operations { get; }
Property Value
Type Description
Int64

Methods

CompareTo(Measurement)

Declaration
public int CompareTo(Measurement other)
Parameters
Type Name Description
Measurement other
Returns
Type Description
Int32

GetAverageTime()

Gets the average duration of one operation.

Declaration
public TimeInterval GetAverageTime()
Returns
Type Description
TimeInterval

Parse(String, Int32)

Parses the benchmark statistics from the plain text line.

E.g. given the input line:

WorkloadTarget 1: 10 op, 1005842518 ns

Will extract the number of Operations performed and the total number of Nanoseconds it took to perform them.

Declaration
public static Measurement Parse(string line, int processIndex)
Parameters
Type Name Description
String line

The line to parse.

Int32 processIndex

Process launch index, indexed from one.

Returns
Type Description
Measurement

An instance of Measurement if parsed successfully. Null in case of any trouble.

ToString()

Declaration
public override string ToString()
Returns
Type Description
String
Overrides
ValueType.ToString()

Implements

System.IComparable<T>

Extension Methods

MeasurementExtensions.GetOpsPerSecond(Measurement)
MeasurementExtensions.Is(Measurement, IterationMode, IterationStage)
MeasurementExtensions.IsOverhead(Measurement)
MeasurementExtensions.IsWorkload(Measurement)
In This Article
Back to top Copyright © 2013–2021 .NET Foundation and contributors