home_run 0.9.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/CHANGELOG +3 -0
- data/LICENSE +19 -0
- data/README.rdoc +314 -0
- data/Rakefile +136 -0
- data/bench/cpu_bench.rb +279 -0
- data/bench/dt_garbage_bench.rb +11 -0
- data/bench/dt_mem_bench.rb +14 -0
- data/bench/garbage_bench.rb +11 -0
- data/bench/mem_bench.rb +14 -0
- data/bin/home_run +91 -0
- data/default.mspec +12 -0
- data/ext/1.8/date_ext.so +0 -0
- data/ext/1.9/date_ext.so +0 -0
- data/ext/date/format.rb +842 -0
- data/ext/date.rb +7 -0
- data/ext/date_ext.c +4548 -0
- data/ext/date_parser.c +367 -0
- data/ext/date_parser.rl +134 -0
- data/ext/datetime.c +2804 -0
- data/ext/extconf.rb +6 -0
- data/spec/date/accessor_spec.rb +176 -0
- data/spec/date/add_month_spec.rb +26 -0
- data/spec/date/add_spec.rb +23 -0
- data/spec/date/boat_spec.rb +38 -0
- data/spec/date/civil_spec.rb +147 -0
- data/spec/date/commercial_spec.rb +153 -0
- data/spec/date/constants_spec.rb +44 -0
- data/spec/date/conversions_spec.rb +246 -0
- data/spec/date/day_spec.rb +73 -0
- data/spec/date/downto_spec.rb +17 -0
- data/spec/date/eql_spec.rb +16 -0
- data/spec/date/format_spec.rb +52 -0
- data/spec/date/gregorian_spec.rb +52 -0
- data/spec/date/hash_spec.rb +11 -0
- data/spec/date/julian_spec.rb +129 -0
- data/spec/date/leap_spec.rb +19 -0
- data/spec/date/minus_month_spec.rb +25 -0
- data/spec/date/minus_spec.rb +51 -0
- data/spec/date/next_prev_spec.rb +108 -0
- data/spec/date/ordinal_spec.rb +83 -0
- data/spec/date/parse_spec.rb +442 -0
- data/spec/date/parsing_spec.rb +77 -0
- data/spec/date/relationship_spec.rb +28 -0
- data/spec/date/step_spec.rb +109 -0
- data/spec/date/strftime_spec.rb +223 -0
- data/spec/date/strptime_spec.rb +201 -0
- data/spec/date/succ_spec.rb +20 -0
- data/spec/date/today_spec.rb +15 -0
- data/spec/date/upto_spec.rb +17 -0
- data/spec/datetime/accessor_spec.rb +218 -0
- data/spec/datetime/add_month_spec.rb +26 -0
- data/spec/datetime/add_spec.rb +36 -0
- data/spec/datetime/boat_spec.rb +43 -0
- data/spec/datetime/constructor_spec.rb +142 -0
- data/spec/datetime/conversions_spec.rb +54 -0
- data/spec/datetime/day_spec.rb +73 -0
- data/spec/datetime/downto_spec.rb +39 -0
- data/spec/datetime/eql_spec.rb +17 -0
- data/spec/datetime/format_spec.rb +59 -0
- data/spec/datetime/hash_spec.rb +11 -0
- data/spec/datetime/leap_spec.rb +19 -0
- data/spec/datetime/minus_month_spec.rb +25 -0
- data/spec/datetime/minus_spec.rb +77 -0
- data/spec/datetime/next_prev_spec.rb +138 -0
- data/spec/datetime/now_spec.rb +18 -0
- data/spec/datetime/parse_spec.rb +390 -0
- data/spec/datetime/parsing_spec.rb +77 -0
- data/spec/datetime/relationship_spec.rb +28 -0
- data/spec/datetime/step_spec.rb +155 -0
- data/spec/datetime/strftime_spec.rb +118 -0
- data/spec/datetime/strptime_spec.rb +117 -0
- data/spec/datetime/succ_spec.rb +24 -0
- data/spec/datetime/upto_spec.rb +39 -0
- data/spec/spec_helper.rb +59 -0
- metadata +154 -0
data/CHANGELOG
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 Jeremy Evans
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to
|
5
|
+
deal in the Software without restriction, including without limitation the
|
6
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
16
|
+
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,314 @@
|
|
1
|
+
= home_run
|
2
|
+
|
3
|
+
home_run is an implementation of ruby's Date/DateTime classes in C,
|
4
|
+
with much better performance (20-200x) than the version in the
|
5
|
+
standard library, while being almost completely compatible.
|
6
|
+
|
7
|
+
== Performance increase (microbenchmarks)
|
8
|
+
|
9
|
+
The speedup you'll get depends mostly on your version of ruby, but
|
10
|
+
also on your operating system, platform, and compiler. Here are
|
11
|
+
some comparative results for common methods:
|
12
|
+
|
13
|
+
# | i386 | i386 | i386 | i386 | amd64 |
|
14
|
+
# |Windows| Linux | Linux | Linux |OpenBSD|
|
15
|
+
# | 1.8.6 | 1.8.7 | 1.9.1 | 1.9.2 | 1.9.2 |
|
16
|
+
# |-------+-------+-------+------ +-------|
|
17
|
+
Date.civil | 82x | 66x | 27x | 21x | 14x |
|
18
|
+
Date.parse | 56x | 56x | 33x | 30x | 25x |
|
19
|
+
Date.today | 17x | 6x | 2x | 2x | 2x |
|
20
|
+
Date.strptime | 43x | 62x | 63x | 37x | 23x |
|
21
|
+
DateTime.civil | 252x | 146x | 52x | 41x | 17x |
|
22
|
+
DateTime.parse | 52x | 54x | 32x | 27x | 20x |
|
23
|
+
DateTime.now | 78x | 35x | 11x | 8x | 4x |
|
24
|
+
DateTime.strptime | 63x | 71x | 58x | 35x | 23x |
|
25
|
+
Date#strftime | 156x | 104x | 110x | 70x | 62x |
|
26
|
+
Date#+ | 34x | 32x | 5x | 5x | 4x |
|
27
|
+
Date#<< | 177x | 220x | 86x | 72x | 40x |
|
28
|
+
Date#to_s | 15x | 6x | 5x | 4x | 2x |
|
29
|
+
DateTime#strftime | 146x | 107x | 114x | 71x | 60x |
|
30
|
+
DateTime#+ | 34x | 37x | 8x | 6x | 3x |
|
31
|
+
DateTime#<< | 88x | 106x | 40x | 33x | 16x |
|
32
|
+
DateTime#to_s | 144x | 47x | 54x | 29x | 24x |
|
33
|
+
|
34
|
+
== Real world difference
|
35
|
+
|
36
|
+
The standard library Date class is slow enough to be the
|
37
|
+
bottleneck in much (if not most) of code that uses it.
|
38
|
+
Here's a real world benchmark showing the retrieval of
|
39
|
+
data from a database, first without home_run, and then
|
40
|
+
with home_run.
|
41
|
+
|
42
|
+
$ script/console production
|
43
|
+
Loading production environment (Rails 2.3.5)
|
44
|
+
>> require 'benchmark'
|
45
|
+
=> false
|
46
|
+
>> puts Benchmark.measure{Employee.all}
|
47
|
+
0.270000 0.020000 0.290000 ( 0.460604)
|
48
|
+
=> nil
|
49
|
+
>> puts Benchmark.measure{Notification.all}
|
50
|
+
2.510000 0.050000 2.560000 ( 2.967896)
|
51
|
+
=> nil
|
52
|
+
|
53
|
+
$ home_run script/console production
|
54
|
+
Loading production environment (Rails 2.3.5)
|
55
|
+
>> require 'benchmark'
|
56
|
+
=> false
|
57
|
+
>> puts Benchmark.measure{Employee.all}
|
58
|
+
0.100000 0.000000 0.100000 ( 0.114747)
|
59
|
+
=> nil
|
60
|
+
>> puts Benchmark.measure{Notification.all}
|
61
|
+
0.860000 0.010000 0.870000 ( 0.939594)
|
62
|
+
|
63
|
+
Without changing any application code, there's a 4x
|
64
|
+
increase when retrieving all employees, and a 3x
|
65
|
+
increase when retrieving all notifications. The
|
66
|
+
main reason for the performance difference between
|
67
|
+
these two models is that Employee has 5 date columns,
|
68
|
+
while Notification only has 3.
|
69
|
+
|
70
|
+
== Installing the gem
|
71
|
+
|
72
|
+
gem install home_run
|
73
|
+
|
74
|
+
The standard gem requires compiling from source, so you need a working
|
75
|
+
compiler toolchain. Since few Windows users have a working compiler
|
76
|
+
toolchain, a windows binary gem is available that works on both 1.8
|
77
|
+
and 1.9.
|
78
|
+
|
79
|
+
== Installing into site_ruby
|
80
|
+
|
81
|
+
This is only necessary on ruby 1.8, as on ruby 1.9, gem directories
|
82
|
+
come before the standard library directories in the load path.
|
83
|
+
|
84
|
+
After installing the gem:
|
85
|
+
|
86
|
+
home_run --install
|
87
|
+
|
88
|
+
Installing into site_ruby means that ruby will always use home_run's
|
89
|
+
Date/DateTime classes instead of the ones in the standard library.
|
90
|
+
|
91
|
+
If you ever want to uninstall from site_ruby:
|
92
|
+
|
93
|
+
home_run --uninstall
|
94
|
+
|
95
|
+
== Running without installing into site_ruby
|
96
|
+
|
97
|
+
Just like installing into site_ruby, this should only be necessary
|
98
|
+
on ruby 1.8.
|
99
|
+
|
100
|
+
If you don't want to install into site_ruby, you can use home_run's
|
101
|
+
Date/DateTime classes for specific programs by running your script
|
102
|
+
using home_run:
|
103
|
+
|
104
|
+
home_run ruby ...
|
105
|
+
home_run irb ...
|
106
|
+
home_run unicorn ...
|
107
|
+
home_run rake ...
|
108
|
+
|
109
|
+
This manipulates the RUBYLIB and RUBYOPT environment variables so
|
110
|
+
that home_run's Date/DateTime classes will be used.
|
111
|
+
|
112
|
+
== Running the specs
|
113
|
+
|
114
|
+
You can run the specs after installing the gem, if you have MSpec
|
115
|
+
installed (gem install mspec):
|
116
|
+
|
117
|
+
home_run --spec
|
118
|
+
|
119
|
+
If there are any failures, please report them as a bug.
|
120
|
+
|
121
|
+
== Running comparative benchmarks
|
122
|
+
|
123
|
+
You can run the benchmarks after installing the gem:
|
124
|
+
|
125
|
+
home_run --bench
|
126
|
+
|
127
|
+
The benchmarks compare home_run's Date/DateTime classes to the
|
128
|
+
standard library ones, showing you the amount of time an average
|
129
|
+
call to each method takes for both the standard library and
|
130
|
+
home_run, and the number of times home_run is faster or slower.
|
131
|
+
Output is in CSV, so an entry like this:
|
132
|
+
|
133
|
+
Date._parse,362562,10235,35.42
|
134
|
+
|
135
|
+
means that:
|
136
|
+
|
137
|
+
* The standard library's Date._parse averaged 362,562 nanoseconds
|
138
|
+
per call.
|
139
|
+
* home_run's Date._parse averaged 10,235 nanoseconds per call.
|
140
|
+
* Therefore, home_run's Date._parse method is 35.42 times faster
|
141
|
+
|
142
|
+
The bench task tries to be fair by ensuring that it runs the
|
143
|
+
benchmark for at least two seconds for both the standard
|
144
|
+
library and home_run's versions.
|
145
|
+
|
146
|
+
== Usage
|
147
|
+
|
148
|
+
home_run aims to be compatible with the standard library, except
|
149
|
+
for differences mentioned below. So you can use it the same way
|
150
|
+
you use the standard library.
|
151
|
+
|
152
|
+
== Differences from standard library
|
153
|
+
|
154
|
+
* Written in C (mostly) instead of ruby. Stores information in a
|
155
|
+
C structure, and therefore has a range limitation. home_run
|
156
|
+
cannot handle dates after 5874773-08-15 or before -5877752-05-08
|
157
|
+
on 32-bit platforms (with larger limits for 64-bit platforms).
|
158
|
+
* The Date class does not store fractional days (e.g. hours, minutes),
|
159
|
+
or offsets. The DateTime class does handle fractional days and
|
160
|
+
offsets.
|
161
|
+
* The DateTime class stores fractional days as the number of
|
162
|
+
nanoseconds since midnight, so it cannot deal with differences
|
163
|
+
less than a nanosecond.
|
164
|
+
* Neither Date nor DateTime uses rational. Places where the standard
|
165
|
+
library returns rationals, home_run returns integers or floats.
|
166
|
+
* Because rational is not used, it is not required. This can break
|
167
|
+
other libraries that use rational without directly requiring it.
|
168
|
+
* There is no support for modifying the date of calendar reform, the
|
169
|
+
sg arguments are ignored and the Gregorian calendar is always used.
|
170
|
+
This means that julian day 0 is -4173-11-24, instead of -4712-01-01.
|
171
|
+
* The undocumented Date#strftime format modifiers are not supported.
|
172
|
+
* The DateTime offset is checked for reasonableness. home_run
|
173
|
+
does not support offsets with an absolute difference of more than
|
174
|
+
14 hours from UTC.
|
175
|
+
* DateTime offsets are stored in minutes, so it will round offsets
|
176
|
+
with fractional minutes to the nearest minute.
|
177
|
+
* All public class and instance methods for both Date and DateTime
|
178
|
+
are implemented, except that the allocate class method is not
|
179
|
+
available and on 1.9, _dump and _load are used instead of
|
180
|
+
marshal_dump and marshal_load.
|
181
|
+
* Only the public API is compatible, the private methods in the
|
182
|
+
standard library are not implemented.
|
183
|
+
* The marshalling format differs from the one used by the standard
|
184
|
+
library. Note that the 1.8 and 1.9 standard library date
|
185
|
+
marshalling formats differ from each other.
|
186
|
+
* Date#step treats the step value as an integer, so it cannot handle
|
187
|
+
steps of fractional days. DateTime#step can handle fractional
|
188
|
+
day steps, though.
|
189
|
+
* When parsing the %Q modifier in _strptime, the hash returned
|
190
|
+
includes an Integer :seconds value and a Float :sec_fraction
|
191
|
+
value instead of a single rational :seconds value.
|
192
|
+
* The string returned by #inspect has a different format, since it
|
193
|
+
doesn't use rational.
|
194
|
+
* The conversion of 2-digit years to 4-digit years in Date._parse
|
195
|
+
is set to true by default. On ruby 1.8, the standard library
|
196
|
+
has it set to false by default.
|
197
|
+
* You can use the Date::Format::STYLE hash to change how to parse
|
198
|
+
DD/DD/DD and DD.DD.DD date formats, allowing you to get ruby 1.9
|
199
|
+
behavior on 1.8 or vice-versa. This is probably the only new
|
200
|
+
feature in that isn't in the standard library.
|
201
|
+
|
202
|
+
Any other differences will either be documented here or considered
|
203
|
+
bugs, so please report any other differences you find.
|
204
|
+
|
205
|
+
== Reporting issues/bugs
|
206
|
+
|
207
|
+
home_run uses GitHub Issues for tracking issues/bugs:
|
208
|
+
|
209
|
+
http://github.com/jeremyevans/home_run/issues
|
210
|
+
|
211
|
+
== Contributing
|
212
|
+
|
213
|
+
The source code is on GitHub:
|
214
|
+
|
215
|
+
http://github.com/jeremyevans/home_run
|
216
|
+
|
217
|
+
To get a copy:
|
218
|
+
|
219
|
+
git clone git://github.com/jeremyevans/home_run.git
|
220
|
+
|
221
|
+
There are a few requirements:
|
222
|
+
|
223
|
+
* Rake
|
224
|
+
* Ragel 6.5+ for building the ragel parser. The compiled C file is
|
225
|
+
included in the gem, so people installing the gem don't need
|
226
|
+
Ragel. The compiled C file is not checked into git, so you need
|
227
|
+
Ragel if you are working with a git checkout.
|
228
|
+
* MSpec (not RSpec) for running the specs. The specs are based on
|
229
|
+
the rubyspec specs, which is why they use MSpec.
|
230
|
+
* RDoc 2.5.10+ if you want to build the documentation.
|
231
|
+
|
232
|
+
The directory layout is slightly unusual in that there is no
|
233
|
+
lib directory and there are .rb files in the ext directory. This may
|
234
|
+
change in a future version.
|
235
|
+
|
236
|
+
== Building
|
237
|
+
|
238
|
+
To build the library from a git checkout, after installing the
|
239
|
+
requirements:
|
240
|
+
|
241
|
+
rake parser build
|
242
|
+
|
243
|
+
== Testing
|
244
|
+
|
245
|
+
The default rake task runs the specs, so just run:
|
246
|
+
|
247
|
+
rake
|
248
|
+
|
249
|
+
You need to build the library before running the specs.
|
250
|
+
|
251
|
+
== Benchmarking
|
252
|
+
|
253
|
+
To see the speedup that home_run gives you over the standard library:
|
254
|
+
|
255
|
+
rake bench
|
256
|
+
|
257
|
+
To see how much less memory home_run uses compared to the standard
|
258
|
+
library:
|
259
|
+
|
260
|
+
rake mem_bench
|
261
|
+
|
262
|
+
To see how much less garbage is created when instantiating objects
|
263
|
+
with home_run compared to the standard library:
|
264
|
+
|
265
|
+
rake garbage_bench
|
266
|
+
|
267
|
+
If you want to run all three benchmarks at once:
|
268
|
+
|
269
|
+
rake bench_all
|
270
|
+
|
271
|
+
== Platforms Supported
|
272
|
+
|
273
|
+
home_run has been tested on the following:
|
274
|
+
|
275
|
+
=== Operating Systems/Platforms
|
276
|
+
|
277
|
+
* Linux (x86_64, i386)
|
278
|
+
* Mac OS X 10.6 (x86_64, i386)
|
279
|
+
* OpenBSD (amd64, i386)
|
280
|
+
* Windows XP (i386)
|
281
|
+
|
282
|
+
=== Compiler Versions
|
283
|
+
|
284
|
+
* gcc (3.3.5, 4.2.1, 4.4.3, 4.5.0)
|
285
|
+
|
286
|
+
=== Ruby Versions
|
287
|
+
|
288
|
+
* rbx head (as of commit 0e265b92727cf3536053, 2010-08-16)
|
289
|
+
* ruby 1.8.6 (p0, p398, p399)
|
290
|
+
* ruby 1.8.7 (p174, p248, p299, p302)
|
291
|
+
* ruby 1.9.1 (p243, p378, p429, p430)
|
292
|
+
* ruby 1.9.2 (p0)
|
293
|
+
* ruby head
|
294
|
+
|
295
|
+
If your platform, compiler version, or ruby version is not listed
|
296
|
+
above, please test and send me a report including:
|
297
|
+
|
298
|
+
* Your operating system and platform (e.g. i386, x86_64/amd64)
|
299
|
+
* Your compiler
|
300
|
+
* Your ruby version
|
301
|
+
* The output of home_run --spec
|
302
|
+
* The output of home_run --bench
|
303
|
+
|
304
|
+
== Todo
|
305
|
+
|
306
|
+
* Get it working on jruby with the cext branch
|
307
|
+
* Add more specs for greater code coverage and to test
|
308
|
+
boundry conditions
|
309
|
+
* Expand main ragel parser to handle more formats
|
310
|
+
* Add ragel versions of the 1.9 date parsing functions
|
311
|
+
|
312
|
+
== Author
|
313
|
+
|
314
|
+
Jeremy Evans <code@jeremyevans.net>
|
data/Rakefile
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
require "rake"
|
2
|
+
require "rake/clean"
|
3
|
+
require 'rbconfig'
|
4
|
+
|
5
|
+
CLEAN.include %w'ext/Makefile ext/date_ext.*o **/*.rbc *.core rdoc'
|
6
|
+
RUBY=ENV['RUBY'] || File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
7
|
+
|
8
|
+
begin
|
9
|
+
gem 'rdoc'
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require "rake/rdoctask"
|
12
|
+
Rake::RDocTask.new do |rdoc|
|
13
|
+
rdoc.rdoc_dir = "rdoc"
|
14
|
+
rdoc.options += ["--quiet", "--line-numbers", "--inline-source", '--title',
|
15
|
+
'home_run: Fast Date/DateTime classes for ruby', '--main', 'README.rdoc']
|
16
|
+
rdoc.rdoc_files.add %w"README.rdoc CHANGELOG LICENSE ext/**/*.rb ext/*.c"
|
17
|
+
end
|
18
|
+
rescue LoadError
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Run the specs with mspec"
|
22
|
+
task :default => :spec
|
23
|
+
task :spec do
|
24
|
+
ENV['RUBY'] ||= RUBY
|
25
|
+
sh %{mspec}
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Build the gem"
|
29
|
+
task :gem => [:clean, :parser] do
|
30
|
+
sh %{gem build home_run.gemspec}
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Try to clean up everything"
|
34
|
+
task :distclean do
|
35
|
+
CLEAN.concat(%w'pkg home_run-*.gem ext/1.* tmp rdoc ext/date_parser.c')
|
36
|
+
Rake::Task[:clean].invoke
|
37
|
+
end
|
38
|
+
|
39
|
+
if RUBY_PLATFORM !~ /win|w32/ and File.directory?(File.join(File.expand_path(ENV['HOME']), '.rake-compiler'))
|
40
|
+
begin
|
41
|
+
require "rake/extensiontask"
|
42
|
+
ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
|
43
|
+
load('home_run.gemspec')
|
44
|
+
desc "Internal--cross compile the windows binary gem"
|
45
|
+
cross_platform = ENV['CROSS_PLATFORM'] || 'i386-mingw32'
|
46
|
+
Rake::ExtensionTask.new('date_ext', HOME_RUN_GEMSPEC) do |ext|
|
47
|
+
ext.name = 'date_ext'
|
48
|
+
ext.ext_dir = 'ext'
|
49
|
+
ext.lib_dir = 'ext'
|
50
|
+
ext.cross_compile = true
|
51
|
+
ext.cross_platform = cross_platform
|
52
|
+
ext.source_pattern = '*.c'
|
53
|
+
end
|
54
|
+
|
55
|
+
# FIXME: Incredibly hacky, should figure out how to get
|
56
|
+
# rake compiler to do this correctly
|
57
|
+
desc "Build the cross compiled windows binary gem"
|
58
|
+
task :windows_gem => [:clean, :parser] do
|
59
|
+
sh %{rm -rf tmp pkg home_run-*.gem ext/1.*}
|
60
|
+
system %{rake cross native gem}
|
61
|
+
unless File.directory?('pkg')
|
62
|
+
sh "cp ext/*.c tmp/#{cross_platform}/date_ext/1.8.6"
|
63
|
+
system %{rake cross native gem}
|
64
|
+
sh %{cp ext/*.c tmp/#{cross_platform}/date_ext/1.9.1}
|
65
|
+
system %{rake cross native gem}
|
66
|
+
sh %{rake cross native gem}
|
67
|
+
end
|
68
|
+
sh %{rm -rf home_run-*.gem tmp ext/1.*}
|
69
|
+
sh %{mv pkg/home_run-*.gem .}
|
70
|
+
sh %{rmdir pkg}
|
71
|
+
end
|
72
|
+
rescue LoadError
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
desc "Build the ragel parser"
|
77
|
+
task :parser do
|
78
|
+
sh %{cd ext && ragel date_parser.rl}
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Build the extension"
|
82
|
+
task :build=>[:clean] do
|
83
|
+
sh %{cd ext && #{RUBY} extconf.rb && make}
|
84
|
+
end
|
85
|
+
|
86
|
+
desc "Build debug version of extension"
|
87
|
+
task :build_debug=>[:clean] do
|
88
|
+
ENV['DEBUG'] = '1'
|
89
|
+
sh %{cd ext && #{RUBY} extconf.rb && make}
|
90
|
+
end
|
91
|
+
|
92
|
+
desc "Start an IRB shell using the extension"
|
93
|
+
task :irb do
|
94
|
+
irb = ENV['IRB'] || File.join(RbConfig::CONFIG['bindir'], File.basename(RUBY).sub('ruby', 'irb'))
|
95
|
+
sh %{#{irb} -I ext -r date}
|
96
|
+
end
|
97
|
+
|
98
|
+
desc "Run comparative benchmarks"
|
99
|
+
task :bench do
|
100
|
+
sh %{#{RUBY} bench/cpu_bench.rb}
|
101
|
+
end
|
102
|
+
|
103
|
+
desc "Run all benchmarks"
|
104
|
+
task :bench_all => [:bench, :mem_bench, :garbage_bench]
|
105
|
+
|
106
|
+
desc "Run comparative memory benchmarks"
|
107
|
+
task :mem_bench do
|
108
|
+
if RUBY_PLATFORM =~ /win|w32/
|
109
|
+
puts "Memory benchmarks not supported on Windows"
|
110
|
+
next
|
111
|
+
end
|
112
|
+
|
113
|
+
stdlib = `#{RUBY} -I #{RbConfig::CONFIG['rubylibdir']} bench/mem_bench.rb`.to_i
|
114
|
+
home_run = `#{RUBY} -I ext bench/mem_bench.rb`.to_i
|
115
|
+
puts "Date memory use,#{stdlib}KB,#{home_run}KB,#{sprintf('%0.1f', stdlib/home_run.to_f)}"
|
116
|
+
|
117
|
+
stdlib = `#{RUBY} -I #{RbConfig::CONFIG['rubylibdir']} bench/dt_mem_bench.rb`.to_i
|
118
|
+
home_run = `#{RUBY} -I ext bench/dt_mem_bench.rb`.to_i
|
119
|
+
puts "DateTime memory use,#{stdlib}KB,#{home_run}KB,#{sprintf('%0.1f', stdlib/home_run.to_f)}"
|
120
|
+
end
|
121
|
+
|
122
|
+
desc "Run comparative garbage creation benchmarks"
|
123
|
+
task :garbage_bench do
|
124
|
+
if RUBY_PLATFORM =~ /win|w32/
|
125
|
+
puts "Garbage creation benchmarks not supported on Windows"
|
126
|
+
next
|
127
|
+
end
|
128
|
+
|
129
|
+
stdlib = `#{RUBY} -I #{RbConfig::CONFIG['rubylibdir']} bench/garbage_bench.rb`.to_i
|
130
|
+
home_run = `#{RUBY} -I ext bench/garbage_bench.rb`.to_i
|
131
|
+
puts "Date garbage created,#{stdlib}KB,#{home_run}KB,#{sprintf('%0.1f', stdlib/home_run.to_f)}"
|
132
|
+
|
133
|
+
stdlib = `#{RUBY} -I #{RbConfig::CONFIG['rubylibdir']} bench/dt_garbage_bench.rb`.to_i
|
134
|
+
home_run = `#{RUBY} -I ext bench/dt_garbage_bench.rb`.to_i
|
135
|
+
puts "DateTime garbage created,#{stdlib}KB,#{home_run}KB,#{sprintf('%0.1f', stdlib/home_run.to_f)}"
|
136
|
+
end
|