hitimes 0.3.0-x86-mswin32-60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/rbconfig.rb ADDED
@@ -0,0 +1,178 @@
1
+
2
+ # This file was created by mkconfig.rb when ruby was built. Any
3
+ # changes made to this file will be lost the next time ruby is built.
4
+
5
+ module Config
6
+ RUBY_VERSION == "1.8.6" or
7
+ raise "ruby lib version (1.8.6) doesn't match executable version (#{RUBY_VERSION})"
8
+
9
+ TOPDIR = File.dirname(__FILE__).chomp!("/lib/ruby/1.8/i386-mingw32")
10
+ DESTDIR = '' unless defined? DESTDIR
11
+ CONFIG = {}
12
+ CONFIG["DESTDIR"] = DESTDIR
13
+ CONFIG["INSTALL"] = '/opt/local/bin/ginstall -c'
14
+ CONFIG["prefix"] = (TOPDIR || DESTDIR + "#{ENV["HOME"]}/ruby-mingw32")
15
+ CONFIG["EXEEXT"] = ".exe"
16
+ CONFIG["ruby_install_name"] = "ruby"
17
+ CONFIG["RUBY_INSTALL_NAME"] = "ruby"
18
+ CONFIG["RUBY_SO_NAME"] = "msvcrt-ruby18"
19
+ CONFIG["SHELL"] = "/bin/sh"
20
+ CONFIG["PATH_SEPARATOR"] = ":"
21
+ CONFIG["PACKAGE_NAME"] = ""
22
+ CONFIG["PACKAGE_TARNAME"] = ""
23
+ CONFIG["PACKAGE_VERSION"] = ""
24
+ CONFIG["PACKAGE_STRING"] = ""
25
+ CONFIG["PACKAGE_BUGREPORT"] = ""
26
+ CONFIG["exec_prefix"] = "$(prefix)"
27
+ CONFIG["bindir"] = "$(exec_prefix)/bin"
28
+ CONFIG["sbindir"] = "$(exec_prefix)/sbin"
29
+ CONFIG["libexecdir"] = "$(exec_prefix)/libexec"
30
+ CONFIG["datarootdir"] = "$(prefix)/share"
31
+ CONFIG["datadir"] = "$(datarootdir)"
32
+ CONFIG["sysconfdir"] = "$(prefix)/etc"
33
+ CONFIG["sharedstatedir"] = "$(prefix)/com"
34
+ CONFIG["localstatedir"] = "$(prefix)/var"
35
+ CONFIG["includedir"] = "$(prefix)/include"
36
+ CONFIG["oldincludedir"] = "/usr/include"
37
+ CONFIG["docdir"] = "$(datarootdir)/doc/$(PACKAGE)"
38
+ CONFIG["infodir"] = "$(datarootdir)/info"
39
+ CONFIG["htmldir"] = "$(docdir)"
40
+ CONFIG["dvidir"] = "$(docdir)"
41
+ CONFIG["pdfdir"] = "$(docdir)"
42
+ CONFIG["psdir"] = "$(docdir)"
43
+ CONFIG["libdir"] = "$(exec_prefix)/lib"
44
+ CONFIG["localedir"] = "$(datarootdir)/locale"
45
+ CONFIG["mandir"] = "$(datarootdir)/man"
46
+ CONFIG["ECHO_C"] = ""
47
+ CONFIG["ECHO_N"] = "-n"
48
+ CONFIG["ECHO_T"] = ""
49
+ CONFIG["LIBS"] = "-lwsock32 "
50
+ CONFIG["build_alias"] = "i686-darwin9.2.2"
51
+ CONFIG["host_alias"] = "i386-mingw32"
52
+ CONFIG["target_alias"] = "i386-mingw32"
53
+ CONFIG["MAJOR"] = "1"
54
+ CONFIG["MINOR"] = "8"
55
+ CONFIG["TEENY"] = "6"
56
+ CONFIG["build"] = "i686-pc-darwin9.2.2"
57
+ CONFIG["build_cpu"] = "i686"
58
+ CONFIG["build_vendor"] = "pc"
59
+ CONFIG["build_os"] = "darwin9.2.2"
60
+ CONFIG["host"] = "i386-pc-mingw32"
61
+ CONFIG["host_cpu"] = "i386"
62
+ CONFIG["host_vendor"] = "pc"
63
+ CONFIG["host_os"] = "mingw32"
64
+ CONFIG["target"] = "i386-pc-mingw32"
65
+ CONFIG["target_cpu"] = "i386"
66
+ CONFIG["target_vendor"] = "pc"
67
+ CONFIG["target_os"] = "mingw32"
68
+ CONFIG["CC"] = "i386-mingw32-gcc"
69
+ CONFIG["CFLAGS"] = "-g -O2 "
70
+ CONFIG["LDFLAGS"] = "-L. "
71
+ CONFIG["CPPFLAGS"] = ""
72
+ CONFIG["OBJEXT"] = "o"
73
+ CONFIG["CPP"] = "i386-mingw32-gcc -E"
74
+ CONFIG["GREP"] = "/usr/bin/grep"
75
+ CONFIG["EGREP"] = "/usr/bin/grep -E"
76
+ CONFIG["GNU_LD"] = "yes"
77
+ CONFIG["CPPOUTFILE"] = "-o conftest.i"
78
+ CONFIG["OUTFLAG"] = "-o "
79
+ CONFIG["YACC"] = "bison -y"
80
+ CONFIG["YFLAGS"] = ""
81
+ CONFIG["RANLIB"] = "i386-mingw32-ranlib"
82
+ CONFIG["AR"] = "i386-mingw32-ar"
83
+ CONFIG["AS"] = "i386-mingw32-as"
84
+ CONFIG["ASFLAGS"] = ""
85
+ CONFIG["NM"] = "i386-mingw32-nm"
86
+ CONFIG["WINDRES"] = "i386-mingw32-windres"
87
+ CONFIG["DLLWRAP"] = "i386-mingw32-dllwrap"
88
+ CONFIG["OBJDUMP"] = "i386-mingw32-objdump"
89
+ CONFIG["LN_S"] = "ln -s"
90
+ CONFIG["SET_MAKE"] = ""
91
+ CONFIG["INSTALL_PROGRAM"] = "$(INSTALL)"
92
+ CONFIG["INSTALL_SCRIPT"] = "$(INSTALL)"
93
+ CONFIG["INSTALL_DATA"] = "$(INSTALL) -m 644"
94
+ CONFIG["RM"] = "rm -f"
95
+ CONFIG["CP"] = "cp"
96
+ CONFIG["MAKEDIRS"] = "mkdir -p"
97
+ CONFIG["ALLOCA"] = ""
98
+ CONFIG["DLDFLAGS"] = " -Wl,--enable-auto-image-base,--enable-auto-import,--export-all"
99
+ CONFIG["ARCH_FLAG"] = ""
100
+ CONFIG["STATIC"] = ""
101
+ CONFIG["CCDLFLAGS"] = ""
102
+ CONFIG["LDSHARED"] = "i386-mingw32-gcc -shared -s"
103
+ CONFIG["DLEXT"] = "so"
104
+ CONFIG["DLEXT2"] = "dll"
105
+ CONFIG["LIBEXT"] = "a"
106
+ CONFIG["LINK_SO"] = ""
107
+ CONFIG["LIBPATHFLAG"] = " -L\"%s\""
108
+ CONFIG["RPATHFLAG"] = ""
109
+ CONFIG["LIBPATHENV"] = ""
110
+ CONFIG["TRY_LINK"] = ""
111
+ CONFIG["STRIP"] = "strip"
112
+ CONFIG["EXTSTATIC"] = ""
113
+ CONFIG["setup"] = "Setup"
114
+ CONFIG["MINIRUBY"] = "ruby -I/Users/jeremy/pkgs/ruby-1.8.6-p114 -rfake"
115
+ CONFIG["PREP"] = "fake.rb"
116
+ CONFIG["RUNRUBY"] = "$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`"
117
+ CONFIG["EXTOUT"] = ".ext"
118
+ CONFIG["ARCHFILE"] = ""
119
+ CONFIG["RDOCTARGET"] = ""
120
+ CONFIG["XCFLAGS"] = " -DRUBY_EXPORT"
121
+ CONFIG["XLDFLAGS"] = " -Wl,--stack,0x02000000"
122
+ CONFIG["LIBRUBY_LDSHARED"] = "i386-mingw32-gcc -shared -s"
123
+ CONFIG["LIBRUBY_DLDFLAGS"] = " -Wl,--enable-auto-image-base,--enable-auto-import,--export-all -Wl,--out-implib=$(LIBRUBY)"
124
+ CONFIG["rubyw_install_name"] = "rubyw"
125
+ CONFIG["RUBYW_INSTALL_NAME"] = "rubyw"
126
+ CONFIG["LIBRUBY_A"] = "lib$(RUBY_SO_NAME)-static.a"
127
+ CONFIG["LIBRUBY_SO"] = "$(RUBY_SO_NAME).dll"
128
+ CONFIG["LIBRUBY_ALIASES"] = ""
129
+ CONFIG["LIBRUBY"] = "lib$(LIBRUBY_SO).a"
130
+ CONFIG["LIBRUBYARG"] = "$(LIBRUBYARG_SHARED)"
131
+ CONFIG["LIBRUBYARG_STATIC"] = "-l$(RUBY_SO_NAME)-static"
132
+ CONFIG["LIBRUBYARG_SHARED"] = "-l$(RUBY_SO_NAME)"
133
+ CONFIG["SOLIBS"] = "$(LIBS)"
134
+ CONFIG["DLDLIBS"] = ""
135
+ CONFIG["ENABLE_SHARED"] = "yes"
136
+ CONFIG["MAINLIBS"] = ""
137
+ CONFIG["COMMON_LIBS"] = "m"
138
+ CONFIG["COMMON_MACROS"] = ""
139
+ CONFIG["COMMON_HEADERS"] = "windows.h winsock.h"
140
+ CONFIG["EXPORT_PREFIX"] = ""
141
+ CONFIG["MAKEFILES"] = "Makefile GNUmakefile"
142
+ CONFIG["arch"] = "i386-mingw32"
143
+ CONFIG["sitearch"] = "i386-msvcrt"
144
+ CONFIG["sitedir"] = "$(prefix)/lib/ruby/site_ruby"
145
+ CONFIG["configure_args"] = " '--host=i386-mingw32' '--target=i386-mingw32' '--build=i686-darwin9.2.2' '--prefix=/Users/jeremy/ruby-mingw32' 'build_alias=i686-darwin9.2.2' 'host_alias=i386-mingw32' 'target_alias=i386-mingw32'"
146
+ CONFIG["NROFF"] = "/usr/bin/nroff"
147
+ CONFIG["MANTYPE"] = "doc"
148
+ CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
149
+ CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
150
+ CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
151
+ CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
152
+ CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
153
+ CONFIG["topdir"] = File.dirname(__FILE__)
154
+ MAKEFILE_CONFIG = {}
155
+ CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
156
+ def Config::expand(val, config = CONFIG)
157
+ val.gsub!(/\$\$|\$\(([^()]+)\)|\$\{([^{}]+)\}/) do |var|
158
+ if !(v = $1 || $2)
159
+ '$'
160
+ elsif key = config[v = v[/\A[^:]+(?=(?::(.*?)=(.*))?\z)/]]
161
+ pat, sub = $1, $2
162
+ config[v] = false
163
+ Config::expand(key, config)
164
+ config[v] = key
165
+ key = key.gsub(/#{Regexp.quote(pat)}(?=\s|\z)/n) {sub} if pat
166
+ key
167
+ else
168
+ var
169
+ end
170
+ end
171
+ val
172
+ end
173
+ CONFIG.each_value do |val|
174
+ Config::expand(val)
175
+ end
176
+ end
177
+ RbConfig = Config # compatibility for ruby-1.9
178
+ CROSS_COMPILING = nil unless defined? CROSS_COMPILING
data/gemspec.rb ADDED
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'hitimes/version'
3
+ require 'tasks/config'
4
+
5
+ Hitimes::GEM_SPEC = Gem::Specification.new do |spec|
6
+ proj = Configuration.for('project')
7
+ spec.name = proj.name
8
+ spec.version = Hitimes::VERSION
9
+
10
+ spec.author = proj.author
11
+ spec.email = proj.email
12
+ spec.homepage = proj.homepage
13
+ spec.summary = proj.summary
14
+ spec.description = proj.description
15
+ spec.platform = Gem::Platform::RUBY
16
+
17
+
18
+ pkg = Configuration.for('packaging')
19
+ spec.files = pkg.files.all
20
+ spec.executables = pkg.files.bin.collect { |b| File.basename(b) }
21
+
22
+ # add dependencies here
23
+ spec.add_dependency("rake", ">= 0.8.1")
24
+ spec.add_dependency("configuration", ">= 0.0.5")
25
+ spec.add_dependency("mkrf", ">= 0.2.3")
26
+
27
+ if ext_conf = Configuration.for_if_exist?("extension") then
28
+ spec.extensions << ext_conf.configs
29
+ spec.require_paths << 'ext'
30
+ spec.extensions.flatten!
31
+ end
32
+
33
+ if rdoc = Configuration.for_if_exist?('rdoc') then
34
+ spec.has_rdoc = true
35
+ spec.extra_rdoc_files = pkg.files.rdoc
36
+ spec.rdoc_options = rdoc.options + [ "--main" , rdoc.main_page ]
37
+ else
38
+ spec.has_rdoc = false
39
+ end
40
+
41
+ if test = Configuration.for_if_exist?('testing') then
42
+ spec.test_files = test.files
43
+ end
44
+
45
+ if rf = Configuration.for_if_exist?('rubyforge') then
46
+ spec.rubyforge_project = rf.project
47
+ end
48
+ end
49
+
50
+ Hitimes::GEM_SPEC_WIN = Hitimes::GEM_SPEC.clone
51
+ Hitimes::GEM_SPEC_WIN.platform = ::Gem::Platform.new( "i386-mswin32_60" )
52
+ Hitimes::GEM_SPEC_WIN.extensions = []
53
+ Hitimes::GEM_SPEC_WIN.files += ["lib/hitimes_ext.so"]
54
+
55
+ Hitimes::SPECS = [ Hitimes::GEM_SPEC, Hitimes::GEM_SPEC_WIN ]
data/lib/hitimes.rb ADDED
@@ -0,0 +1,21 @@
1
+ #--
2
+ # Copyright (c) 2008 Jeremy Hinegardner
3
+ # All rights reserved. See LICENSE and/or COPYING for details.
4
+ #++
5
+
6
+ #
7
+ # The top level module containing the contents of the hitimes library
8
+ #
9
+ # use the library with:
10
+ #
11
+ # require 'hitimes'
12
+ #
13
+ module Hitimes
14
+ #
15
+ # Base class of all errors in Hitimes
16
+ #
17
+ class Error < ::StandardError; end
18
+ end
19
+ require 'hitimes/paths'
20
+ require 'hitimes/version'
21
+ require 'hitimes/timer'
@@ -0,0 +1,54 @@
1
+ #--
2
+ # Copyright (c) 2008 Jeremy Hinegardner
3
+ # All rights reserved. See LICENSE and/or COPYING for details.
4
+ #++
5
+ #
6
+ module Hitimes
7
+ #
8
+ # Access to various paths inside the project programatically
9
+ #
10
+ module Paths
11
+ #
12
+ # :call-seq:
13
+ # Hitimes::Paths.root_dir -> String
14
+ #
15
+ # Returns The full expanded path of the parent directory of +lib+
16
+ # going up the path from the current file. A trailing File::SEPARATOR
17
+ # is guaranteed.
18
+ #
19
+ def self.root_dir
20
+ unless @root_dir
21
+ path_parts = ::File.expand_path(__FILE__).split(::File::SEPARATOR)
22
+ lib_index = path_parts.rindex("lib")
23
+ @root_dir = path_parts[0...lib_index].join(::File::SEPARATOR) + ::File::SEPARATOR
24
+ end
25
+ return @root_dir
26
+ end
27
+
28
+ #
29
+ # :call-seq:
30
+ # Hitimes::Paths.lib_path( *args ) -> String
31
+ #
32
+ # Returns The full expanded path of the +lib+ directory below
33
+ # _root_dir_. All parameters passed in are joined onto the
34
+ # result. A trailing File::SEPARATOR is guaranteed if
35
+ # _args_ are *not* present.
36
+ #
37
+ def self.lib_path(*args)
38
+ self.sub_path("lib", *args)
39
+ end
40
+
41
+ #
42
+ # :call-seq:
43
+ # Hitimes::Paths.sub_path( sub, *args ) -> String
44
+ #
45
+ # Returns the full expanded path of the +sub+ directory below _root_dir. All
46
+ # _arg_ parameters passed in are joined onto the result. A trailing
47
+ # File::SEPARATOR is guaranteed if _args_ are *not* present.
48
+ #
49
+ def self.sub_path(sub,*args)
50
+ sp = ::File.join(root_dir, sub) + File::SEPARATOR
51
+ sp = ::File.join(sp, *args) if args
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,223 @@
1
+ #--
2
+ # Copyright (c) 2008 Jeremy Hinegardner
3
+ # All rights reserved. See LICENSE and/or COPYING for details.
4
+ #++
5
+
6
+ require 'hitimes'
7
+ require 'hitimes_ext'
8
+
9
+ module Hitimes
10
+ #
11
+ # A Timer combines together an Interval and a Stats object to provide
12
+ # aggregate information about timings.
13
+ #
14
+ # A Timer has many of the same methods as an Interval and would be used in
15
+ # preference to an Interval in those situations where you want to track
16
+ # statistics about the item you are monitoring.
17
+ #
18
+ class Timer
19
+
20
+ # holds all the statistics
21
+ attr_reader :stats
22
+
23
+ class << self
24
+
25
+ #
26
+ # :call-seq:
27
+ # Timer.now -> Timer
28
+ #
29
+ # Return a newly allocated Timer that has already been started
30
+ #
31
+ def now
32
+ t = Timer.new
33
+ t.start
34
+ return t
35
+ end
36
+
37
+ #
38
+ # :call-seq:
39
+ # Timer.measure { ... } -> Float
40
+ #
41
+ # Return the number of seconds that a block of code took to
42
+ # execute.
43
+ #
44
+ def measure( &block )
45
+ Interval.measure { yield }
46
+ end
47
+ end
48
+
49
+ #
50
+ # :call-seq:
51
+ # Timer.new -> Timer
52
+ #
53
+ def initialize
54
+ @stats = Stats.new
55
+ @current_interval = nil
56
+ end
57
+
58
+ #
59
+ # :call-seq:
60
+ # timer.current_interval -> Interval
61
+ #
62
+ # Return the current interval, if one doesn't exist create one.
63
+ #
64
+ def current_interval
65
+ @current_interval ||= Interval.new
66
+ end
67
+
68
+ #
69
+ # :call-seq:
70
+ # timer.running? -> true or false
71
+ #
72
+ # return whether or not the timer is currently running.
73
+ #
74
+ def running?
75
+ current_interval.running?
76
+ end
77
+
78
+ #
79
+ # :call-seq:
80
+ # timer.start -> nil
81
+ #
82
+ # Start the current timer, if the current timer is already started, then
83
+ # this is a noop.
84
+ #
85
+ def start
86
+ current_interval.start unless running?
87
+ nil
88
+ end
89
+
90
+ #
91
+ # :call-seq:
92
+ # timer.stop -> Float or nil
93
+ #
94
+ # Stop the current timer. This updates the stats and removes the current
95
+ # interval. If the timer is not running then this is a noop. If the
96
+ # timer was stopped then the duration of the last Interval is returned. If
97
+ # the timer was already stopped then false is returned.
98
+ #
99
+ def stop
100
+ if running? then
101
+ d = current_interval.stop
102
+ @current_interval = nil
103
+ stats.update( d )
104
+ return d
105
+ end
106
+ return false
107
+ end
108
+
109
+ #
110
+ # :call-seq:
111
+ # timer.measure { ... } -> Float
112
+ #
113
+ # Measure the execution of a block and add those stats to the running stats.
114
+ #
115
+ def measure( &block )
116
+ t = 0.0
117
+ begin
118
+ start
119
+ yield
120
+ ensure
121
+ t = stop
122
+ end
123
+ return t
124
+ end
125
+
126
+ #
127
+ # :call-seq:
128
+ # timer.split -> Flaot
129
+ #
130
+ # Split the current timer. Essentially, mark a split time. This means
131
+ # stop the current interval and create a new interval, but make sure
132
+ # that the new interval lines up exactly, timewise, behind the previous
133
+ # interval.
134
+ #
135
+ # If the timer is running, then split returns the duration of the previous
136
+ # interval, i.e. the split-time. If the timer is not running, nothing
137
+ # happens and false is returned.
138
+ #
139
+ def split
140
+ if running? then
141
+ next_interval = current_interval.split
142
+ d = current_interval.duration
143
+ stats.update( d )
144
+ @current_interval = next_interval
145
+ return d
146
+ end
147
+ return false
148
+ end
149
+
150
+ #
151
+ # :call-seq:
152
+ # timer.sum -> Float
153
+ # timer.duration -> Float
154
+ #
155
+ # The total time the timer has been measuring.
156
+ #
157
+ def sum
158
+ stats.sum
159
+ end
160
+ alias duration sum
161
+
162
+ #
163
+ # :call-seq:
164
+ # timer.mean -> Float
165
+ #
166
+ # The mean value of all the the stopped intervals. The current interval, if
167
+ # it is still running, is not included.
168
+ #
169
+ def mean
170
+ stats.mean
171
+ end
172
+
173
+ #
174
+ # :call-seq:
175
+ # timer.rate -> Float
176
+ #
177
+ # Return the rate of the states, which is the count / duration
178
+ #
179
+ def rate
180
+ stats.rate
181
+ end
182
+
183
+ #
184
+ # :call-seq:
185
+ # timer.stddev -> Float
186
+ #
187
+ # The standard deviation of all the intervals
188
+ #
189
+ def stddev
190
+ stats.stddev
191
+ end
192
+
193
+ #
194
+ # :call-seq:
195
+ # timer.count -> Integer
196
+ #
197
+ # The count of intervals in this timer
198
+ #
199
+ def count
200
+ stats.count
201
+ end
202
+
203
+ #
204
+ # :call-seq:
205
+ # timer.max -> Float
206
+ #
207
+ # The maximum duration of all the intervals this Timer has seen
208
+ #
209
+ def max
210
+ stats.max
211
+ end
212
+
213
+ #
214
+ # :call-seq:
215
+ # timer.min -> Float
216
+ #
217
+ # The minimum duration of all the intervals this Timer has seen
218
+ #
219
+ def min
220
+ stats.min
221
+ end
222
+ end
223
+ end