本文整理汇总了Python中hdrh.histogram.HdrHistogram.encode方法的典型用法代码示例。如果您正苦于以下问题:Python HdrHistogram.encode方法的具体用法?Python HdrHistogram.encode怎么用?Python HdrHistogram.encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hdrh.histogram.HdrHistogram
的用法示例。
在下文中一共展示了HdrHistogram.encode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_cod_perf
# 需要导入模块: from hdrh.histogram import HdrHistogram [as 别名]
# 或者: from hdrh.histogram.HdrHistogram import encode [as 别名]
def check_cod_perf():
histogram = HdrHistogram(LOWEST, WRK2_MAX_LATENCY, 2)
fill_start_index = (20 * histogram.counts_len) // 100
fill_to_index = fill_start_index + (30 * histogram.counts_len) // 100
fill_hist_counts(histogram, fill_to_index, fill_start_index)
# encode 1000 times
start = datetime.datetime.now()
for _ in range(1000):
histogram.encode()
delta = datetime.datetime.now() - start
print(delta)
示例2: check_hist_codec_b64
# 需要导入模块: from hdrh.histogram import HdrHistogram [as 别名]
# 或者: from hdrh.histogram.HdrHistogram import encode [as 别名]
def check_hist_codec_b64(word_size, b64_wrap):
histogram = HdrHistogram(LOWEST, WRK2_MAX_LATENCY, SIGNIFICANT,
b64_wrap=b64_wrap,
word_size=word_size)
# encode with all zero counters
encoded = histogram.encode()
# add back same histogram
histogram.decode_and_add(encoded)
# counters should remain zero
check_hist_counts(histogram, histogram.counts_len, multiplier=0)
# fill up the histogram
fill_hist_counts(histogram, histogram.counts_len)
encoded = histogram.encode()
histogram.decode_and_add(encoded)
check_hist_counts(histogram, histogram.counts_len, multiplier=2)
示例3: encode_bins
# 需要导入模块: from hdrh.histogram import HdrHistogram [as 别名]
# 或者: from hdrh.histogram.HdrHistogram import encode [as 别名]
def encode_bins(self, p_output):
p_output = json.loads(p_output)
p_output['jobs'][0].pop('trim')
test_list = ['read', 'write']
for test in test_list:
histogram = HdrHistogram(1, 5 * 3600 * 1000, 3)
clat = p_output['jobs'][0][test]['clat']['bins']
total_buckets = clat['FIO_IO_U_PLAT_NR']
grp_msb_bits = clat['FIO_IO_U_PLAT_BITS']
buckets_per_grp = clat['FIO_IO_U_PLAT_VAL']
for bucket in xrange(total_buckets):
if clat[str(bucket)]:
grp = bucket / buckets_per_grp
subbucket = bucket % buckets_per_grp
if grp == 0:
val = subbucket - 1
else:
base = 2 ** (grp_msb_bits + grp - 1)
val = int(base + (base / buckets_per_grp) * (subbucket - 0.5))
histogram.record_value(val, clat[str(bucket)])
p_output['jobs'][0][test]['clat']['hist'] = histogram.encode()
p_output['jobs'][0][test]['clat'].pop('bins')
p_output['jobs'][0][test]['clat'].pop('percentile')
return json.dumps(p_output)
示例4: check_dec_perf
# 需要导入模块: from hdrh.histogram import HdrHistogram [as 别名]
# 或者: from hdrh.histogram.HdrHistogram import encode [as 别名]
def check_dec_perf():
histogram = HdrHistogram(LOWEST, WRK2_MAX_LATENCY, 2)
fill_start_index = (20 * histogram.counts_len) // 100
fill_to_index = fill_start_index + (30 * histogram.counts_len) // 100
fill_hist_counts(histogram, fill_to_index, fill_start_index)
b64 = histogram.encode()
# decode and add to self 1000 times
start = datetime.datetime.now()
for _ in range(1000):
histogram.decode_and_add(b64)
delta = datetime.datetime.now() - start
print(delta)
示例5: check_hist_encode
# 需要导入模块: from hdrh.histogram import HdrHistogram [as 别名]
# 或者: from hdrh.histogram.HdrHistogram import encode [as 别名]
def check_hist_encode(word_size,
digits,
expected_compressed_length,
fill_start_percent,
fill_count_percent):
histogram = HdrHistogram(LOWEST, WRK2_MAX_LATENCY, digits,
word_size=word_size)
if fill_count_percent:
fill_start_index = (fill_start_percent * histogram.counts_len) // 100
fill_to_index = fill_start_index + (fill_count_percent * histogram.counts_len) // 100
fill_hist_counts(histogram, fill_to_index, fill_start_index)
b64 = histogram.encode()
assert(len(b64) == expected_compressed_length)
示例6: test_hist_codec_partial
# 需要导入模块: from hdrh.histogram import HdrHistogram [as 别名]
# 或者: from hdrh.histogram.HdrHistogram import encode [as 别名]
def test_hist_codec_partial():
histogram = HdrHistogram(LOWEST, WRK2_MAX_LATENCY, SIGNIFICANT)
partial_histogram = HdrHistogram(LOWEST, WRK2_MAX_LATENCY, SIGNIFICANT)
# put some known numbers in the first half buckets
half_count = partial_histogram.counts_len
fill_hist_counts(partial_histogram, half_count)
encoded = partial_histogram.encode()
histogram.decode_and_add(encoded)
# now verify that the partial counters are identical to the original
check_hist_counts(histogram, half_count, multiplier=1)
check_hist_counts(histogram, histogram.counts_len, start=half_count + 1, multiplier=0)