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());
        }
        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();
        }
示例#3
0
 // <inheritdoc />
 public void Reset()
 {
     _reservoir.Reset();
 }
示例#4
0
 /// <inheritdoc />
 public void Reset()
 {
     _last = UserValueWrapper.Empty;
     _reservoir.Reset();
 }