private static void Run(IReservoir reservoir) { var thread = new List <Thread>(); for (var i = 0; i < ThreadCount; i++) { thread.Add(new Thread(() => { for (long j = 0; j < NumberOfRuns; j++) { reservoir.Update(1, $"user-value-{j}"); if (j % 4 == 0) { reservoir.GetSnapshot(); } if (j == NumberOfRuns / 2) { reservoir.Reset(); } } })); } thread.ForEach(t => t.Start()); thread.ForEach(t => t.Join()); }
public HistogramMetric(IReservoir reservoir) { if (reservoir == null) { throw new ArgumentNullException(nameof(reservoir)); } _reservoir = reservoir; }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.Reservoir == null)) { IReservoir reservoirCasted = item.As <IReservoir>(); if ((reservoirCasted != null)) { this._parent.Reservoir = reservoirCasted; return; } } }
private void RunReservoir(IReservoir reservoir) { var scheduler = new DefaultTaskScheduler(); scheduler.Interval( TimeSpan.FromMilliseconds(20), TaskCreationOptions.None, () => { reservoir.GetSnapshot(); reservoir.Reset(); }); SimpleBenchmarkRunner.Run( () => { reservoir.Update(_fixture.Rnd.Next(0, 1000), _fixture.RandomUserValue); }); scheduler.Dispose(); }
/// <summary> /// Initializes a new instance of the <see cref="ApdexProvider" /> class. /// </summary> /// <param name="reservoir">The reservoir used to sample values in order to caclulate an apdex score.</param> /// <param name="apdexTSeconds">The apdex t seconds used to calculate satisfied, tolerating and frustrating counts.</param> public ApdexProvider(IReservoir reservoir, double apdexTSeconds) { _reservoir = reservoir; _apdexTSeconds = apdexTSeconds; }
/// <summary> /// Initializes a new instance of the <see cref="ApdexProvider" /> class. /// </summary> /// <remarks> /// The apdex T <see cref="Constants.ReservoirSampling">default</see> value will be used /// </remarks> /// <param name="reservoir">The reservoir used to sample values in order to caclulate an apdex score.</param> public ApdexProvider(IReservoir reservoir) : this(reservoir, Constants.ReservoirSampling.DefaultApdexTSeconds) { }
/// <summary> /// Initializes a new instance of the <see cref="DefaultTimerMetric" /> class. /// </summary> /// <param name="reservoir">The reservoir implementation to use for sampling values to generate the histogram.</param> /// <param name="clock">The clock to use to measure processing duration.</param> /// <param name="meterTickScheduler">The scheduler used to tick the associated meter.</param> internal DefaultTimerMetric(IReservoir reservoir, IClock clock, IMeterTickerScheduler meterTickScheduler) { _clock = clock; _histogram = new DefaultHistogramMetric(reservoir); _meter = new DefaultMeterMetric(clock, meterTickScheduler); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultTimerMetric" /> class. /// </summary> /// <param name="reservoir">The reservoir to use for sampling within the histogram.</param> /// <param name="meter">The meter implementation to use to genreate the rate of events over time.</param> /// <param name="clock">The clock to use to measure processing duration.</param> public DefaultTimerMetric(IReservoir reservoir, IMeterMetric meter, IClock clock) : this(new DefaultHistogramMetric(reservoir), meter, clock) { }
/// <summary> /// Initializes a new instance of the <see cref="DefaultTimerMetric" /> class. /// </summary> /// <param name="reservoir">The reservoir implementation to use for sampling values to generate the histogram.</param> /// <param name="clock">The clock to use to measure processing duration.</param> public DefaultTimerMetric(IReservoir reservoir, IClock clock) { _clock = clock; _histogram = new DefaultHistogramMetric(reservoir); _meter = new DefaultMeterMetric(clock); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultApdexMetric" /> class. /// </summary> /// <param name="reservoir">The reservoir to user for sampling.</param> /// <param name="clock">The clock to use to measure processing duration.</param> /// <param name="allowWarmup"> /// if set to <c>true</c> allows the service to warmup before starting to calculate the apdex, /// the score will intitially be 1 until enough samples have been recorded. /// </param> public DefaultApdexMetric(IReservoir reservoir, IClock clock, bool allowWarmup) // ReSharper disable RedundantArgumentDefaultValue : this(new ApdexProvider(reservoir, AppMetricsReservoirSamplingConstants.DefaultApdexTSeconds), clock, allowWarmup) // ReSharper restore RedundantArgumentDefaultValue { }
public HistogramMetric(IReservoir reservoir) { _reservoir = reservoir; }
/// <summary> /// Initializes a new instance of the <see cref="TimerMetric" /> class. /// </summary> /// <param name="reservoir">The reservoir implementation to use for sampling values to generate the histogram.</param> /// <param name="clock">The clock to use to measure processing duration.</param> public TimerMetric(IReservoir reservoir, IClock clock) : this(new HistogramMetric(reservoir), new MeterMetric(clock), clock) { }
public static ITimerMetric BuildTimer(this IAdvancedMetrics context, TimerOptions options, IReservoir reservoir) { return(new TimerMetric(reservoir, context.Clock)); }
public static IHistogramMetric BuildHistogram(this IAdvancedMetrics context, HistogramOptions options, IReservoir reservoir) { return(new HistogramMetric(reservoir)); }
public static IApdexMetric BuildApdex(this IAdvancedMetrics context, ApdexOptions options, IReservoir reservoir) { return(new ApdexMetric(new ApdexProvider(reservoir, options.ApdexTSeconds), context.Clock)); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultHistogramMetric" /> class. /// </summary> /// <param name="reservoir">The reservoir to use for sampling.</param> public DefaultHistogramMetric(IReservoir reservoir) { _reservoir = reservoir ?? throw new ArgumentNullException(nameof(reservoir)); }
/// <summary> /// Initializes a new instance of the <see cref="ApdexProvider" /> class. /// </summary> /// <param name="reservoir">The reservoir used to sample values in order to caclulate an apdex score.</param> /// <param name="apdexTSeconds">The apdex t seconds used to calculate satisfied, tolerating and frustrating counts.</param> public ApdexProvider(IReservoir reservoir, double apdexTSeconds = AppMetricsReservoirSamplingConstants.DefaultApdexTSeconds) { _reservoir = reservoir; _apdexTSeconds = apdexTSeconds; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultApdexMetric" /> class. /// </summary> /// <param name="reservoir">The reservoir to user for sampling.</param> /// <param name="apdexTSeconds">The apdex t seconds value between 0 and 1.</param> /// <param name="clock">The clock to use to measure processing duration.</param> /// <param name="allowWarmup"> /// if set to <c>true</c> allows the service to warmup before starting to calculate the apdex, /// the score will intitially be 1 until enough samples have been recorded. /// </param> public DefaultApdexMetric(IReservoir reservoir, double apdexTSeconds, IClock clock, bool allowWarmup) : this(new ApdexProvider(reservoir, apdexTSeconds), clock, allowWarmup) { }