You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## What type of PR is this? (check all applicable)
- [x] Refactor
- [ ] Feature
- [ ] Bug Fix
- [x] Optimization
- [ ] Documentation Update
## Description
This optimizes NewRouter creation. The change introduces strings.Builder
for more efficient strings concatenation, and replaces SplitN with
Index, avoiding the allocations for the slice.
## Related Tickets & Documents
| Test Group | Condition | Average Time (ns/op) | Average Memory (B/op)
| Average Allocations |
|-----------------------------|-----------|----------------------|-----------------------|---------------------|
| **BenchmarkNewRouter** | Before | 37041 | 26553 | 376 |
| | After | 32046 | 25800 | 347 |
| **BenchmarkNewRouterRegexpFunc** | Before | 4713 | 2385 | 75 |
| | After | 2792 | 1640 | 46 |
BenchmarkNewRouterRegexpFunc:
Time Improvement: Significant improvement in execution time from 4,713
ns/op to 2,792 ns/op.
Memory Usage: Memory usage per operation dropped from 2,385 bytes to
1,640 bytes.
Allocations: Allocations per operation decreased substantially from 75
to 46.
## Added/updated tests?
- [x] Yes
## Run verifications and test
- [ ] `make verify` is passing
- [x] `make test` is passing
---------
Co-authored-by: Tit Petric <[email protected]>
0 commit comments