Skip to main content
100%

Measure.Performance (Simplifies work with Stopwatch class)

✓ Published0🌍 Public
RRestuta
Last edited Mar 1, 2012
Created on Mar 1, 2012

This example shows a simplified C# utility for measuring code execution time using the `System.Diagnostics.Stopwatch` class. The `Measure.Performance` method runs a given `Action` code block, records the elapsed milliseconds, and invokes a customizable `WhenDone` callback that defaults to printing the result to the console. The included `Program.Main` demonstrates usage by timing a loop that repeatedly creates and populates a `Dictionary<string, object>`, with the output formatted as `Execution time: {0}ms`. The code highlights how to set a custom reporting action and wrap performance measurement into a concise one-line API.

AI-generated description

Similar vizzes