Skip to content
  • Jean Boussier's avatar
    294dad22
    Time#strftime: avoid repeated coderange scanning · 294dad22
    Jean Boussier authored
    Followup: a3f58964
    
    Restarting scanning has a fixed cost. Since we build a string
    from many small parts, that causes the scan to restart many times.
    
    It's much faster to ignore the coderange, if it's needed later it
    will be faster to scan it in one go.
    
    ```
    compare-ruby: ruby 3.4.0dev (2024-09-04T11:54:06Z opt-strftime-growth 149480f0ff) +YJIT [arm64-darwin23]
    built-ruby: ruby 3.4.0dev (2024-09-04T11:55:26Z opt-strftime-coder.. 29a5153cba) +YJIT [arm64-darwin23]
    warming up...
    
    |                            |compare-ruby|built-ruby|
    |:---------------------------|-----------:|---------:|
    |time.strftime("%FT%T")      |      1.870M|    2.225M|
    |                            |           -|     1.19x|
    |time.strftime("%FT%T.%3N")  |      1.731M|    2.068M|
    |                            |           -|     1.19x|
    |time.strftime("%FT%T.%6N")  |      1.744M|    2.073M|
    |                            |           -|     1.19x|
    ```
    
    Cumulative with a3f58964:
    
    ```
    compare-ruby: ruby 3.4.0dev (2024-09-04T11:55:26Z opt-strftime-coder.. 29a5153cba) +YJIT [arm64-darwin23]
    built-ruby: ruby 3.4.0dev (2024-09-04T12:57:30Z opt-strftime-coder.. 2b938d667a) +YJIT [arm64-darwin23]
    warming up...
    
    |                            |compare-ruby|built-ruby|
    |:---------------------------|-----------:|---------:|
    |time.strftime("%FT%T")      |      1.784M|    2.277M|
    |                            |           -|     1.28x|
    |time.strftime("%FT%T.%3N")  |      1.504M|    2.056M|
    |                            |           -|     1.37x|
    |time.strftime("%FT%T.%6N")  |      1.489M|    2.094M|
    |                            |           -|     1.41x|
    ```
    294dad22
    Time#strftime: avoid repeated coderange scanning
    Jean Boussier authored
    Followup: a3f58964
    
    Restarting scanning has a fixed cost. Since we build a string
    from many small parts, that causes the scan to restart many times.
    
    It's much faster to ignore the coderange, if it's needed later it
    will be faster to scan it in one go.
    
    ```
    compare-ruby: ruby 3.4.0dev (2024-09-04T11:54:06Z opt-strftime-growth 149480f0ff) +YJIT [arm64-darwin23]
    built-ruby: ruby 3.4.0dev (2024-09-04T11:55:26Z opt-strftime-coder.. 29a5153cba) +YJIT [arm64-darwin23]
    warming up...
    
    |                            |compare-ruby|built-ruby|
    |:---------------------------|-----------:|---------:|
    |time.strftime("%FT%T")      |      1.870M|    2.225M|
    |                            |           -|     1.19x|
    |time.strftime("%FT%T.%3N")  |      1.731M|    2.068M|
    |                            |           -|     1.19x|
    |time.strftime("%FT%T.%6N")  |      1.744M|    2.073M|
    |                            |           -|     1.19x|
    ```
    
    Cumulative with a3f58964:
    
    ```
    compare-ruby: ruby 3.4.0dev (2024-09-04T11:55:26Z opt-strftime-coder.. 29a5153cba) +YJIT [arm64-darwin23]
    built-ruby: ruby 3.4.0dev (2024-09-04T12:57:30Z opt-strftime-coder.. 2b938d667a) +YJIT [arm64-darwin23]
    warming up...
    
    |                            |compare-ruby|built-ruby|
    |:---------------------------|-----------:|---------:|
    |time.strftime("%FT%T")      |      1.784M|    2.277M|
    |                            |           -|     1.28x|
    |time.strftime("%FT%T.%3N")  |      1.504M|    2.056M|
    |                            |           -|     1.37x|
    |time.strftime("%FT%T.%6N")  |      1.489M|    2.094M|
    |                            |           -|     1.41x|
    ```
Loading