mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Time#strftime: grow the buffer faster
Use a classic doubling of capacity rather than only adding twice as much capacity as is already known to be needed. ``` compare-ruby: ruby 3.4.0dev (2024-09-04T09:21:53Z opt-strftime-2ae98d19cf9
) +YJIT [arm64-darwin23] built-ruby: ruby 3.4.0dev (2024-09-04T11:46:02Z opt-strftime-growth 586263d6fb) +YJIT [arm64-darwin23] warming up... | |compare-ruby|built-ruby| |:---------------------------|-----------:|---------:| |time.strftime("%FT%T") | 1.754M| 1.889M| | | -| 1.08x| |time.strftime("%FT%T.%3N") | 1.508M| 1.749M| | | -| 1.16x| |time.strftime("%FT%T.%6N") | 1.488M| 1.756M| | | -| 1.18x| compare-ruby: ruby 3.4.0dev (2024-09-04T09:21:53Z opt-strftime-2ae98d19cf9
) +YJIT [arm64-darwin23] built-ruby: ruby 3.4.0dev (2024-09-04T09:21:53Z opt-strftime-2ae98d19cf9
) +YJIT [arm64-darwin23] warming up... ```
This commit is contained in:
parent
83334ebb3c
commit
a3f589640f
Notes:
git
2024-09-04 12:53:14 +00:00
2 changed files with 10 additions and 1 deletions
7
benchmark/time_strftime.yml
Normal file
7
benchmark/time_strftime.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
prelude: |
|
||||
# frozen_string_literal: true
|
||||
time = Time.now
|
||||
benchmark:
|
||||
- time.strftime("%FT%T") # 19B
|
||||
- time.strftime("%FT%T.%3N") # 23B
|
||||
- time.strftime("%FT%T.%6N") # 26B
|
Loading…
Add table
Add a link
Reference in a new issue