HDRHistogram 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,65 @@
1
+ require "HDRHistogram/version"
2
+ require "ruby_hdr_histogram"
3
+
4
+ class HDRHistogram
5
+ def initialize(lowest, highest, sig, opt={})
6
+ @multiplier = opt[:multiplier] || 1
7
+ @unit = opt[:unit] || opt[:units]
8
+ end
9
+
10
+ def record(val)
11
+ raw_record(val * 1/@multiplier)
12
+ end
13
+ def record_corrected(val)
14
+ raw_record_corrected(val * 1/@multiplier)
15
+ end
16
+ def min
17
+ raw_min * @multiplier
18
+ end
19
+ def max
20
+ raw_max * @multiplier
21
+ end
22
+ def mean
23
+ raw_mean * @multiplier
24
+ end
25
+ def stddev
26
+ raw_stddev * @multiplier
27
+ end
28
+ def percentile(pct)
29
+ raw_percentile(pct) * @multiplier
30
+ end
31
+ def merge(other)
32
+ if other.multiplier != multiplier
33
+ raise HDRHistogramError, "can't merge histograms with different multipliers"
34
+ end
35
+ if other.unit != unit
36
+ raise HDRHistogramError, "can't merge histograms with different units"
37
+ end
38
+ raw_merge other
39
+ end
40
+
41
+ def to_s
42
+ stats
43
+ end
44
+
45
+ def latency_stats
46
+ str = "Latency Stats\n"
47
+ str << stats([ 50.0, 75.0, 90.0, 99.0, 99.9, 99.99, 99.999, 100.0 ])
48
+
49
+ end
50
+
51
+ def stats(percentiles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
52
+ str = ""
53
+ pctf = @multiplier < 1 ? "%12.#{Math.log(0.001, 10).abs.ceil}f" : "%12u"
54
+ percentiles.each do |pct|
55
+ str << sprintf("%7.3f%% #{pctf}%s\n", pct, percentile(pct), unit)
56
+ end
57
+ str
58
+ end
59
+
60
+ def self.adjusted_boundary_val(val, opt={})
61
+ return val * 1/(opt[:multiplier] || 1)
62
+ end
63
+ private_class_method :adjusted_boundary_val
64
+
65
+ end
@@ -0,0 +1,3 @@
1
+ class HDRHistogram
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: HDRHistogram
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Leo P.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-compiler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-debundle
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: HdrHistogram is an algorithm designed for recording histograms of value
98
+ measurements with configurable precision. Value precision is expressed as the number
99
+ of significant digits, providing control over value quantization and resolution
100
+ whilst maintaining a fixed cost in both space and time.
101
+ email:
102
+ - junk@slact.net
103
+ executables: []
104
+ extensions:
105
+ - ext/ruby_hdr_histogram/extconf.rb
106
+ extra_rdoc_files: []
107
+ files:
108
+ - ".gitignore"
109
+ - ".travis.yml"
110
+ - CODE_OF_CONDUCT.md
111
+ - Gemfile
112
+ - HDRHistogram.gemspec
113
+ - LICENSE.txt
114
+ - README.md
115
+ - Rakefile
116
+ - bin/console
117
+ - bin/setup
118
+ - ext/ruby_hdr_histogram/extconf.rb
119
+ - ext/ruby_hdr_histogram/hdr_histogram.c
120
+ - ext/ruby_hdr_histogram/hdr_histogram.h
121
+ - ext/ruby_hdr_histogram/ruby_hdr_histogram.c
122
+ - lib/HDRHistogram.rb
123
+ - lib/HDRHistogram/version.rb
124
+ homepage: https://github.com/slact/hdr_histogram_ruby
125
+ licenses:
126
+ - MIT
127
+ metadata:
128
+ allowed_push_host: https://rubygems.org
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.5.1
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: Ruby wrapper for the C hdr_histogram library
149
+ test_files: []
150
+ has_rdoc: