* time.c (time_utc_or_local): split into time_s_mkutc and
time_s_mktime without utc flag.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (rb_localtime_r): call tzset() only after TZ environment
variable is changed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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