当前位置: 首页>>代码示例>>C#>>正文


C# ActionBlock.WaitUntilAllItemsProcessed方法代码示例

本文整理汇总了C#中ActionBlock.WaitUntilAllItemsProcessed方法的典型用法代码示例。如果您正苦于以下问题:C# ActionBlock.WaitUntilAllItemsProcessed方法的具体用法?C# ActionBlock.WaitUntilAllItemsProcessed怎么用?C# ActionBlock.WaitUntilAllItemsProcessed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActionBlock的用法示例。


在下文中一共展示了ActionBlock.WaitUntilAllItemsProcessed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteOneLatency_OneMetricFlushed_Success

    public void WriteOneLatency_OneMetricFlushed_Success()
    {
      _block = TimedLatencyAggregatorBlockFactory.CreateBlock(_outputBuffer,
        String.Empty,
        _intervalService,
        true,
        _log.Object);
      var pulseDate = DateTime.Now;

      _block.Post(new Timing("foo.bar.baz", 100));
      _block.WaitUntilAllItemsProcessed();
      _intervalService.Pulse(pulseDate);

      Assert.AreEqual(new GraphiteLine("foo.bar.baz.count", 1, pulseDate.ToEpoch()),_outputBuffer.GetGraphiteLine(0));
      Assert.AreEqual(new GraphiteLine("foo.bar.baz.min", 100, pulseDate.ToEpoch()), _outputBuffer.GetGraphiteLine(1));
      Assert.AreEqual(new GraphiteLine("foo.bar.baz.max", 100, pulseDate.ToEpoch()), _outputBuffer.GetGraphiteLine(2));
      Assert.AreEqual(new GraphiteLine("foo.bar.baz.mean", 100, pulseDate.ToEpoch()), _outputBuffer.GetGraphiteLine(3));
      Assert.AreEqual(new GraphiteLine("foo.bar.baz.sum", 100, pulseDate.ToEpoch()), _outputBuffer.GetGraphiteLine(4));
      Assert.AreEqual(new GraphiteLine("foo.bar.baz.sumSquares", 10000, pulseDate.ToEpoch()), _outputBuffer.GetGraphiteLine(5));
      Assert.AreEqual(6, _outputBuffer.GraphiteLines.Count);
      // Ensure that min, max, mean and sum are all equal
      Assert.IsTrue(_outputBuffer.GetGraphiteLine(1).Quantity == _outputBuffer.GetGraphiteLine(2).Quantity 
        && _outputBuffer.GetGraphiteLine(2).Quantity == _outputBuffer.GetGraphiteLine(3).Quantity
        && _outputBuffer.GetGraphiteLine(3).Quantity == _outputBuffer.GetGraphiteLine(4).Quantity);
    }
开发者ID:houcine,项目名称:statsd.net,代码行数:25,代码来源:TimedLatencyAggregatorBlockTests.cs

示例2: WriteOneHunderedLatencies_p90PercentileLogged_Success

    public void WriteOneHunderedLatencies_p90PercentileLogged_Success()
    {
      _block = TimedLatencyPercentileAggregatorBlockFactory.CreateBlock(_outputBuffer,
        String.Empty,
        _intervalService,
        90,
        null,
        _log.Object);

      TestUtility.Range(100, false).ForEach(p => _block.Post(new Timing("foo", p)));
      _block.WaitUntilAllItemsProcessed();
      _intervalService.Pulse();

      Assert.AreEqual(90, _outputBuffer["foo.p90"]);
    }
开发者ID:houcine,项目名称:statsd.net,代码行数:15,代码来源:TimedLatencyPercentileAggregatorBlockTests.cs

示例3: WriteFourLatencies_PercentileLogged_Success

    public void WriteFourLatencies_PercentileLogged_Success()
    {
      _block = TimedLatencyPercentileAggregatorBlockFactory.CreateBlock(_outputBuffer,
        String.Empty,
        _intervalService,
        90,
        null,
        _log.Object);

      _block.Post(new Timing("foo", 100));
      _block.Post(new Timing("foo", 200));
      _block.Post(new Timing("foo", 300));
      _block.Post(new Timing("foo", 400));
      _block.WaitUntilAllItemsProcessed();
      _intervalService.Pulse();

      Assert.IsTrue(_outputBuffer.GraphiteLines.Any(p => p.Name == "foo.p90"));
      Assert.AreEqual(400, _outputBuffer["foo.p90"]);
    }
开发者ID:houcine,项目名称:statsd.net,代码行数:19,代码来源:TimedLatencyPercentileAggregatorBlockTests.cs

示例4: WriteTwoLatencies_CalulateMinMaxMeanSum_Success

    public void WriteTwoLatencies_CalulateMinMaxMeanSum_Success()
    {
      _block = TimedLatencyAggregatorBlockFactory.CreateBlock(_outputBuffer,
        String.Empty,
        _intervalService,
        true,
        _log.Object);
      var pulseDate = DateTime.Now;

      _block.Post(new Timing("foo", 5));
      _block.Post(new Timing("foo", 15));
      _block.WaitUntilAllItemsProcessed();
      _intervalService.Pulse(pulseDate);

      Assert.AreEqual(15, _outputBuffer["foo.max"]);
      Assert.AreEqual(5, _outputBuffer["foo.min"]);
      Assert.AreEqual(10, _outputBuffer["foo.mean"]);
      Assert.AreEqual(2, _outputBuffer["foo.count"]);
      Assert.AreEqual(20, _outputBuffer["foo.sum"]);
    }
开发者ID:joshclark,项目名称:statsd.net,代码行数:20,代码来源:TimedLatencyAggregatorBlockTests.cs

示例5: WriteLatenciesToTwoBuckets_MeasurementsSeparate_Success

    public void WriteLatenciesToTwoBuckets_MeasurementsSeparate_Success()
    {
      _block = TimedLatencyPercentileAggregatorBlockFactory.CreateBlock(_outputBuffer,
        String.Empty,
        _intervalService,
        80,
        null,
        _log.Object);
      var pulseDate = DateTime.Now;

      // Bucket one
      TestUtility.Range(5, false).ForEach(p => _block.Post(new Timing("foo", p * 100)));
      // Bucket two
      TestUtility.Range(5, false).ForEach(p => _block.Post(new Timing("bar", p * 100)));
      _block.WaitUntilAllItemsProcessed();
      _intervalService.Pulse(pulseDate);

      Assert.AreEqual(400, _outputBuffer["foo.p80"]);
      Assert.AreEqual(400, _outputBuffer["bar.p80"]);
      Assert.AreEqual(1, _outputBuffer.Items.Count);
    }
开发者ID:houcine,项目名称:statsd.net,代码行数:21,代码来源:TimedLatencyPercentileAggregatorBlockTests.cs

示例6: WriteLatenciesToTwoBuckets_MeasurementsSeparate_Success

    public void WriteLatenciesToTwoBuckets_MeasurementsSeparate_Success()
    {
      _block = TimedLatencyAggregatorBlockFactory.CreateBlock(_outputBuffer,
        String.Empty,
        _intervalService,
        true,
        _log.Object);
      var pulseDate = DateTime.Now;

      // Bucket one
      TestUtility.Range(5, false).ForEach(p => _block.Post(new Timing("foo", p * 100)));
      // Bucket two
      TestUtility.Range(5, false).ForEach(p => _block.Post(new Timing("bar", p * 100)));
      _block.WaitUntilAllItemsProcessed();
      _intervalService.Pulse(pulseDate);

      Assert.AreEqual(5, _outputBuffer["foo.count"]);
      Assert.AreEqual(100, _outputBuffer["foo.min"]);
      Assert.AreEqual(500, _outputBuffer["foo.max"]);
      Assert.AreEqual(300, _outputBuffer["foo.mean"]);
      Assert.AreEqual(1500, _outputBuffer["foo.sum"]);
      Assert.AreEqual(550000, _outputBuffer["foo.sumSquares"]);

      Assert.AreEqual(5, _outputBuffer["bar.count"]);
      Assert.AreEqual(100, _outputBuffer["bar.min"]);
      Assert.AreEqual(500, _outputBuffer["bar.max"]);
      Assert.AreEqual(300, _outputBuffer["bar.mean"]);
      Assert.AreEqual(1500, _outputBuffer["bar.sum"]);
      Assert.AreEqual(550000, _outputBuffer["bar.sumSquares"]);

      Assert.AreEqual(12, _outputBuffer.GraphiteLines.Count);
    }
开发者ID:houcine,项目名称:statsd.net,代码行数:32,代码来源:TimedLatencyAggregatorBlockTests.cs


注:本文中的ActionBlock.WaitUntilAllItemsProcessed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。