Project

General

Profile

Actions

Bug #13354

closed

Improve Time#<=> performance

Bug #13354: Improve Time#<=> performance

Added by watson1978 (Shizuo Fujita) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-dev:50034]

Description

Time#<=> will be faster around 60%.
If internal values would have Fixnum,
optimized function improves performance.
(https://github.com/ruby/ruby/blob/9b69e9fafc329aaa540d5adeb55124f020abfe3c/time.c#L57-L67)

Before

 user system total real 1.410000 0.000000 1.410000 ( 1.407848) 

After

 user system total real 0.880000 0.000000 0.880000 ( 0.886662) 

Test code

require 'benchmark' Benchmark.bmbm do |x| x.report do t1 = Time.now t2 = Time.now 10000000.times do t1 <=> t2 end end end 

Patch

The patch is in https://github.com/ruby/ruby/pull/1546

Actions

Also available in: PDF Atom