HDRHistogram 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc890bb97e2d8e3df9318ebeadbdfe33f3593b5ce2ca8afaef123c7876c0cb12
4
- data.tar.gz: 4e26dd8585aafc0edc028b31ab0185c8397a95897062aa203fc0a2b8f1cc3839
3
+ metadata.gz: c6bc83dd9876e1ee8fce3a8aab6c3a19c3cdab9013362b2b0e478932709f0213
4
+ data.tar.gz: 662746096a757ea07856c7d560b60c005d80a2a7fff4ffda8582dd791263ea09
5
5
  SHA512:
6
- metadata.gz: 46b8dc766bb51cc69508309b60c9821907f95d14a1564fcca4cbd1447347a02afea2d8cabd6dce41cd40f85ac8e23f8d73020096a821bcc78c8430d3bdc265e9
7
- data.tar.gz: dd38b0453460d01acebaf66c4f6898e9a1f12514cc3ca24dab51c6c76c83f38629f738d3352959cc394c280745106173ae513ef7a58cabc6913d0d0374bdfef4
6
+ metadata.gz: 14b8a27b28b4fda00fbb1f9571c7d086477534b15ec5ac6037a53a7d99b290440252c814d701376b1d87a2f04f5195890e06f2570b39174b457d6c172392658f
7
+ data.tar.gz: d870f490a37cc05d3fa49af17d98e879cb4b8415efbe3cfb3e373aace2079949f30c273dfd533731d00a178dc25a08befbb8d28bcd4d7ee4f1d538dc18233926
@@ -2,6 +2,8 @@ require "HDRHistogram/version"
2
2
  require "ruby_hdr_histogram"
3
3
 
4
4
  class HDRHistogram
5
+ class UnserializeError < StandardError
6
+ end
5
7
  def initialize(lowest, highest, sig, opt={})
6
8
  @multiplier = opt[:multiplier] || 1
7
9
  @unit = opt[:unit] || opt[:units]
@@ -93,12 +95,18 @@ class HDRHistogram
93
95
  end
94
96
  private_class_method :adjusted_boundary_val
95
97
 
96
- def self.unserialize(str)
98
+ def self.unserialize(str, opt={})
97
99
  regex = /^(?<lowest_trackable_value>\d+) (?<highest_trackable_value>\d+) (?<unit_magnitude>\d+) (?<significant_figures>\d+) (?<sub_bucket_half_count_magnitude>\d+) (?<sub_bucket_half_count>\d+) (?<sub_bucket_mask>\d+) (?<sub_bucket_count>\d+) (?<bucket_count>\d+) (?<min_value>\d+) (?<max_value>\d+) (?<normalizing_index_offset>\d+) (?<conversion_ratio>\S+) (?<counts_len>\d+) (?<total_count>\d+) \[(?<counts>[\d~ ]+)\s\]/
98
100
 
99
101
  m = str.match regex
100
102
 
101
- hdrh = self.new(m[:lowest_trackable_value].to_i, m[:highest_trackable_value].to_i, m[:significant_figures].to_i, {unserialized: m})
103
+ raise UnserializeError, "invalid serialization pattern" if m.nil?
104
+
105
+ opt[:unserialized]=m
106
+
107
+ low = m[:lowest_trackable_value].to_i * (opt[:multiplier] || 1)
108
+ high = m[:highest_trackable_value].to_i * (opt[:multiplier] || 1)
109
+ hdrh = self.new(low, high, m[:significant_figures].to_i, opt)
102
110
 
103
111
  return hdrh
104
112
  end
@@ -1,3 +1,3 @@
1
1
  class HDRHistogram
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: HDRHistogram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo P.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-24 00:00:00.000000000 Z
11
+ date: 2018-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler