hitimes 1.0.3-x86-mswin32-60 → 1.2.2-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/.travis.yml +10 -0
  2. data/CONTRIBUTING.md +45 -0
  3. data/HISTORY.md +97 -0
  4. data/LICENSE +11 -8
  5. data/Manifest.txt +45 -0
  6. data/README.md +163 -0
  7. data/Rakefile +23 -62
  8. data/ext/hitimes/c/extconf.rb +24 -0
  9. data/ext/hitimes/{hitimes_ext.c → c/hitimes.c} +1 -1
  10. data/ext/hitimes/{hitimes_instant_clock_gettime.c → c/hitimes_instant_clock_gettime.c} +0 -0
  11. data/ext/hitimes/c/hitimes_instant_osx.c +45 -0
  12. data/ext/hitimes/{hitimes_instant_windows.c → c/hitimes_instant_windows.c} +0 -0
  13. data/ext/hitimes/{hitimes_interval.c → c/hitimes_interval.c} +15 -7
  14. data/ext/hitimes/{hitimes_interval.h → c/hitimes_interval.h} +5 -5
  15. data/ext/hitimes/{hitimes_stats.c → c/hitimes_stats.c} +0 -0
  16. data/ext/hitimes/{hitimes_stats.h → c/hitimes_stats.h} +0 -0
  17. data/ext/hitimes/java/src/hitimes/Hitimes.java +54 -0
  18. data/ext/hitimes/java/src/hitimes/HitimesInterval.java +181 -0
  19. data/ext/hitimes/java/src/hitimes/HitimesService.java +16 -0
  20. data/ext/hitimes/java/src/hitimes/HitimesStats.java +112 -0
  21. data/lib/hitimes.rb +18 -5
  22. data/lib/hitimes/1.9/hitimes.so +0 -0
  23. data/lib/hitimes/2.0/hitimes.so +0 -0
  24. data/lib/hitimes/2.1/hitimes.so +0 -0
  25. data/lib/hitimes/metric.rb +6 -0
  26. data/lib/hitimes/mutexed_stats.rb +5 -1
  27. data/lib/hitimes/stats.rb +5 -1
  28. data/lib/hitimes/timed_metric.rb +1 -2
  29. data/lib/hitimes/timed_value_metric.rb +0 -2
  30. data/lib/hitimes/value_metric.rb +2 -3
  31. data/lib/hitimes/version.rb +1 -50
  32. data/spec/hitimes_spec.rb +14 -0
  33. data/spec/interval_spec.rb +40 -37
  34. data/spec/metric_spec.rb +8 -10
  35. data/spec/mutex_stats_spec.rb +10 -8
  36. data/spec/paths_spec.rb +3 -5
  37. data/spec/spec_helper.rb +9 -4
  38. data/spec/stats_spec.rb +28 -30
  39. data/spec/timed_metric_spec.rb +44 -44
  40. data/spec/timed_value_metric_spec.rb +54 -55
  41. data/spec/value_metric_spec.rb +28 -30
  42. data/spec/version_spec.rb +4 -30
  43. data/tasks/default.rake +254 -0
  44. data/tasks/extension.rake +29 -73
  45. data/tasks/this.rb +200 -0
  46. metadata +173 -105
  47. data/HISTORY +0 -55
  48. data/README +0 -134
  49. data/ext/hitimes/extconf.rb +0 -21
  50. data/ext/hitimes/hitimes_instant_osx.c +0 -16
  51. data/gemspec.rb +0 -57
  52. data/lib/hitimes/1.8/hitimes_ext.so +0 -0
  53. data/lib/hitimes/1.9/hitimes_ext.so +0 -0
  54. data/tasks/announce.rake +0 -39
  55. data/tasks/config.rb +0 -108
  56. data/tasks/distribution.rake +0 -74
  57. data/tasks/documentation.rake +0 -32
  58. data/tasks/rspec.rake +0 -31
  59. data/tasks/rubyforge.rake +0 -55
  60. data/tasks/utils.rb +0 -80
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.8.7"
4
+ - "1.9.2"
5
+ - "1.9.3"
6
+ - "2.0.0"
7
+ - "2.1.0"
8
+ - jruby-18mode # JRuby in 1.8 mode
9
+ - jruby-19mode # JRuby in 1.9 mode
10
+ - rbx
@@ -0,0 +1,45 @@
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, or if you prefer bundler `rake develop:using_bunder && bundle`.
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
+ # Contributors
37
+
38
+ * Jeremy Hinegardner
39
+
40
+ [GitHub Account]: https://github.com/signup/free "GitHub Signup"
41
+ [GitHub Issues]: https://github.com/copiousfreetime/hitimes/issues "Hitimes Issues"
42
+ [new issue]: https://github.com/copiousfreetime/hitimes/issues/new "New Hitimes Issue"
43
+ [gist]: https://gist.github.com/ "New Gist"
44
+ [repo]: https://github.com/copiousfreetime/hitimes "hitimes Repo"
45
+ [pull request]: https://help.github.com/articles/using-pull-requests "Using Pull Requests"
@@ -0,0 +1,97 @@
1
+ # Hitimes Changelog
2
+
3
+ ## Version 1.2.2 2014-07-09
4
+
5
+ * fix compilation issue with clock_gettime in libc (reported by eradman and virtualfunction)
6
+ * Switch to minispec for tests
7
+
8
+ ## Version 1.2.1 2013-03-12
9
+
10
+ * Update dependencies
11
+ * Ruby 2.0 fixes
12
+ * Switch to Markdown, Yeah RDoc 4.0!
13
+
14
+ ## Version 1.2.0 2013-02-09
15
+
16
+ * Update dependencies
17
+ * Documentation cleanup
18
+ * Fix use of deprecated JRuby API in java extension
19
+ * Fix use of deprecated OSX system calls in C extension
20
+ * Make hitimes -w clean
21
+ * Fix ambiguity of calling duration on non-started Interval
22
+ * Use RbConfig instead of Config (eregon)
23
+ * Added Hitimes.measure
24
+ * Switch to using rake-compiler for cross compilation of gems
25
+
26
+ ## Version 1.1.1 2010-09-04
27
+
28
+ * Remove the unnecessary dependencies that should be development dependencies
29
+
30
+ ## Version 1.1.0 2010-07-28
31
+
32
+ * Add a pure java extension so hitimes may be used in jruby with the same API
33
+
34
+ ## Version 1.0.5 2010-07-20
35
+
36
+ * Fix 'circular require considered harmful' warnings in 1.9.x (reported by Roger Pack)
37
+ * Fix 'method redefined' warnings in 1.9.x (reported by Roger Pack)
38
+
39
+ ## Version 1.0.4 2009-08-01
40
+
41
+ * Add in support for x86-mingw32 gem
42
+ * Add version subdirectory for extension on all platforms
43
+
44
+ ## Version 1.0.3 2009-06-28
45
+
46
+ * Fix bug with time.h on linode (reported by Roger Pack)
47
+ * Fix potential garbage collection issue with Interval class
48
+ * Windows gem is now a fat binary to support installing in 1.8 or 1.9 from the
49
+ same gem
50
+
51
+ ## Version 1.0.1 2009-06-12
52
+
53
+ * Fix examples
54
+ * performance tuning, new Hitimes::Metric derived classes are faster than old Timer class
55
+
56
+ ## Version 1.0.0 2009-06-12
57
+
58
+ * Major version bump with complete refactor of the metric collection API
59
+ * 3 types of metrics now instead of just 1 Timer
60
+ * Hitimes::ValueMetric
61
+ * Hitimes::TimedMetric
62
+ * Hitimes::TimedValueMetric
63
+ * The ability to convert all metrics #to_hash
64
+ * Updated documentation with examples using each metric type
65
+
66
+ ## Version 0.4.1 2009-02-19
67
+
68
+ * change to ISC License
69
+ * fix bug in compilation on gentoo
70
+
71
+ ## Version 0.4.0 2008-12-20
72
+
73
+ * Added new stat 'rate'
74
+ * Added new stat method to_hash
75
+ * Added Hitimes::MutexedStats class for threadsafe stats collection
76
+ - not needed when used in MRI 1.8.x
77
+ * remove stale dependency on mkrf
78
+
79
+ ## Version 0.3.0
80
+
81
+ * switched to extconf for building extensions
82
+ * first release of windows binary gem
83
+ * reverted back to normal rdoc
84
+
85
+ ## Version 0.2.1
86
+
87
+ * added Timer#rate method
88
+ * switched to darkfish rdoc
89
+
90
+ ## Version 0.2.0
91
+
92
+ * Performance improvements
93
+ * Added Hitimes::Stats class
94
+
95
+ ## Version 0.1.0
96
+
97
+ * Initial completion
data/LICENSE CHANGED
@@ -1,13 +1,16 @@
1
- Copyright (c) 2008 Jeremy Hinegardner
1
+ ISC LICENSE - http://opensource.org/licenses/isc-license.txt
2
+
3
+ Copyright (c) 2008-2012 Jeremy Hinegardner
2
4
 
3
5
  Permission to use, copy, modify, and/or distribute this software for any
4
6
  purpose with or without fee is hereby granted, provided that the above
5
7
  copyright notice and this permission notice appear in all copies.
6
8
 
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
9
- FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
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,45 @@
1
+ .travis.yml
2
+ CONTRIBUTING.md
3
+ HISTORY.md
4
+ LICENSE
5
+ Manifest.txt
6
+ README.md
7
+ Rakefile
8
+ examples/benchmarks.rb
9
+ examples/stats.rb
10
+ ext/hitimes/c/extconf.rb
11
+ ext/hitimes/c/hitimes.c
12
+ ext/hitimes/c/hitimes_instant_clock_gettime.c
13
+ ext/hitimes/c/hitimes_instant_osx.c
14
+ ext/hitimes/c/hitimes_instant_windows.c
15
+ ext/hitimes/c/hitimes_interval.c
16
+ ext/hitimes/c/hitimes_interval.h
17
+ ext/hitimes/c/hitimes_stats.c
18
+ ext/hitimes/c/hitimes_stats.h
19
+ ext/hitimes/java/src/hitimes/Hitimes.java
20
+ ext/hitimes/java/src/hitimes/HitimesInterval.java
21
+ ext/hitimes/java/src/hitimes/HitimesService.java
22
+ ext/hitimes/java/src/hitimes/HitimesStats.java
23
+ lib/hitimes.rb
24
+ lib/hitimes/metric.rb
25
+ lib/hitimes/mutexed_stats.rb
26
+ lib/hitimes/paths.rb
27
+ lib/hitimes/stats.rb
28
+ lib/hitimes/timed_metric.rb
29
+ lib/hitimes/timed_value_metric.rb
30
+ lib/hitimes/value_metric.rb
31
+ lib/hitimes/version.rb
32
+ spec/hitimes_spec.rb
33
+ spec/interval_spec.rb
34
+ spec/metric_spec.rb
35
+ spec/mutex_stats_spec.rb
36
+ spec/paths_spec.rb
37
+ spec/spec_helper.rb
38
+ spec/stats_spec.rb
39
+ spec/timed_metric_spec.rb
40
+ spec/timed_value_metric_spec.rb
41
+ spec/value_metric_spec.rb
42
+ spec/version_spec.rb
43
+ tasks/default.rake
44
+ tasks/extension.rake
45
+ tasks/this.rb
@@ -0,0 +1,163 @@
1
+ ## hitimes
2
+
3
+ * [Homepage](http://github.com/copiousfreetime/hitimes)
4
+ * [Github project](http://github.com.org/copiousfreetime/hitimes)
5
+ * email jeremy at copiousfreetime dot org
6
+ * `git clone url git://github.com/copiousfreetime/hitimes.git`
7
+
8
+ ## INSTALL
9
+
10
+ * `gem install hitimes`
11
+
12
+ ## DESCRIPTION
13
+
14
+ Hitimes is a fast, high resolution timer library for recording
15
+ performance metrics. It uses the appropriate low method calls for each
16
+ system to get the highest granularity time increments possible.
17
+
18
+ It currently supports any of the following systems:
19
+
20
+ * any system with the POSIX call `clock_gettime()`
21
+ * Mac OS X
22
+ * Windows
23
+ * JRuby
24
+
25
+ Using Hitimes can be faster than using a series of `Time.new` calls, and
26
+ it will have a much higher granularity. It is definitely faster than
27
+ using `Process.times`.
28
+
29
+ ## SYNOPSIS
30
+
31
+ ### Interval
32
+
33
+ Use Hitimes::Interval to calculate only the duration of a block of code
34
+
35
+ ``` ruby
36
+ duration = Hitimes::Interval.measure do
37
+ # some operation ...
38
+ end
39
+
40
+ puts duration
41
+ ```
42
+
43
+ ### TimedMetric
44
+
45
+ Use a Hitimes::TimedMetric to calculate statistics about an iterative operation
46
+
47
+ ``` ruby
48
+ timed_metric = Hitimes::TimedMetric.new('operation on items')
49
+ ```
50
+
51
+ Explicitly use `start` and `stop`:
52
+
53
+ ``` ruby
54
+ collection.each do |item|
55
+ timed_metric.start
56
+ # .. do something with item
57
+ timed_metric.stop
58
+ end
59
+ ```
60
+
61
+ Or use the block. In TimedMetric the return value of +measure+ is the return
62
+ value of the block
63
+
64
+ ``` ruby
65
+ collection.each do |item|
66
+ result_of_do_something = timed_metric.measure { do_something( item ) }
67
+ end
68
+ ```
69
+ And then look at the stats
70
+
71
+ ``` ruby
72
+ puts timed_metric.mean
73
+ puts timed_metric.max
74
+ puts timed_metric.min
75
+ puts timed_metric.stddev
76
+ puts timed_metric.rate
77
+ ```
78
+ ### ValueMetric
79
+
80
+ Use a Hitimes::ValueMetric to calculate statistics about measured samples
81
+
82
+ ``` ruby
83
+ value_metric = Hitimes::ValueMetric.new( 'size of thing' )
84
+ loop do
85
+ # ... do stuff changing sizes of 'thing'
86
+ value_metric.measure( thing.size )
87
+ # ... do other stuff that may change size of thing
88
+ end
89
+
90
+ puts value_metric.mean
91
+ puts value_metric.max
92
+ puts value_metric.min
93
+ puts value_metric.stddev
94
+ puts value_metric.rate
95
+ ```
96
+
97
+ ### TimedValueMetric
98
+
99
+ Use a Hitimes::TimedValueMetric to calculate statistics about batches of samples
100
+
101
+ ``` ruby
102
+ timed_value_metric = Hitimes::TimedValueMetric.new( 'batch times' )
103
+ loop do
104
+ batch = ... # get a batch of things
105
+ timed_value_metric.start
106
+ # .. do something with batch
107
+ timed_value_metric.stop( batch.size )
108
+ end
109
+
110
+ puts timed_value_metric.rate
111
+
112
+ puts timed_value_metric.timed_stats.mean
113
+ puts timed_value_metric.timed_stats.max
114
+ puts timed_value_metric.timed_stats.min
115
+ puts timed_value_metric.timed_stats.stddev
116
+
117
+ puts timed_value_metric.value_stats.mean
118
+ puts timed_value_metric.value_stats.max
119
+ puts timed_value_metric.value_stats.min
120
+ puts timed_value_metric.value_stats.stddev
121
+ ```
122
+
123
+ ## CHANGES
124
+
125
+ Read the HISTORY.md file.
126
+
127
+ ## BUILDING FOR WINDOWS
128
+
129
+ [rake-compiler](https://github.com/luislavena/rake-compiler) is use for building
130
+ the windows version. For me, on OSX to cross compile the process is:
131
+
132
+ ```
133
+ % gem install rake-compiler # in each rvm instance, 1.8.7, 1.9.3
134
+ % rvm use 2.0.0@hitimes
135
+ % rake-compiler cross-ruby VERSION=2.0.0-p0 # or latest
136
+ % rvm use 1.9.3@hitimes
137
+ % rake-compiler cross-ruby VERSION=1.9.3-p374 # or latest
138
+ % rvm use 1.8.7@hitimes
139
+ % rake-compiler cross-ruby VERSION=1.8.7-p371
140
+
141
+ # This only works via 1.8.7 at the current moment
142
+ % rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.3:2.0.0
143
+ ```
144
+
145
+ ## CREDITS
146
+
147
+ * [Bruce Williams](https://github.com/bruce) for suggesting the idea
148
+
149
+ ## ISC License
150
+
151
+ Copyright (c) 2008-2012 Jeremy Hinegardner
152
+
153
+ Permission to use, copy, modify, and/or distribute this software for any
154
+ purpose with or without fee is hereby granted, provided that the above
155
+ copyright notice and this permission notice appear in all copies.
156
+
157
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
158
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
159
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
160
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
161
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
162
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
163
+ PERFORMANCE OF THIS SOFTWARE.
data/Rakefile CHANGED
@@ -1,66 +1,27 @@
1
- #--
2
- # Copyright (c) 2008 Jeremy Hinegardner
3
- # All rights reserved. See LICENSE and/or COPYING for details.
4
- #++
5
-
6
- #-------------------------------------------------------------------------------
7
- # make sure our project's top level directory and the lib directory are added to
8
- # the ruby search path.
9
- #-------------------------------------------------------------------------------
10
- $: << File.expand_path(File.join(File.dirname(__FILE__),"ext"))
11
- $: << File.expand_path(File.join(File.dirname(__FILE__),"lib"))
12
- $: << File.expand_path(File.dirname(__FILE__))
13
-
14
-
15
- #-------------------------------------------------------------------------------
16
- # load the global project configuration and add in the top level clean and
17
- # clobber tasks so that other tasks can utilize those constants if necessary
18
- # This loads up the defaults for the whole project configuration
19
- #-------------------------------------------------------------------------------
20
- require 'rubygems'
21
- require 'tasks/config.rb'
22
- require 'rake/clean'
23
-
24
- #-------------------------------------------------------------------------------
25
- # Main configuration for the project, these overwrite the items that are in
26
- # tasks/config.rb
27
- #-------------------------------------------------------------------------------
28
- require 'hitimes/version'
29
- require 'hitimes/paths'
30
-
31
- Configuration.for("project") {
32
- name "hitimes"
33
- version Hitimes::VERSION
34
- author "Jeremy Hinegardner"
35
- email "jeremy@copiousfreetime.org"
36
- homepage "http://copiousfreetime.rubyforge.org/hitimes/"
37
- }
38
-
39
- #-------------------------------------------------------------------------------
40
- # load up all the project tasks and setup the default task to be the
41
- # test:default task.
42
- #-------------------------------------------------------------------------------
43
- Configuration.for("packaging").files.tasks.each do |tasklib|
44
- import tasklib
1
+ # vim: syntax=ruby
2
+ load 'tasks/this.rb'
3
+
4
+ This.name = "hitimes"
5
+ This.author = "Jeremy Hinegardner"
6
+ This.email = "jeremy@copiousfreetime.org"
7
+ This.homepage = "http://github.com/copiousfreetime/#{ This.name }"
8
+
9
+ This.ruby_gemspec do |spec|
10
+ spec.add_development_dependency( 'rake' , '~> 10.4')
11
+ spec.add_development_dependency( 'minitest' , '~> 5.5' )
12
+ spec.add_development_dependency( 'rdoc' , '~> 4.2' )
13
+ spec.add_development_dependency( 'json' , '~> 1.8' )
14
+ spec.add_development_dependency( 'rake-compiler', '~> 0.9' )
15
+ spec.add_development_dependency( 'simplecov' , '~> 0.9' )
16
+
17
+ spec.extensions.concat This.extension_conf_files
18
+ spec.license = "ISC"
45
19
  end
46
- task :default => 'test:default'
47
20
 
48
- #-------------------------------------------------------------------------------
49
- # Finalize the loading of all pending imports and update the top level clobber
50
- # task to depend on all possible sub-level tasks that have a name like
51
- # ':clobber' in other namespaces. This allows us to say:
52
- #
53
- # rake clobber
54
- #
55
- # and it will get everything.
56
- #-------------------------------------------------------------------------------
57
- Rake.application.load_imports
58
- Rake.application.tasks.each do |t|
59
- if t.name =~ /:clobber/ then
60
- task :clobber => [t.name]
61
- end
62
- if t.name =~ /:clean/ then
63
- task :clean => [t.name]
64
- end
21
+ This.java_gemspec( This.ruby_gemspec ) do |spec|
22
+ spec.extensions.clear
23
+ spec.files << "lib/hitimes/hitimes.jar"
65
24
  end
66
25
 
26
+ load 'tasks/default.rake'
27
+ load 'tasks/extension.rake'