protected MemoryRegionCache(int size, SizeClass sizeClass) { _size = MathUtil.SafeFindNextPositivePowerOfTwo(size); _queue = PlatformDependent.NewFixedMpscQueue <Entry>(_size); _sizeClass = sizeClass; }
public void GlobalSetup() { this.concurrentQueueExecutor = new TestExecutor("CompatibleConcurrentQueue", TimeSpan.FromSeconds(1), new CompatibleConcurrentQueue <IRunnable>()); this.fixedMpscQueueExecutor = new TestExecutor("FixedMpscQueue", TimeSpan.FromSeconds(1), PlatformDependent.NewFixedMpscQueue <IRunnable>(1 * 1000 * 1000)); }
public void GlobalSetup() { _singleThreadEventLoop = new NewTestExecutor("SingleThreadEventLoop", TimeSpan.FromSeconds(1)); _concurrentQueueExecutor = new TestExecutor("CompatibleConcurrentQueue", TimeSpan.FromSeconds(1), new CompatibleConcurrentQueue <IRunnable>()); _fixedMpscQueueExecutor = new TestExecutor("FixedMpscQueue", TimeSpan.FromSeconds(1), PlatformDependent.NewFixedMpscQueue <IRunnable>(1 * 1000 * 1000)); }
protected MemoryRegionCache(int size, SizeClass sizeClass) { this.size = IntegerExtensions.RoundUpToPowerOfTwo(size); this.queue = PlatformDependent.NewFixedMpscQueue <Entry>(this.size); this.sizeClass = sizeClass; }
public void BenchSingleThreadEventExecutorWaiting() { var testSubjects = new Dictionary <string, IEventExecutor> { { "CompatibleConcurrentQueue", new TestExecutor("ConcurrentQueueCustom", TimeSpan.FromSeconds(1), new CompatibleConcurrentQueue <IRunnable>()) }, { "ArrayQueue", new TestExecutor("ArrayQueue", TimeSpan.FromSeconds(1), PlatformDependent.NewFixedMpscQueue <IRunnable>(1 * 1000 * 1000)) } }; var mre = new ManualResetEvent(false); CodeTimer.Benchmark(testSubjects, "STEE in loop ({0})", 1, this.output, scheduler => { var action = new BenchActionIn(scheduler, mre); scheduler.Execute(action); if (!mre.WaitOne(TimeSpan.FromMinutes(1))) { throw new TimeoutException($"{scheduler.GetType().Name} benchmark timed out."); } mre.Reset(); }); CodeTimer.Benchmark(testSubjects, "STEE out of loop ({0})", 1, this.output, scheduler => { var action = new BenchActionOut(mre); for (int i = 0; i < Iterations; i++) { scheduler.Execute(action); } if (!mre.WaitOne(TimeSpan.FromMinutes(1))) { throw new TimeoutException($"{scheduler.GetType().Name} benchmark timed out."); } mre.Reset(); }); foreach (IEventExecutor scheduler in testSubjects.Values) { scheduler.ShutdownGracefullyAsync(); } }