Issue #18293 has been updated by peterzhu2118 (Peter Zhu).


I was able to repro this on Ubuntu 20.04 on an AMD CPU. Looks like moving these functions from `time.c` to `timev.rb` is the reason.

77e7082e824af8523c1e7c3bfc111c2e52e7e3b3 (Moved Time.at to builtin)

```
             Time.at      5.663M ( 0.7%) i/s -     28.836M in   5.092655s
            Time.now      5.077M ( 0.8%) i/s -     25.841M in   5.089906s
```

9101597d05ef645949bab3a210d8fa5e61de26e3 (Moved Time.now to builtin)

```
             Time.at      7.755M ( 0.7%) i/s -     39.139M in   5.047441s
            Time.now      5.001M ( 0.8%) i/s -     25.217M in   5.042618s
```

d5fb51d2d3a7ba0e16042282d0f94c5336ed2cc1 (Add time.rb as builtin)

```
             Time.at      7.882M ( 0.7%) i/s -     39.532M in   5.015832s
            Time.now      5.450M ( 0.4%) i/s -     27.564M in   5.057575s
```


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

* Author: watson1978 (Shizuo Fujita)
* Status: Open
* Priority: Normal
* 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
```



-- 
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>