hitimes 1.3.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +57 -0
  3. data/HISTORY.md +124 -0
  4. data/LICENSE +16 -0
  5. data/Manifest.txt +44 -0
  6. data/README.md +200 -0
  7. data/Rakefile +28 -0
  8. data/examples/benchmarks.rb +113 -0
  9. data/examples/stats.rb +31 -0
  10. data/ext/hitimes/c/extconf.rb +24 -0
  11. data/ext/hitimes/c/hitimes.c +37 -0
  12. data/ext/hitimes/c/hitimes_instant_clock_gettime.c +28 -0
  13. data/ext/hitimes/c/hitimes_instant_osx.c +45 -0
  14. data/ext/hitimes/c/hitimes_instant_windows.c +27 -0
  15. data/ext/hitimes/c/hitimes_interval.c +370 -0
  16. data/ext/hitimes/c/hitimes_interval.h +73 -0
  17. data/ext/hitimes/c/hitimes_stats.c +269 -0
  18. data/ext/hitimes/c/hitimes_stats.h +30 -0
  19. data/ext/hitimes/java/src/hitimes/Hitimes.java +66 -0
  20. data/ext/hitimes/java/src/hitimes/HitimesInterval.java +176 -0
  21. data/ext/hitimes/java/src/hitimes/HitimesService.java +16 -0
  22. data/ext/hitimes/java/src/hitimes/HitimesStats.java +112 -0
  23. data/lib/hitimes.rb +66 -0
  24. data/lib/hitimes/2.0/hitimes.so +0 -0
  25. data/lib/hitimes/2.1/hitimes.so +0 -0
  26. data/lib/hitimes/2.2/hitimes.so +0 -0
  27. data/lib/hitimes/2.3/hitimes.so +0 -0
  28. data/lib/hitimes/2.4/hitimes.so +0 -0
  29. data/lib/hitimes/2.5/hitimes.so +0 -0
  30. data/lib/hitimes/metric.rb +118 -0
  31. data/lib/hitimes/mutexed_stats.rb +32 -0
  32. data/lib/hitimes/paths.rb +53 -0
  33. data/lib/hitimes/stats.rb +58 -0
  34. data/lib/hitimes/timed_metric.rb +176 -0
  35. data/lib/hitimes/timed_value_metric.rb +233 -0
  36. data/lib/hitimes/value_metric.rb +71 -0
  37. data/lib/hitimes/version.rb +8 -0
  38. data/spec/hitimes_spec.rb +24 -0
  39. data/spec/interval_spec.rb +136 -0
  40. data/spec/metric_spec.rb +28 -0
  41. data/spec/mutex_stats_spec.rb +36 -0
  42. data/spec/paths_spec.rb +11 -0
  43. data/spec/spec_helper.rb +11 -0
  44. data/spec/stats_spec.rb +98 -0
  45. data/spec/timed_metric_spec.rb +155 -0
  46. data/spec/timed_value_metric_spec.rb +171 -0
  47. data/spec/value_metric_spec.rb +108 -0
  48. data/spec/version_spec.rb +7 -0
  49. data/tasks/default.rake +242 -0
  50. data/tasks/extension.rake +38 -0
  51. data/tasks/this.rb +208 -0
  52. metadata +216 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cd0753ca4c87ef476f9a46520c0d522122f735378d77c7310eaf03f8db88b341
4
+ data.tar.gz: 9d1dfc523449870050d5e86a7f2145eab1742e01c83c7cf71a2493961aa9c28f
5
+ SHA512:
6
+ metadata.gz: 17de5f09502c772ac53cd13f7497edb2a955db925edafe39e0f2e3daea0b3ef290213fa4362a84832dd327ea157c09c9e0f499bbf044c158e6eefd43e4764880
7
+ data.tar.gz: f540282f60503bc87a3180276695b984e5ae023dd1de590bfa31da389d1df8e38b19a0f1823367aeb18cdab238ea7d003d4788aac22083e7237147d251f33db2
@@ -0,0 +1,57 @@
1
+ # Hi there!
2
+
3
+ I see you are interested in contributing. That is wonderful. I love
4
+ contributions.
5
+
6
+ I guarantee that there are bugs in this software. And I guarantee that there is
7
+ a feature you want that is not in here yet. As such, any and all bugs reports
8
+ are gratefully accepted, bugfixes even more so. Helping out with bugs is the
9
+ easiest way to contribute.
10
+
11
+
12
+ ## The Quick Version
13
+
14
+ * Have a [GitHub Account][].
15
+ * Search the [GitHub Issues][] and see if your issue already present. If so
16
+ add your comments, :thumbsup:, etc.
17
+ * Issue not there? Not a problem, open up a [new issue][].
18
+ * **Bug reports** please be as detailed as possible. Include:
19
+ * full ruby engine and version: `ruby -e 'puts RUBY_DESCRIPTION'`
20
+ * operating system and version
21
+ * version of hitimes `ruby -rubygems -e "require 'hitimes'; puts Hitimes::VERSION"`
22
+ * as much detail about the bug as possible so I can replicated it. Feel free
23
+ to link in a [gist][]
24
+ * **New Feature**
25
+ * What the new feature should do.
26
+ * What benefit the new feature brings to the project.
27
+ * Fork the [repo][].
28
+ * Create a new branch for your issue: `git checkout -b issue/my-issue`
29
+ * Lovingly craft your contribution:
30
+ * `rake develop` to get started
31
+ * `rake test` to run tests
32
+ * Make sure that `rake test` passes. Its important, I said it twice.
33
+ * Add yourself to the contributors section below.
34
+ * Submit your [pull request][].
35
+
36
+ ## Building Windows Binaries
37
+
38
+ This is done using https://github.com/rake-compiler/rake-compiler-dock
39
+
40
+ 1. have VirtualBox installed
41
+ 2. have Docker Machine installed (https://docs.docker.com/engine/installation/)
42
+ 3. `gem install rake-compiler-dock`
43
+ 4. `rake-compiler-dock` (this could take a while)
44
+ 5. `bundle`
45
+ 6. `rake cross native gem`
46
+
47
+ # Contributors
48
+
49
+ * Jeremy Hinegardner
50
+ * Wojciech Piekutowski
51
+
52
+ [GitHub Account]: https://github.com/signup/free "GitHub Signup"
53
+ [GitHub Issues]: https://github.com/copiousfreetime/hitimes/issues "Hitimes Issues"
54
+ [new issue]: https://github.com/copiousfreetime/hitimes/issues/new "New Hitimes Issue"
55
+ [gist]: https://gist.github.com/ "New Gist"
56
+ [repo]: https://github.com/copiousfreetime/hitimes "hitimes Repo"
57
+ [pull request]: https://help.github.com/articles/using-pull-requests "Using Pull Requests"
@@ -0,0 +1,124 @@
1
+ # Hitimes Changelog
2
+ ## Version 1.3.0 2018-06-15
3
+
4
+ * Add api method `Hitimes.raw_instant` to expose raw OS instant value
5
+ * Add api constant `Hitimes::INSTANT_CONVERSION_FACTOR` to expose raw OS instant conversion factor
6
+ * other development cleanup tasks
7
+
8
+ ## Version 1.2.6 2017-08-04
9
+
10
+ * Resolve version number issue (#61) (thanks @anthraxx)
11
+
12
+ ## Version 1.2.5 2017-05-25
13
+
14
+ * Update dependencies
15
+ * Add ruby 2.4 to windows fatbinary
16
+ * Update docs to indicate windows ruby before 2.0 is no longer supported
17
+
18
+ ## Version 1.2.4 2016-05-01
19
+
20
+ * Fix finding the extension on ruby 2.1.10 (thanks @wpiekutowski)
21
+ * Add more readable load error (thanks @mbautin)
22
+ * Update README with what versions of ruby are supported.
23
+
24
+ ## Version 1.2.3 2015-09-13
25
+
26
+ * Release new fatbinary version for windows
27
+ * Update README to indicate duration units
28
+ * Provide a more friendly error message if the gem is not installed correctly
29
+
30
+ ## Version 1.2.2 2014-07-09
31
+
32
+ * fix compilation issue with clock_gettime in libc (reported by eradman and virtualfunction)
33
+ * Switch to minispec for tests
34
+
35
+ ## Version 1.2.1 2013-03-12
36
+
37
+ * Update dependencies
38
+ * Ruby 2.0 fixes
39
+ * Switch to Markdown, Yeah RDoc 4.0!
40
+
41
+ ## Version 1.2.0 2013-02-09
42
+
43
+ * Update dependencies
44
+ * Documentation cleanup
45
+ * Fix use of deprecated JRuby API in java extension
46
+ * Fix use of deprecated OSX system calls in C extension
47
+ * Make hitimes -w clean
48
+ * Fix ambiguity of calling duration on non-started Interval
49
+ * Use RbConfig instead of Config (eregon)
50
+ * Added Hitimes.measure
51
+ * Switch to using rake-compiler for cross compilation of gems
52
+
53
+ ## Version 1.1.1 2010-09-04
54
+
55
+ * Remove the unnecessary dependencies that should be development dependencies
56
+
57
+ ## Version 1.1.0 2010-07-28
58
+
59
+ * Add a pure java extension so hitimes may be used in jruby with the same API
60
+
61
+ ## Version 1.0.5 2010-07-20
62
+
63
+ * Fix 'circular require considered harmful' warnings in 1.9.x (reported by Roger Pack)
64
+ * Fix 'method redefined' warnings in 1.9.x (reported by Roger Pack)
65
+
66
+ ## Version 1.0.4 2009-08-01
67
+
68
+ * Add in support for x86-mingw32 gem
69
+ * Add version subdirectory for extension on all platforms
70
+
71
+ ## Version 1.0.3 2009-06-28
72
+
73
+ * Fix bug with time.h on linode (reported by Roger Pack)
74
+ * Fix potential garbage collection issue with Interval class
75
+ * Windows gem is now a fat binary to support installing in 1.8 or 1.9 from the
76
+ same gem
77
+
78
+ ## Version 1.0.1 2009-06-12
79
+
80
+ * Fix examples
81
+ * performance tuning, new Hitimes::Metric derived classes are faster than old Timer class
82
+
83
+ ## Version 1.0.0 2009-06-12
84
+
85
+ * Major version bump with complete refactor of the metric collection API
86
+ * 3 types of metrics now instead of just 1 Timer
87
+ * Hitimes::ValueMetric
88
+ * Hitimes::TimedMetric
89
+ * Hitimes::TimedValueMetric
90
+ * The ability to convert all metrics #to_hash
91
+ * Updated documentation with examples using each metric type
92
+
93
+ ## Version 0.4.1 2009-02-19
94
+
95
+ * change to ISC License
96
+ * fix bug in compilation on gentoo
97
+
98
+ ## Version 0.4.0 2008-12-20
99
+
100
+ * Added new stat 'rate'
101
+ * Added new stat method to_hash
102
+ * Added Hitimes::MutexedStats class for threadsafe stats collection
103
+ - not needed when used in MRI 1.8.x
104
+ * remove stale dependency on mkrf
105
+
106
+ ## Version 0.3.0
107
+
108
+ * switched to extconf for building extensions
109
+ * first release of windows binary gem
110
+ * reverted back to normal rdoc
111
+
112
+ ## Version 0.2.1
113
+
114
+ * added Timer#rate method
115
+ * switched to darkfish rdoc
116
+
117
+ ## Version 0.2.0
118
+
119
+ * Performance improvements
120
+ * Added Hitimes::Stats class
121
+
122
+ ## Version 0.1.0
123
+
124
+ * Initial completion
data/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ ISC LICENSE - http://opensource.org/licenses/isc-license.txt
2
+
3
+ Copyright (c) 2008-2015 Jeremy Hinegardner
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
@@ -0,0 +1,44 @@
1
+ CONTRIBUTING.md
2
+ HISTORY.md
3
+ LICENSE
4
+ Manifest.txt
5
+ README.md
6
+ Rakefile
7
+ examples/benchmarks.rb
8
+ examples/stats.rb
9
+ ext/hitimes/c/extconf.rb
10
+ ext/hitimes/c/hitimes.c
11
+ ext/hitimes/c/hitimes_instant_clock_gettime.c
12
+ ext/hitimes/c/hitimes_instant_osx.c
13
+ ext/hitimes/c/hitimes_instant_windows.c
14
+ ext/hitimes/c/hitimes_interval.c
15
+ ext/hitimes/c/hitimes_interval.h
16
+ ext/hitimes/c/hitimes_stats.c
17
+ ext/hitimes/c/hitimes_stats.h
18
+ ext/hitimes/java/src/hitimes/Hitimes.java
19
+ ext/hitimes/java/src/hitimes/HitimesInterval.java
20
+ ext/hitimes/java/src/hitimes/HitimesService.java
21
+ ext/hitimes/java/src/hitimes/HitimesStats.java
22
+ lib/hitimes.rb
23
+ lib/hitimes/metric.rb
24
+ lib/hitimes/mutexed_stats.rb
25
+ lib/hitimes/paths.rb
26
+ lib/hitimes/stats.rb
27
+ lib/hitimes/timed_metric.rb
28
+ lib/hitimes/timed_value_metric.rb
29
+ lib/hitimes/value_metric.rb
30
+ lib/hitimes/version.rb
31
+ spec/hitimes_spec.rb
32
+ spec/interval_spec.rb
33
+ spec/metric_spec.rb
34
+ spec/mutex_stats_spec.rb
35
+ spec/paths_spec.rb
36
+ spec/spec_helper.rb
37
+ spec/stats_spec.rb
38
+ spec/timed_metric_spec.rb
39
+ spec/timed_value_metric_spec.rb
40
+ spec/value_metric_spec.rb
41
+ spec/version_spec.rb
42
+ tasks/default.rake
43
+ tasks/extension.rake
44
+ tasks/this.rb
@@ -0,0 +1,200 @@
1
+ # Hitimes
2
+
3
+ [![Build Status](https://travis-ci.org/copiousfreetime/hitimes.svg?branch=master)](https://travis-ci.org/copiousfreetime/hitimes)
4
+
5
+ A fast, high resolution timer library for recording peformance metrics.
6
+
7
+ * [Homepage](http://github.com/copiousfreetime/hitimes)
8
+ * [Github project](http://github.com.org/copiousfreetime/hitimes)
9
+ * email jeremy at copiousfreetime dot org
10
+ * `git clone url git://github.com/copiousfreetime/hitimes.git`
11
+
12
+ ## Table of Contents
13
+
14
+ * [Requirements](#requirements)
15
+ * [Usage](#usage)
16
+ * [Contributing](#contributing)
17
+ * [Support](#support)
18
+ * [License](#license)
19
+
20
+
21
+ ## Requirements
22
+
23
+ Hitimes requires the following to run:
24
+
25
+ * Ruby
26
+
27
+ ## Usage
28
+
29
+ Hitimes easiest to use when installed with `rubygems`:
30
+
31
+ ```sh
32
+ gem install hitimes
33
+ ```
34
+
35
+ Or as part of your bundler `Gemfile`:
36
+
37
+ ```ruby
38
+ gem 'hitimes'
39
+ ```
40
+
41
+ You can load it with the standard ruby require statement.
42
+
43
+ ```ruby
44
+ require 'hitimes'
45
+ ```
46
+
47
+ ### Interval
48
+
49
+ Use `Hitimes::Interval` to calculate only the duration of a block of code.
50
+ Returns the time as seconds.
51
+
52
+ ```ruby
53
+ duration = Hitimes::Interval.measure do
54
+ 1_000_000.times do |x|
55
+ 2 + 2
56
+ end
57
+ end
58
+
59
+ puts duration # => 0.047414297 (seconds)
60
+ ```
61
+
62
+ ### TimedMetric
63
+
64
+ Use a `Hitimes::TimedMetric` to calculate statistics about an iterative operation
65
+
66
+ ```ruby
67
+ timed_metric = Hitimes::TimedMetric.new('operation on items')
68
+ ```
69
+
70
+ Explicitly use `start` and `stop`:
71
+
72
+ ```ruby
73
+ collection.each do |item|
74
+ timed_metric.start
75
+ # .. do something with item
76
+ timed_metric.stop
77
+ end
78
+ ```
79
+
80
+ Or use the block. In `TimedMetric` the return value of `measure` is the return
81
+ value of the block.
82
+
83
+ ```ruby
84
+ collection.each do |item|
85
+ result_of_do_something = timed_metric.measure { do_something( item ) }
86
+ end
87
+ ```
88
+ And then look at the stats
89
+
90
+ ```ruby
91
+ puts timed_metric.mean
92
+ puts timed_metric.max
93
+ puts timed_metric.min
94
+ puts timed_metric.stddev
95
+ puts timed_metric.rate
96
+ ```
97
+ ### ValueMetric
98
+
99
+ Use a `Hitimes::ValueMetric` to calculate statistics about measured samples.
100
+
101
+ ``` ruby
102
+ value_metric = Hitimes::ValueMetric.new( 'size of thing' )
103
+ loop do
104
+ # ... do stuff changing sizes of 'thing'
105
+ value_metric.measure( thing.size )
106
+ # ... do other stuff that may change size of thing
107
+ end
108
+
109
+ puts value_metric.mean
110
+ puts value_metric.max
111
+ puts value_metric.min
112
+ puts value_metric.stddev
113
+ puts value_metric.rate
114
+ ```
115
+
116
+ ### TimedValueMetric
117
+
118
+ Use a `Hitimes::TimedValueMetric` to calculate statistics about batches of samples.
119
+
120
+ ``` ruby
121
+ timed_value_metric = Hitimes::TimedValueMetric.new( 'batch times' )
122
+ loop do
123
+ batch = ... # get a batch of things
124
+ timed_value_metric.start
125
+ # .. do something with batch
126
+ timed_value_metric.stop( batch.size )
127
+ end
128
+
129
+ puts timed_value_metric.rate
130
+
131
+ puts timed_value_metric.timed_stats.mean
132
+ puts timed_value_metric.timed_stats.max
133
+ puts timed_value_metric.timed_stats.min
134
+ puts timed_value_metric.timed_stats.stddev
135
+
136
+ puts timed_value_metric.value_stats.mean
137
+ puts timed_value_metric.value_stats.max
138
+ puts timed_value_metric.value_stats.min
139
+ puts timed_value_metric.value_stats.stddev
140
+ ```
141
+
142
+ ### Implementation details
143
+
144
+ Hitimes use the appropriate low-level system call for each operating system to
145
+ get the highest granularity time increment possible. Generally this is
146
+ nanosecond resolution, or whatever the hardware chip in the CPU supports.
147
+
148
+ It currently supports any of the following systems:
149
+
150
+ * any system with the POSIX call `clock_gettime()`
151
+ * Mac OS X
152
+ * Windows
153
+ * JRuby
154
+
155
+ ## Support
156
+
157
+ Hitimes is supported on whatever versions of ruby are currently supported.
158
+ Hitimes also follows [semantic versioning](http://semver.org/).
159
+
160
+ The current officially supported versions of Ruby are:
161
+
162
+ * MRI Ruby (all platforms) 2.3 - 2.5
163
+ * JRuby 9.1.17.0, 9.2.0.0
164
+
165
+ Unofficially supported versions, these have been supported in the past when they
166
+ were the primary rubies around. In all likelihood they still work, but are not
167
+ supported.
168
+
169
+ * MRI Ruby (linux/mac/bsd/unix/etc) - everything from 1.8.7 to 2.2
170
+ * MRI Ruby (windows) - 2.0 and up
171
+ * Ruby 1.8 and 1.9 for windows are supported in hitimes version 1.2.4 or earlier
172
+ * JRuby - I think everything back to 1.4
173
+ * Rubinius
174
+
175
+ ## Contributing
176
+
177
+ Please read the [CONTRIBUTING.md](CONTRIBUTING.md)
178
+
179
+ ## Credits
180
+
181
+ * [Bruce Williams](https://github.com/bruce) for suggesting the idea
182
+
183
+ ## License
184
+
185
+ Hitimes is licensed under the [ISC](https://opensource.org/licenses/ISC)
186
+ license.
187
+
188
+ Copyright (c) 2008-2016 Jeremy Hinegardner
189
+
190
+ Permission to use, copy, modify, and/or distribute this software for any
191
+ purpose with or without fee is hereby granted, provided that the above
192
+ copyright notice and this permission notice appear in all copies.
193
+
194
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
195
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
196
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
197
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
198
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
199
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
200
+ PERFORMANCE OF THIS SOFTWARE.