/// <summary> /// Shows a sample loop where an action is executed, and the latency of each execution is recorded. /// </summary> private static void RecordMeasurements() { var timer = Stopwatch.StartNew(); Action actionToMeasure = CreateAndCloseDatagramSocket; do { Histogram.Record(actionToMeasure); } while (timer.Elapsed < RunPeriod); }
public static LongHistogram Bench(Action action, int count) { var histogram = new LongHistogram(TimeStamp.Minutes(1), 5); for (var i = 0; i < count; i++) { histogram.Record(() => action()); } return(histogram); }