From 0a8c2fd663c5c12d76360d8fa3ec33cb7b13028f Mon Sep 17 00:00:00 2001 From: filipecosta90 Date: Thu, 31 Oct 2019 17:12:44 +0000 Subject: [PATCH 1/2] [fix] conversion_ratio_bits type setted to c_double --- hdrh/codec.py | 3 ++- test/test_hdrhistogram.py | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hdrh/codec.py b/hdrh/codec.py index a3f38f8..e6f2e3b 100644 --- a/hdrh/codec.py +++ b/hdrh/codec.py @@ -35,6 +35,7 @@ from ctypes import c_ushort from ctypes import c_uint from ctypes import c_ulonglong +from ctypes import c_double import zlib @@ -98,7 +99,7 @@ class PayloadHeader(BigEndianStructure): ("significant_figures", c_uint), ("lowest_trackable_value", c_ulonglong), ("highest_trackable_value", c_ulonglong), - ("conversion_ratio_bits", c_ulonglong)] + ("conversion_ratio_bits", c_double)] payload_header_size = ctypes.sizeof(PayloadHeader) diff --git a/test/test_hdrhistogram.py b/test/test_hdrhistogram.py index 867d7a3..d5ccc2c 100644 --- a/test/test_hdrhistogram.py +++ b/test/test_hdrhistogram.py @@ -425,17 +425,17 @@ def check_hist_encode(word_size, ENCODE_ARG_LIST = ( # word size digits expected_compressed_length, fill_start%, fill_count% # best case when all counters are zero - (8, 3, 48, 0, 0), # V1=52 385 = size when compressing entire counts array - (8, 2, 48, 0, 0), # 126 + (8, 3, 52, 0, 0), # V1=52 385 = size when compressing entire counts array + (8, 2, 52, 0, 0), # 126 # typical case when all counters are aggregated in a small contiguous area - (8, 3, 15560, 30, 20), # V1=16452 - (8, 2, 1688, 30, 20), # V1=2096 + (8, 3, 15564, 30, 20), # V1=16452 + (8, 2, 1692, 30, 20), # V1=2096 # worst case when all counters are different (8, 3, 76892, 0, 100), # V1=80680 - (8, 2, 9340, 0, 100), # V1=10744 + (8, 2, 9344, 0, 100), # V1=10744 # worst case 32-bit and 16-bit counters (2, 3, 76892, 0, 100), # V1=68936 - (2, 2, 9340, 0, 100), # V1=9144 + (2, 2, 9344, 0, 100), # V1=9144 ) @pytest.mark.codec From 018f04fdc66b4952743e05f6e3df325dd97f17b3 Mon Sep 17 00:00:00 2001 From: filipecosta90 Date: Fri, 1 Nov 2019 00:10:27 +0000 Subject: [PATCH 2/2] [add] added getter for int_to_double_conversion_ratio. exteded test_jHiccup_v2_log() --- hdrh/histogram.py | 3 +++ test/test_hdrhistogram.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/hdrh/histogram.py b/hdrh/histogram.py index 8eb4951..a17a0a6 100644 --- a/hdrh/histogram.py +++ b/hdrh/histogram.py @@ -574,6 +574,9 @@ def decode(encoded_histogram, b64_wrap=True): def get_word_size(self): return self.word_size + def get_int_to_double_conversion_ratio(self): + return self.int_to_double_conversion_ratio + def output_percentile_distribution(self, out_file, output_value_unit_scaling_ratio, diff --git a/test/test_hdrhistogram.py b/test/test_hdrhistogram.py index d5ccc2c..469e92f 100644 --- a/test/test_hdrhistogram.py +++ b/test/test_hdrhistogram.py @@ -618,6 +618,8 @@ def test_jHiccup_v2_log(): accumulated_histogram.add(decoded_histogram) # These logs use 8 byte counters assert decoded_histogram.get_word_size() == 8 + # These logs use the default 1.0 conversion ratio + assert decoded_histogram.get_int_to_double_conversion_ratio() == 1.0 for statement in target_numbers: assert eval(statement) == target_numbers[statement]