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


Python Gauged.statistics方法代码示例

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


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

示例1: test_statistics

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import statistics [as 别名]
 def test_statistics(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000)
     with gauged.writer as writer:
         writer.add('bar', 123, timestamp=10000)
         writer.add('bar', 123, timestamp=15000, namespace=1)
         writer.add({'foo': 123, 'bar': 456}, timestamp=20000)
     stats = gauged.statistics()
     self.assertEqual(stats.data_points, 3)
     self.assertEqual(stats.byte_count, 24)
     stats = gauged.statistics(end=20000)
     # note: statistics() rounds to the nearest block boundary
     self.assertEqual(stats.data_points, 1)
     self.assertEqual(stats.byte_count, 8)
     stats = gauged.statistics(namespace=1)
     self.assertEqual(stats.data_points, 1)
     self.assertEqual(stats.byte_count, 8)
开发者ID:pyarnold,项目名称:gauged,代码行数:18,代码来源:test_gauged.py

示例2: test_no_data

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import statistics [as 别名]
 def test_no_data(self):
     gauged = Gauged(self.driver)
     self.assertEqual(len(gauged.namespaces()), 0)
     self.assertEqual(len(gauged.value_series('foo')), 0)
     self.assertEqual(len(gauged.aggregate_series('foo', Gauged.SUM)), 0)
     self.assertEqual(gauged.value('foo'), None)
     self.assertEqual(gauged.aggregate('foo', Gauged.SUM), None)
     self.assertEqual(len(gauged.keys()), 0)
     stats = gauged.statistics()
     for attr in ['data_points', 'byte_count']:
         self.assertEqual(getattr(stats, attr), 0)
开发者ID:pyarnold,项目名称:gauged,代码行数:13,代码来源:test_gauged.py

示例3: test_accepting_data_as_string

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import statistics [as 别名]
 def test_accepting_data_as_string(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000,
         key_overflow=Gauged.IGNORE, gauge_nan=Gauged.IGNORE)
     with gauged.writer as writer:
         writer.add('foo=123.456&bar=-15.98&qux=0&invalid=foobar\n', timestamp=20000)
     self.assertAlmostEqual(123.456, gauged.value('foo', timestamp=20000), 5)
     self.assertAlmostEqual(-15.98, gauged.value('bar', timestamp=20000), 5)
     self.assertEqual(gauged.value('qux', timestamp=20000), 0)
     self.assertEqual(gauged.value('invalid', timestamp=20000), None)
     stats = gauged.statistics()
     self.assertEqual(stats.data_points, 3)
     self.assertEqual(stats.byte_count, 24)
     stats = gauged.statistics(end=25000)
     self.assertEqual(stats.data_points, 3)
     self.assertEqual(stats.byte_count, 24)
     gauged = Gauged(self.driver, resolution=1000, block_size=10000,
         key_overflow=Gauged.IGNORE)
     with self.assertRaises(GaugedNaNError):
         with gauged.writer as writer:
             writer.add(u'foo=123.456&bar=-15.98&qux=0&invalid=foobar\n', timestamp=20000)
开发者ID:lessc0de,项目名称:gauged,代码行数:22,代码来源:test_gauged.py

示例4: time

# 需要导入模块: from gauged import Gauged [as 别名]
# 或者: from gauged.Gauged import statistics [as 别名]
measurements = options['number']
span = end_timestamp - start_timestamp
start = time()
with gauged.writer as writer:
    data = ['foobar', 0]
    gauges = [data]
    add = writer.add
    for timestamp in xrange(start_timestamp, end_timestamp,
                            span // measurements):
        data[1] = random()
        add(gauges, timestamp=timestamp*1000)
elapsed = time() - start

print 'Wrote %s measurements in %s seconds (%s/s)' % \
    (number, round(elapsed, 3), abbreviate_number(measurements / elapsed))

statistics = gauged.statistics()
byte_count = statistics.byte_count
print 'Gauge data uses %s (%s per measurement)' % \
    (abbreviate_bytes(byte_count),
     abbreviate_bytes(byte_count / float(measurements)))

# Read benchmarks
for aggregate in ('min', 'max', 'sum', 'count', 'mean', 'stddev', 'median'):
    start = time()
    gauged.aggregate('foobar', aggregate)
    elapsed = time() - start
    print '%s() in %ss (read %s measurements/s)' % \
        (aggregate, round(elapsed, 3),
         abbreviate_number(measurements / elapsed))
开发者ID:chriso,项目名称:gauged,代码行数:32,代码来源:benchmark.py


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