示例#1
0
 public static void TimeScope(this DataMeter target, Action action, string timeElapsedKey = DurationKey)
 {
     using (target.TimeScope(timeElapsedKey))
     {
         action();
     }
 }
示例#2
0
 public static void ConditionalTimeScope(this DataMeter target,
                                         Action action,
                                         Func <bool> condition,
                                         string timeElapsedKey = DurationKey)
 {
     using (target.ConditionalTimeScope(condition, timeElapsedKey))
     {
         action();
     }
 }
示例#3
0
        public static IDisposable TimeScope(this DataMeter target, string timeElapsedKey = DurationKey)
        {
            var stopWatch = new Stopwatch();

            return(new ExecutionScope(stopWatch.Start, () =>
            {
                stopWatch.Stop();
                target.Data.Add(timeElapsedKey, stopWatch.Elapsed.TotalMilliseconds);
                target.Send();
            }));
        }
示例#4
0
 public static DataMeter AddData(this DataMeter target, string key, object value)
 {
     target.Data.Add(key, value);
     return(target);
 }