/// <summary> /// Logs the time from now to the call of End() on the returned object (== success) or it's disposal (== failure). /// </summary> /// <param name="operationName">The name of the operation (will be used for log messages).</param> /// <returns>Object to stop the benchmark.</returns> /// <example> /// <code> /// using(var op = CBenchmark.Begin("TestOperation")){ /// //do someting that could fail /// op.End(); /// } /// </code> /// </example> public static COperation Begin(string operationName) { CBenchmark benchmark = new CBenchmark(operationName); benchmark.Start(); return(new COperation(benchmark)); }
/// <summary> /// Logs the time from now to disposal of the returned object. /// </summary> /// <param name="operationName">The name of the operation (will be used for log messages).</param> /// <returns>Object which needs to be disposed to stop the benchmark.</returns> /// <example> /// <code> /// using(CBenchmark.Time("TestOperation")){ /// //do someting /// } /// </code> /// </example> public static IDisposable Time(string operationName) { CBenchmark benchmark = new CBenchmark(operationName); benchmark.Start(); return(benchmark); }
/// <summary> /// Creates a new instance of the benchmark helper object. /// </summary> /// <param name="benchmark">The associated benchmark object.</param> internal COperation(CBenchmark benchmark) { _Benchmark = benchmark; }