Log format performance improvement
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- ruby
调研方向
从 lib/logger/formatter.rb 第 22 行附近开始,检查当前时间戳格式的使用方式。运行提供的 Benchmark.ips 对比,然后确定所提议的 iso8601(6) 输出是否与 logger 预期的格式兼容,并在修改之前记录结果。
由索引模型根据 Issue 内容生成。
描述
While doing some log format configuration, I came across this performance improvement. It is 4.61x slower to use strftime compared to iso8601(6). The output format is not identical, but close and has a small improvement that it includes offset IMO. Was wondering if this improvement is worth making a PR?
irb(main):9> time = Time.now
2025-10-10 09:28:08.27533 -0400
irb(main):10> time.strftime("%Y-%m-%dT%H:%M:%S.%6N")
"2025-10-10T09:28:08.275330"
irb(main):11> time.iso8601(6)
"2025-10-10T09:28:08.275330-04:00"
Warming up --------------------------------------
Time#strftime 149.661k i/100ms
Time#iso8601 668.851k i/100ms
Calculating -------------------------------------
Time#strftime 1.459M (± 4.5%) i/s - 7.333M in 5.038060s
Time#iso8601 6.731M (± 3.8%) i/s - 34.111M in 5.077102s
Comparison:
Time#iso8601: 6730815.9 i/s
Time#strftime: 1459156.6 i/s - 4.61x (± 0.00) slower
Benchmark.ips do |x|
time = Time.now
x.report('Time#strftime') { time.strftime('%Y-%m-%dT%H:%M:%S.%6N') }
x.report('Time#iso8601') { time.iso8601(6) }
x.compare!
end
- 主要语言
- Ruby
- 星标
- 161
- 派生
- 76
- 平均合并
- 2 天 5 小时
- 30 天内合并 PR
- 3
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ruby/logger 的其他 Issue
-
Programs using Logger sometimes resist SIGTERM / SIGINT可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 3/5 1-2 天 新手友好度 68/100
-
难度 4/5 3-5 天 新手友好度 48/100
-
难度 3/5 1-2 天 新手友好度 52/100
-
`datetime_format=` does not apply to custom formatters可能已有人在做 @Rubyist007 于 229 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 72/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
open-feature/ruby-sdk-contrib#340 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
zold-io/wts.zold.io#651 ·
维护者通常 1 天内回复
-
good first issue help wanted
难度 2/5 1-3 小时 新手友好度 87/100
erkamyaman/rust-anything#788 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 74/100
TheOdinProject/curriculum#31579 ·
维护者通常 1 天内回复