HDRHistogram 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/ext/ruby_hdr_histogram/ruby_hdr_histogram.c +51 -1
- data/lib/HDRHistogram.rb +40 -0
- data/lib/HDRHistogram/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fc890bb97e2d8e3df9318ebeadbdfe33f3593b5ce2ca8afaef123c7876c0cb12
|
4
|
+
data.tar.gz: 4e26dd8585aafc0edc028b31ab0185c8397a95897062aa203fc0a2b8f1cc3839
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46b8dc766bb51cc69508309b60c9821907f95d14a1564fcca4cbd1447347a02afea2d8cabd6dce41cd40f85ac8e23f8d73020096a821bcc78c8430d3bdc265e9
|
7
|
+
data.tar.gz: dd38b0453460d01acebaf66c4f6898e9a1f12514cc3ca24dab51c6c76c83f38629f738d3352959cc394c280745106173ae513ef7a58cabc6913d0d0374bdfef4
|
@@ -109,6 +109,29 @@ static VALUE histogram_##int_name(VALUE self) { \
|
|
109
109
|
return INT2NUM(hdr->int_name); \
|
110
110
|
}
|
111
111
|
|
112
|
+
#define HISTOGRAM_SETNUM_METHOD(num_name, num_type) \
|
113
|
+
static VALUE histogram_set_##num_name(VALUE self, VALUE num) { \
|
114
|
+
GET_HDRHIST(hdr, self); \
|
115
|
+
hdr->num_name = NUM2##num_type(num); \
|
116
|
+
return Qtrue; \
|
117
|
+
}
|
118
|
+
|
119
|
+
HISTOGRAM_SETNUM_METHOD(lowest_trackable_value, LL)
|
120
|
+
HISTOGRAM_SETNUM_METHOD(highest_trackable_value, LL)
|
121
|
+
HISTOGRAM_SETNUM_METHOD(unit_magnitude, LONG)
|
122
|
+
HISTOGRAM_SETNUM_METHOD(significant_figures, LONG)
|
123
|
+
HISTOGRAM_SETNUM_METHOD(sub_bucket_half_count_magnitude, LONG)
|
124
|
+
HISTOGRAM_SETNUM_METHOD(sub_bucket_half_count, LONG)
|
125
|
+
HISTOGRAM_SETNUM_METHOD(sub_bucket_mask, LL)
|
126
|
+
HISTOGRAM_SETNUM_METHOD(sub_bucket_count, LONG)
|
127
|
+
HISTOGRAM_SETNUM_METHOD(bucket_count, LONG)
|
128
|
+
HISTOGRAM_SETNUM_METHOD(min_value, LL)
|
129
|
+
HISTOGRAM_SETNUM_METHOD(max_value, LL)
|
130
|
+
HISTOGRAM_SETNUM_METHOD(normalizing_index_offset, LONG)
|
131
|
+
HISTOGRAM_SETNUM_METHOD(conversion_ratio, DBL)
|
132
|
+
HISTOGRAM_SETNUM_METHOD(counts_len, LONG)
|
133
|
+
HISTOGRAM_SETNUM_METHOD(total_count, LL)
|
134
|
+
|
112
135
|
HISTOGRAM_GETINT_METHOD(lowest_trackable_value)
|
113
136
|
HISTOGRAM_GETINT_METHOD(highest_trackable_value)
|
114
137
|
HISTOGRAM_GETINT_METHOD(unit_magnitude)
|
@@ -117,6 +140,14 @@ HISTOGRAM_GETINT_METHOD(bucket_count)
|
|
117
140
|
HISTOGRAM_GETINT_METHOD(sub_bucket_count)
|
118
141
|
HISTOGRAM_GETINT_METHOD(counts_len)
|
119
142
|
|
143
|
+
static VALUE histogram_set_raw_count(VALUE self, VALUE index, VALUE count) {
|
144
|
+
GET_HDRHIST(hdr, self);
|
145
|
+
int i = NUM2INT(index);
|
146
|
+
int64_t c = NUM2LL(count);
|
147
|
+
hdr->counts[i]=c;
|
148
|
+
return Qtrue;
|
149
|
+
}
|
150
|
+
|
120
151
|
void Init_ruby_hdr_histogram() {
|
121
152
|
HDRHistogram = rb_define_class("HDRHistogram", rb_cObject);
|
122
153
|
HDRHistogramError = rb_define_class_under(HDRHistogram, "HDRHistogramError", rb_eRuntimeError);
|
@@ -138,15 +169,34 @@ void Init_ruby_hdr_histogram() {
|
|
138
169
|
rb_define_private_method(HDRHistogram, "raw_percentile", histogram_percentile, 1);
|
139
170
|
rb_define_private_method(HDRHistogram, "raw_merge", histogram_merge, 1);
|
140
171
|
|
172
|
+
rb_define_private_method(HDRHistogram, "lowest_trackable_value=", histogram_set_lowest_trackable_value, 1);
|
173
|
+
rb_define_private_method(HDRHistogram, "highest_trackable_value=", histogram_set_highest_trackable_value, 1);
|
174
|
+
rb_define_private_method(HDRHistogram, "unit_magnitude=", histogram_set_unit_magnitude, 1);
|
175
|
+
rb_define_private_method(HDRHistogram, "significant_figures=", histogram_set_significant_figures, 1);
|
176
|
+
rb_define_private_method(HDRHistogram, "sub_bucket_half_count_magnitude=", histogram_set_sub_bucket_half_count_magnitude, 1);
|
177
|
+
rb_define_private_method(HDRHistogram, "sub_bucket_half_count=", histogram_set_sub_bucket_half_count, 1);
|
178
|
+
rb_define_private_method(HDRHistogram, "sub_bucket_mask=", histogram_set_sub_bucket_mask, 1);
|
179
|
+
rb_define_private_method(HDRHistogram, "sub_bucket_count=", histogram_set_sub_bucket_count, 1);
|
180
|
+
rb_define_private_method(HDRHistogram, "bucket_count=", histogram_set_bucket_count, 1);
|
181
|
+
rb_define_private_method(HDRHistogram, "min_value=", histogram_set_min_value, 1);
|
182
|
+
rb_define_private_method(HDRHistogram, "max_value=", histogram_set_max_value, 1);
|
183
|
+
rb_define_private_method(HDRHistogram, "normalizing_index_offset=", histogram_set_normalizing_index_offset, 1);
|
184
|
+
rb_define_private_method(HDRHistogram, "conversion_ratio=", histogram_set_conversion_ratio, 1);
|
185
|
+
rb_define_private_method(HDRHistogram, "counts_len=", histogram_set_counts_len, 1);
|
186
|
+
rb_define_private_method(HDRHistogram, "total_count=", histogram_set_total_count, 1);
|
187
|
+
rb_define_private_method(HDRHistogram, "set_raw_count", histogram_set_raw_count, 2);
|
141
188
|
|
142
189
|
rb_define_method(HDRHistogram, "lowest_trackable_value", histogram_lowest_trackable_value, 0);
|
143
190
|
rb_define_method(HDRHistogram, "highest_trackable_value", histogram_highest_trackable_value, 0);
|
144
191
|
rb_define_private_method(HDRHistogram, "unit_magnitude", histogram_unit_magnitude, 0);
|
145
192
|
rb_define_method(HDRHistogram, "significant_figures", histogram_significant_figures, 0);
|
146
193
|
rb_define_private_method(HDRHistogram, "bucket_count", histogram_bucket_count, 0);
|
147
|
-
rb_define_private_method(HDRHistogram, "sub_bucket_count",
|
194
|
+
rb_define_private_method(HDRHistogram, "sub_bucket_count", histogram_sub_bucket_count, 0);
|
148
195
|
rb_define_private_method(HDRHistogram, "counts_len", histogram_counts_len, 0);
|
149
196
|
|
197
|
+
|
198
|
+
rb_define_private_method(HDRHistogram, "unit_magnitude", histogram_unit_magnitude, 0);
|
199
|
+
|
150
200
|
//rb_define_private_method(HDRHistogram, "histogram_spectrum", histogram_spectrum, 2);
|
151
201
|
}
|
152
202
|
|
data/lib/HDRHistogram.rb
CHANGED
@@ -5,6 +5,37 @@ class HDRHistogram
|
|
5
5
|
def initialize(lowest, highest, sig, opt={})
|
6
6
|
@multiplier = opt[:multiplier] || 1
|
7
7
|
@unit = opt[:unit] || opt[:units]
|
8
|
+
|
9
|
+
if opt[:unserialized]
|
10
|
+
m=opt[:unserialized]
|
11
|
+
self.unit_magnitude= m[:unit_magnitude].to_i
|
12
|
+
self.sub_bucket_half_count_magnitude= m[:sub_bucket_half_count_magnitude].to_i
|
13
|
+
self.sub_bucket_half_count= m[:sub_bucket_half_count].to_i
|
14
|
+
self.sub_bucket_mask= m[:sub_bucket_mask].to_i
|
15
|
+
self.sub_bucket_count= m[:sub_bucket_count].to_i
|
16
|
+
self.bucket_count= m[:bucket_count].to_i
|
17
|
+
self.min_value= m[:min_value].to_i
|
18
|
+
self.max_value= m[:max_value].to_i
|
19
|
+
self.normalizing_index_offset= m[:normalizing_index_offset].to_i
|
20
|
+
self.conversion_ratio= m[:conversion_ratio].to_f
|
21
|
+
self.counts_len= m[:counts_len].to_i
|
22
|
+
self.total_count= m[:total_count].to_i
|
23
|
+
|
24
|
+
counts = m[:counts].split " "
|
25
|
+
i=0
|
26
|
+
counts.each do |count|
|
27
|
+
m = count.match /^~(\d+)$/
|
28
|
+
if m then #zerofill
|
29
|
+
m[1].to_i.times do
|
30
|
+
set_raw_count(i, 0)
|
31
|
+
i=i+1
|
32
|
+
end
|
33
|
+
else
|
34
|
+
set_raw_count(i, count.to_i)
|
35
|
+
i=i+1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
8
39
|
end
|
9
40
|
|
10
41
|
def record(val)
|
@@ -62,4 +93,13 @@ class HDRHistogram
|
|
62
93
|
end
|
63
94
|
private_class_method :adjusted_boundary_val
|
64
95
|
|
96
|
+
def self.unserialize(str)
|
97
|
+
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
|
+
|
99
|
+
m = str.match regex
|
100
|
+
|
101
|
+
hdrh = self.new(m[:lowest_trackable_value].to_i, m[:highest_trackable_value].to_i, m[:significant_figures].to_i, {unserialized: m})
|
102
|
+
|
103
|
+
return hdrh
|
104
|
+
end
|
65
105
|
end
|
data/lib/HDRHistogram/version.rb
CHANGED
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
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leo P.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.7.7
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Ruby wrapper for the C hdr_histogram library
|