* Both timegmw and gmtimew ignores leap second if the timezone doesn't
have leap seconds on the first call of init_leap_second_info()
* Add Bug::Time.reset_leap_second_info for testing
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Time.utc uses timegmw() and it uses leap second information.
If the given time is larger than known_leap_seconds_limit, it calls
find_time_t, which uses localtime(3) and calls stat(2) in it.
This patch avoid it by setting known_leap_seconds_limit to 0 if the timezone doesn't have leapsecond information (if no leap second is found "now", I assume the timezone doesn't have leapsecond information).
Before:
% time ./miniruby --disable-gem -e'time = Time.now; year = time.year; month = time.month; day = time.day; hour = time.hour; min = time.min; sec = time.sec + time.subsec; i = 0; while i < 100000; ::Time.utc(year, month, day, hour, min, sec); i += 1; end'
./miniruby --disable-gem 0.35s user 0.19s system 99% cpu 0.542 total
After:
% time ./miniruby --disable-gem -e'time = Time.now; year = time.year; month = time.month; day = time.day; hour = time.hour; min = time.min; sec = time.sec + time.subsec; i = 0; while i < 100000; ::Time.utc(year, month, day, hour, min, sec); i += 1; end'
./miniruby --disable-gem 0.23s user 0.00s system 99% cpu 0.233 total
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c: state that Time#localtime does nothing when nothing
changes. [ruby-core:87675] [Bug #14880]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
No need to waste space on "to_r" and "to_int" which are
predefined in defs/id.def
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
compat_common_month_table and compat_leap_month_table should
not be writable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
To be precise C90 says "A bit-field may have type int, unsigned
int, or signed int". It is clear that char or enum are NG.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (wadd): use internal addv() function to calculate internal value in
Time object. On 64-bit machine, Time object might have Fixnum object
internally by default and addv() can calculate Fixnum objects directly.
* time.c (wsub): use internal subv() function due the same reason in above.
Time#+ & Time#- will be faster around 15%.
[ruby-dev:50036] [Bug #13357] [Fix GH-1547]
### Before
user system total real
Time#+ 0.820000 0.000000 0.820000 ( 0.818081)
Time#- 0.810000 0.000000 0.810000 ( 0.813835)
### After
user system total real
Time#+ 0.710000 0.000000 0.710000 ( 0.710241)
Time#- 0.710000 0.010000 0.720000 ( 0.714151)
### Test code
require 'benchmark'
Benchmark.bmbm do |x|
x.report "Time#+" do
t = Time.now
2000000.times do
t + 1
end
end
x.report "Time#-" do
t = Time.now
2000000.times do
t - 1
end
end
end
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (wcmp): use internal cmp() function for comparing internal Fixnum value
in Time objects. On 64-bit machine, Time object might have Fixnum object
internally by default and cmp() can compare the Fixnum objects directly.
Time#<=> will be faster around 60% on 64-bit machine.
* time.c (cmp): add optimized path for comparing internal Bignum value by using
rb_big_cmp() API. On 32-bit machine, Time object might have Bignum object
internally by default.
Time#<=> will be faster around 50% on 32-bit machine.
[ruby-dev:50034] [Bug #13354] [Fix GH-1546]
### Before
user system total real
Fixnum 1.410000 0.000000 1.410000 ( 1.407848)
Bignum 1.550000 0.000000 1.550000 ( 1.549145)
### After
user system total real
Fixnum 0.880000 0.000000 0.880000 ( 0.886662)
Bignum 1.050000 0.000000 1.050000 ( 1.047994)
### Test code
require 'benchmark'
Benchmark.bmbm do |x|
x.report "Fixnum" do
t1 = Time.now
t2 = Time.now
10000000.times do
t1 <=> t2
end
end
x.report "Bignum" do
t1 = Time.at(2 ** 64)
t2 = Time.at(2 ** 64 + 1)
10000000.times do
t1 <=> t2
end
end
end
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
clang 4.0.0 emitted a warning: "taking address of packed member
'subsecx' of class or structure 'vtm' may result in an unaligned
pointer value [-Waddress-of-packed-member]".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (divv): add suffix to get rid of the name in C standard
library, and others together.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Time#to_i will be faster around 80% (on 64-bit platforms).
* Before
user system total real
2.840000 0.000000 2.840000 ( 2.847238)
* After
user system total real
1.600000 0.000000 1.600000 ( 1.598911)
* Test code
require 'benchmark'
Benchmark.bmbm do |x|
x.report do
t = Time.now
20000000.times do
t.to_i
end
end
end
* time.c (_div): new function avoid rb_funcall
(div): replace with new _div function
[ruby-core:80636] [Bug #13418]
Thanks to Watson <watson1978@gmail.com> for the patch.
From: Watson <watson1978@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
strftime format strings which are dynamically-generated will benefit
from avoiding garbage, here.
* time.c (time_strftime): use rb_str_tmp_frozen_{acquire,release}
* test/ruby/test_time.rb (test_strftime_no_hidden_garbage): new test
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (usec2subsecx): fix return type, which is a numeric
object but not a long int. [ruby-dev:49912] [Bug #13066]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (time_arg): dump sec and subsec arguments if subsecx is
insane.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (num_exact): show the original argument when conversion
failed, instead of intermediate nil.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (time_timespec): use RB_TYPE_P instead of switching by
TYPE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (validate_vtm): separate validation failure messages for
each members.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (vtm_add_offset): Fix yday on last day of year.
[ruby-core:72878] [Bug #11994] Fixed by Andrew White.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
on mswin CI, then force to prevent `vtm->subsecx` from GC. this is
experimental.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* strftime.c (rb_strftime_with_timespec): append formatted results
to the given string with expanding, and also deal with NUL chars.
* strftime.c (rb_strftime, rb_strftime_timespec): return formatted
string, not the length put in the given buffer.
* time.c (rb_strftime_alloc): no longer needs to retry with
reallocating buffers.
* time.c (time_strftime): no longer needs to split by NUL chars.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
are valid pointers.
maybe checking them in wdivmod0() is better manner, but I guess that
passing real dummy pointers may be faster than checking and branching
in wdivmod0().
this commit fixes SEGV on 32bit and LLP64 platforms.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (wmul): use MUL_OVERFLOW_FIXWV_P and only switch.
* time.c (wmul): use mul which has Fixnum optimization.
* time.c (rb_time_magnify): If WIDEVALUE_IS_WIDER, wmul() has the same
optimized logic, else mul() has also the similar logic for Fixnum.
* time.c (rb_time_unmagnify): almost ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (wquo): use quo which has Fixnum optimization.
* time.c (wdivmod0): added for WIDEVALUE_IS_WIDER.
* time.c (wdivmod): use wdivmod0 and divmodv.
divmodv has Fixnum optimization.
* time.c (wdiv): use wdivmod0 and div to avoid the use of divmodv which
calls id_quo whose return value is array.
* time.c (wmod): use wdivmod0 and mod to avoid the use of divmodv which
calls id_quo whose return value is array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
x == FIXNUM_MIN && y == -1. This must be a rare case and it is
expected compiler to handle well.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e