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


Python gauged.Gauged类代码示例

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


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

示例1: test_rewrite_append_only_violation

 def test_rewrite_append_only_violation(self):
     gauged = Gauged(self.driver, append_only_violation=Gauged.REWRITE)
     with gauged.writer as writer:
         writer.add('foo', 123, timestamp=2000)
         writer.add('foo', 456, timestamp=1000)
     self.assertEqual(gauged.value('foo', timestamp=1000), None)
     self.assertEqual(gauged.value('foo', timestamp=2000), 456)
开发者ID:pyarnold,项目名称:gauged,代码行数:7,代码来源:test_gauged.py

示例2: test_ignore_append_only_violation

 def test_ignore_append_only_violation(self):
     gauged = Gauged(self.driver, append_only_violation=Gauged.IGNORE)
     with gauged.writer as writer:
         writer.add('foo', 123, timestamp=2000)
         writer.add('foo', 456, timestamp=1000)
     self.assertIsNone(gauged.value('foo', timestamp=1000))
     self.assertEqual(gauged.value('foo', timestamp=2000), 123)
开发者ID:chriso,项目名称:gauged,代码行数:7,代码来源:test_gauged.py

示例3: test_version_mismatch

 def test_version_mismatch(self):
     self.driver.set_metadata({'current_version': 'foo'})
     gauged = Gauged(self.driver)
     with self.assertRaises(GaugedVersionMismatchError):
         with gauged.writer:
             pass
     gauged.migrate()
开发者ID:pyarnold,项目名称:gauged,代码行数:7,代码来源:test_gauged.py

示例4: test_append_only_violation

 def test_append_only_violation(self):
     gauged = Gauged(self.driver)
     with gauged.writer as writer:
         writer.add('foo', 123, timestamp=2000)
         with self.assertRaises(GaugedAppendOnlyError):
             writer.add('foo', 456, timestamp=1000)
     self.assertEqual(gauged.value('foo', timestamp=1000), None)
     self.assertEqual(gauged.value('foo', timestamp=2000), 123)
开发者ID:pyarnold,项目名称:gauged,代码行数:8,代码来源:test_gauged.py

示例5: test_look_behind

 def test_look_behind(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000, max_look_behind=10000)
     with gauged.writer as writer:
         writer.add('foo', 123, timestamp=10000)
         writer.add('bar', 123, timestamp=40000)
     self.assertEqual(gauged.value('foo', timestamp=10000), 123)
     self.assertEqual(gauged.value('foo', timestamp=20000), 123)
     self.assertEqual(gauged.value('foo', timestamp=30000), None)
开发者ID:lessc0de,项目名称:gauged,代码行数:8,代码来源:test_gauged.py

示例6: test_config_instance

 def test_config_instance(self):
     config = Config(append_only_violation=Gauged.REWRITE,
                     resolution=1000, block_size=10000)
     gauged = Gauged(self.driver, config=config)
     with gauged.writer as writer:
         writer.add('foo', 1, timestamp=2000)
         writer.add('foo', 2, timestamp=1000)
     self.assertEqual(gauged.value('foo', timestamp=2000), 2)
开发者ID:pyarnold,项目名称:gauged,代码行数:8,代码来源:test_gauged.py

示例7: test_coercing_non_string_keys

 def test_coercing_non_string_keys(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000)
     with gauged.writer as writer:
         writer.add(1234, 100, timestamp=10000)
         writer.add(True, 100, timestamp=10000)
         writer.add(u'foo', 100, timestamp=10000)
     self.assertEqual(gauged.value('1234', timestamp=10000), 100)
     self.assertEqual(gauged.value('True', timestamp=10000), 100)
     self.assertEqual(gauged.value('foo', timestamp=10000), 100)
开发者ID:pyarnold,项目名称:gauged,代码行数:9,代码来源:test_gauged.py

示例8: test_block_slicing

 def test_block_slicing(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000)
     with gauged.writer as writer:
         writer.add('foo', 100, timestamp=11000)
         writer.add('foo', 200, timestamp=23000)
     self.assertEqual(gauged.aggregate('foo', Gauged.MEAN, start=10000, end=30000), 150)
     self.assertEqual(gauged.aggregate('foo', Gauged.MEAN, start=11000, end=24000), 150)
     self.assertEqual(gauged.aggregate('foo', Gauged.MEAN, start=11000, end=23000), 100)
     self.assertEqual(gauged.aggregate('foo', Gauged.STDDEV, start=11000, end=23000), 0)
开发者ID:lessc0de,项目名称:gauged,代码行数:9,代码来源:test_gauged.py

示例9: test_context_defaults

 def test_context_defaults(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000)
     with gauged.writer as writer:
         writer.add('bar', 123, timestamp=10000)
         writer.add('foo', 456, timestamp=20000)
     self.assertEqual(gauged.keys(), ['bar', 'foo'])
     gauged = Gauged(self.driver, resolution=1000, block_size=10000,
                     defaults={'limit': 1})
     self.assertEqual(gauged.keys(), ['bar'])
开发者ID:chriso,项目名称:gauged,代码行数:9,代码来源:test_gauged.py

示例10: test_gauge_nan

 def test_gauge_nan(self):
     gauged = Gauged(self.driver, block_size=50000)
     with gauged.writer as writer:
         with self.assertRaises(GaugedNaNError):
             writer.add('foobar', 'baz')
     self.assertEqual(gauged.value('foobar'), None)
     gauged = Gauged(self.driver, block_size=50000, gauge_nan=Gauged.IGNORE)
     with gauged.writer as writer:
         writer.add('foobar', 'baz')
     self.assertEqual(gauged.value('foobar'), None)
开发者ID:pyarnold,项目名称:gauged,代码行数:10,代码来源:test_gauged.py

示例11: test_flush_flushes_last_complete_block

 def test_flush_flushes_last_complete_block(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000)
     with gauged.writer as writer:
         writer.add('foo', 1, timestamp=1000)
         writer.add('foo', 2, timestamp=2000)
         writer.add('foo', 3, timestamp=3000)
         self.assertEqual(gauged.value('foo', timestamp=3000), None)
         writer.flush()
         self.assertEqual(gauged.value('foo', timestamp=3000), 2)
     self.assertEqual(gauged.value('foo', timestamp=3000), 3)
开发者ID:pyarnold,项目名称:gauged,代码行数:10,代码来源:test_gauged.py

示例12: test_add_debug

 def test_add_debug(self):
     context = dict(called=False)
     gauged = Gauged(self.driver)
     def mock_debug(*_):
         context['called'] = True
     with gauged.writer as writer:
         writer.debug = mock_debug
         writer.add('foo', 123, timestamp=10000, debug=True)
         writer.add('foo=123', timestamp=10000, debug=True)
     self.assertEqual(gauged.value('foo', timestamp=10000), None)
     self.assertTrue(context['called'])
开发者ID:lessc0de,项目名称:gauged,代码行数:11,代码来源:test_gauged.py

示例13: test_relative_dates

 def test_relative_dates(self):
     now = long(time() * 1000)
     gauged = Gauged(self.driver, defaults={'start': -4 * Gauged.DAY})
     with gauged.writer as writer:
         writer.add('foo', 1, timestamp=now - 6 * Gauged.DAY)
         writer.add('foo', 2, timestamp=now - 5 * Gauged.DAY)
         writer.add('foo', 3, timestamp=now - 3 * Gauged.DAY)
         writer.add('foo', 4, timestamp=now - 2 * Gauged.DAY)
         writer.add('foo', 5, timestamp=now - Gauged.DAY)
     self.assertEqual(gauged.value('foo'), 5)
     self.assertEqual(gauged.value('foo', timestamp=-1.5 * Gauged.DAY), 4)
开发者ID:pyarnold,项目名称:gauged,代码行数:11,代码来源:test_gauged.py

示例14: test_interim_flushing

 def test_interim_flushing(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000)
     with gauged.writer as writer:
         writer.add('foo', 123, timestamp=1000)
         writer.flush()
         writer.add('bar', 456, timestamp=2000)
         writer.flush()
         writer.add('baz', 789, timestamp=10000)
     self.assertEqual(gauged.value('foo', timestamp=10000), 123)
     self.assertEqual(gauged.value('bar', timestamp=10000), 456)
     self.assertEqual(gauged.value('baz', timestamp=10000), 789)
开发者ID:pyarnold,项目名称:gauged,代码行数:11,代码来源:test_gauged.py

示例15: test_auto_flush

 def test_auto_flush(self):
     gauged = Gauged(self.driver, resolution=1000, block_size=10000, flush_seconds=0.001)
     with gauged.writer as writer:
         writer.add('foo', 1, timestamp=1000)
         self.assertEqual(gauged.value('foo', timestamp=2000), None)
         sleep(0.002)
         self.assertEqual(gauged.value('foo', timestamp=2000), None)
         # note: the next write triggers the flush() of all prior writes
         writer.add('foo', 2, timestamp=2000)
         sleep(0.002)
         self.assertEqual(gauged.value('foo', timestamp=2000), 1)
     self.assertEqual(gauged.value('foo', timestamp=2000), 2)
开发者ID:lessc0de,项目名称:gauged,代码行数:12,代码来源:test_gauged.py


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