/// <summary>
 /// 測定開始区間の最初にusingとともに呼び出すメソッドです。
 /// </summary>
 /// <param name="counter">
 /// 測定に使用する<see cref="BenchmarkCounter"/>オブジェクトです。
 /// </param>
 /// <returns>
 /// <see cref="IDisposable"/>オブジェクトです。
 /// このオブジェクトに対しDisposeが呼び出されると測定が停止します。
 /// </returns>
 public static IDisposable Begin(BenchmarkCounter counter)
 {
     if (counter == null)
     {
         return(_dummy_counter);
     }
     else
     {
         BenchmarkScope scope = new BenchmarkScope(counter);
         scope.OnBegin();
         return(scope);
     }
 }
Exemple #2
0
 /// <summary>
 /// 名前に対応する<see cref="BenchmarkCounter"/>オブジェクトです。
 /// もし名前に一致するオブジェクトが存在しなかった場合には新規に<see cref="BenchmarkCounter"/>オブジェクトが作成されます。
 /// </summary>
 /// <param name="location">
 /// <see cref="BenchmarkCounter"/>オブジェクトの名前です。
 /// </param>
 /// <returns>
 /// 見つかったあるいは作成された<see cref="BenchmarkCounter"/>オブジェクトです。
 /// </returns>
 /// <remarks>
 /// 測定対象のコードの区間を特定できる文字列を名前を<see cref="BenchmarkCounter"/>オブジェクトの名前として使用すると、区間毎に所要時間の累計をカウントするようにできます。
 /// </remarks>
 public BenchmarkCounter this[string location]
 {
     get
     {
         BenchmarkCounter found;
         if (!_counters.TryGetValue(location, out found))
         {
             found = new BenchmarkCounter(location);
             _counters.Add(location, found);
         }
         return(found);
     }
 }
 private BenchmarkScope(BenchmarkCounter counter)
 {
     _counter = counter;
 }