Skip to content

大幅提升命令行解析性能#47

Merged
lindexi merged 81 commits intomasterfrom
t/walterlv/performance
Apr 20, 2025
Merged

大幅提升命令行解析性能#47
lindexi merged 81 commits intomasterfrom
t/walterlv/performance

Conversation

@walterlv
Copy link
Member

@walterlv walterlv commented Apr 16, 2025

更新

  • 现在已使用拦截器提升性能,在启动性能上又获得了 10 倍性能提升

初版优化,再版优化

  • 相比于 4.0 初版,大约 10 倍性能提升;
  • 相比于 3.x 版本:
    • As(Parser):只有手写 Parser 方式大约 50% 的性能(功能多了,规则更严格了之后只能这样)
    • As(Runtime):无参时有 10 倍性能提升,有参时性能相当
    • AddHandler(Parser):性能相当
    • AddHandler(Parser):有 10 倍性能提升

启动性能(us):

Index 3.x-Parser 3.x-Runtime 4.x-Interceptor 4.x-ModuleInitializer
1 31.300 45.200 34.500 514.900
2 29.100 45.100 34.400 535.900
3 29.700 45.500 35.400 518.700
4 30.100 46.300 34.700 514.300
5 30.600 46.600 35.100 520.100
6 30.100 45.800 34.800 576.900
7 30.000 44.700 35.200 510.700
8 52.400 49.500 35.000 514.300
9 29.800 46.300 34.700 514.100
10 30.000 46.400 34.700 519.600

Benchmark:

image

walterlv added 30 commits April 15, 2025 14:18
1. 避免字典的拷贝和列表的拷贝
2. 优化单个元素的列表
@lindexi lindexi merged commit 17bd0f7 into master Apr 20, 2025
2 checks passed
@lindexi lindexi deleted the t/walterlv/performance branch April 20, 2025 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants