コード例 #1
0
        public void PipelineOverhead_Cache()
        {
            _engine.SetCache(new DefaultFlowCache(new CacheConfiguration()
            {
                Builder = new LruPutCacheBuilder(),
                Size    = 100
            }));
            // Set process cost to 0.2 ms. Therefore the test cannot be passed
            // unless the cache is mitigating this cost as it should do.
            _engine.SetProcessCost(2000);

            int iterations = 10000;
            var start      = DateTime.UtcNow;

            for (int i = 0; i < iterations; i++)
            {
                _pipeline.CreateFlowData()
                .AddEvidence("test.value", 10)
                .Process();
            }
            var end = DateTime.UtcNow;

            double msOverheadPerCall =
                end.Subtract(start).TotalMilliseconds / iterations;

            Assert.IsTrue(msOverheadPerCall < 0.1,
                          $"Pipeline overhead per Process call was " +
                          $"{msOverheadPerCall}ms. Maximum permitted is 0.1ms");
        }
コード例 #2
0
        public void Init()
        {
            _cache = new Mock <IFlowCache>();

            _loggerFactory = new TestLoggerFactory();
            _engine        = new EmptyEngineBuilder(_loggerFactory)
                             .Build();
            _engine.SetCache(_cache.Object);
        }