示例#1
0
        public IStopwatch CreateAndStore(MeasuredOperation operation, bool outputToConsole = false)
        {
            var stopwatch = Create(operation, outputToConsole);

            cachedStopwatches[operation] = stopwatch;

            return(stopwatch);
        }
示例#2
0
            public AndroidFirebaseStopwatch(MeasuredOperation operation)
            {
                Operation = operation;

                #if USE_ANALYTICS
                firebaseTrace = FirebasePerformance.Instance.NewTrace(operation.ToString());
                #endif
            }
示例#3
0
        public IStopwatch Create(MeasuredOperation operation, bool outputToConsole = false)
        {
            var stopwatch = NativeCreate(operation);

            return(outputToConsole
                ? new ConsoleStopwatch(stopwatch)
                : new SingleUseStopwatch(stopwatch));
        }
示例#4
0
        public IStopwatch Get(MeasuredOperation operation)
        {
            if (cachedStopwatches.TryGetValue(operation, out var stopwatch))
            {
                return(stopwatch);
            }

            return(null);
        }
示例#5
0
 protected abstract IStopwatch NativeCreate(MeasuredOperation operation);
示例#6
0
 public void Remove(MeasuredOperation operation)
 {
     cachedStopwatches.Remove(operation);
 }
示例#7
0
 protected override IStopwatch NativeCreate(MeasuredOperation operation)
 => new AndroidFirebaseStopwatch(operation);
 public IosFirebaseStopwatch(MeasuredOperation operation)
 {
     Operation = operation;
 }
 public DummyStopwatch(MeasuredOperation operation)
 {
     Operation = operation;
 }
 protected override IStopwatch NativeCreate(MeasuredOperation operation)
 => new DummyStopwatch(operation);
示例#11
0
        public static IStopwatch MaybeCreateStopwatch(this IStopwatchProvider stopwatchProvider, MeasuredOperation operation, float probability)
        {
            var samplingFactor = samplingRandom.NextDouble();

            if (samplingFactor <= probability)
            {
                return(stopwatchProvider.Create(operation));
            }

            return(null);
        }