Issue #18293 has been updated by k0kubun (Takashi Kokubun).

Assignee set to ko1 (Koichi Sasada)
Status changed from Open to Closed

Thanks to commit:f943264565f3072a30616fa93ffa3da3790294b0, master is no longer 25% slower than Ruby 3.0.0 at `Time.at(0)`.

```
$ benchmark-driver -v --rbenv='3.0.0;master::ruby' benchmark/time_at.yml
3.0.0: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
master: ruby 3.1.0dev (2021-11-15T06:58:56Z master f943264565) [x86_64-linux]
Warming up --------------------------------------
                   Time.at(0)     9.546M i/s -      9.734M times in 1.019744s (104.76ns/i, 398clocks/i)
              Time.at(0, 500)     9.457M i/s -      9.680M times in 1.023522s (105.74ns/i, 370clocks/i)
     Time.at(0, in: "+09:00")     1.977M i/s -      2.044M times in 1.033743s (505.75ns/i)
Time.at(0, 500, in: "+09:00")     1.821M i/s -      1.902M times in 1.044507s (549.27ns/i)
Calculating -------------------------------------
                                   3.0.0      master
                   Time.at(0)    10.477M     13.172M i/s -     28.637M times in 2.733200s 2.174097s
              Time.at(0, 500)     9.686M      7.931M i/s -     28.371M times in 2.929153s 3.577184s
     Time.at(0, in: "+09:00")     1.823M      2.542M i/s -      5.932M times in 3.253225s 2.333703s
Time.at(0, 500, in: "+09:00")     1.959M      2.448M i/s -      5.462M times in 2.787425s 2.230970s

Comparison:
                                Time.at(0)
                       master:  13171774.0 i/s
                        3.0.0:  10477358.7 i/s - 1.26x  slower

                           Time.at(0, 500)
                        3.0.0:   9685817.8 i/s
                       master:   7931166.6 i/s - 1.22x  slower

                  Time.at(0, in: "+09:00")
                       master:   2541815.3 i/s
                        3.0.0:   1823372.9 i/s - 1.39x  slower

             Time.at(0, 500, in: "+09:00")
                       master:   2448156.1 i/s
                        3.0.0:   1959429.5 i/s - 1.25x  slower
```

----------------------------------------
Bug #18293: Time.at in master branch was 25% slower then Ruby 3.0
https://bugs.ruby-lang.org/issues/18293#change-94657

* Author: watson1978 (Shizuo Fujita)
* Status: Closed
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: ruby 3.1.0dev (2021-11-08T13:15:21Z master bd2674ad33) [arm64-darwin21]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
       | Ruby 3.0.2 | Ruby 3.1.0-dev | result
--       | --         | --             | --
Time.at  | 8.223M     | 6.190M         | 0.753x

### Environment
- MacBook Pro (14inch, 2021)
- macOS 12.0
- Apple M1 Max
- Apple clang version 13.0.0 (clang-1300.0.29.3)

### Ruby 3.1.0-dev
```
$ ruby -v time.rb
ruby 3.1.0dev (2021-11-08T13:15:21Z master bd2674ad33) [arm64-darwin21]
Warming up --------------------------------------
             Time.at   614.843k i/100ms
Calculating -------------------------------------
             Time.at      6.190M ( 0.3%) i/s -     31.357M in   5.065559s
```

### Ruby 3.0.2
```
$ ruby -v time.rb
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin21]
Warming up --------------------------------------
             Time.at   821.722k i/100ms
Calculating -------------------------------------
             Time.at      8.223M ( 0.6%) i/s -     41.908M in   5.096820s
```

### Test code
```ruby
require 'benchmark/ips'

Benchmark.ips do |x|
  x.report('Time.at') { Time.at(0) }
end
```

---Files--------------------------------
patch.diff (2.52 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>