Feature #20707
closedMove `Time#xmlschema` into core
Description
Performance¶
Converting Time
into RFC3339 / ISO8601
representation is an significant hotspot for application that serialize data in JSON, XML or other formats.
Right now this feature is currently available through the time
default gem, so it rely on Time#strftime
.
While strftime
could certainly be optimized, ultimately it's a very generic API so can't make a lot of assumptions about the output.
Whereas ISO8601
is a very strict format, with very few dynamic part, so it's much easier for dedicated code to be well optimized, as the final size of the string can be computed upfront etc.
compare-ruby: ruby 3.4.0dev (2024-08-29T13:11:40Z master 6b08a50a62) +YJIT [arm64-darwin23]
built-ruby: ruby 3.4.0dev (2024-08-30T13:17:32Z native-xmlschema 34041ff71f) +YJIT [arm64-darwin23]
warming up......
| |compare-ruby|built-ruby|
|:-----------------------|-----------:|---------:|
|time._xmlschema | 1.087M| 5.190M|
| | -| 4.78x|
|utc_time._xmlschema | 1.464M| 6.848M|
| | -| 4.68x|
|time._xmlschema(6) | 859.960k| 4.646M|
| | -| 5.40x|
|utc_time._xmlschema(6) | 1.080M| 5.917M|
| | -| 5.48x|
|time._xmlschema(9) | 893.909k| 4.668M|
| | -| 5.22x|
|utc_time._xmlschema(9) | 1.056M| 5.707M|
| | -| 5.40x|
Usability¶
Aside from the performance reason, ISO8601
is so common that having this functionality built-in without needing to require anything would make sense to me.
xmlschema
is the most common reason why I require time
, and in many case having it core would allow not to load it at all.
Updated by matz (Yukihiro Matsumoto) about 1 month ago
Accepted.
Matz.
Updated by byroot (Jean Boussier) about 1 month ago
- Status changed from Open to Closed
Applied in changeset git|57e3fc32ea83e55d40f4cc6c3e437d485c506d34.
Move Time#xmlschema in core and optimize it
[Feature #20707]
Converting Time into RFC3339 / ISO8601 representation is an significant
hotspot for applications that serialize data in JSON, XML or other formats.
By moving it into core we can optimize it much further than what strftime
will
allow.
compare-ruby: ruby 3.4.0dev (2024-08-29T13:11:40Z master 6b08a50a62) +YJIT [arm64-darwin23]
built-ruby: ruby 3.4.0dev (2024-08-30T13:17:32Z native-xmlschema 34041ff71f) +YJIT [arm64-darwin23]
warming up......
| |compare-ruby|built-ruby|
|:-----------------------|-----------:|---------:|
|time.xmlschema | 1.087M| 5.190M|
| | -| 4.78x|
|utc_time.xmlschema | 1.464M| 6.848M|
| | -| 4.68x|
|time.xmlschema(6) | 859.960k| 4.646M|
| | -| 5.40x|
|utc_time.xmlschema(6) | 1.080M| 5.917M|
| | -| 5.48x|
|time.xmlschema(9) | 893.909k| 4.668M|
| | -| 5.22x|
|utc_time.xmlschema(9) | 1.056M| 5.707M|
| | -| 5.40x|
Updated by hsbt (Hiroshi SHIBATA) about 1 month ago
- Related to Feature #14274: Merge Std-Lib Time Class into Core added