Skip to content

Conversation

@1911860538
Copy link
Contributor

strings.LastIndexByte offers better performance than strings.LastIndex.

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels May 13, 2025
demoManito
demoManito previously approved these changes May 13, 2025
@dosubot dosubot bot added the LGTM label May 13, 2025
kagaya85
kagaya85 previously approved these changes Jul 14, 2025
Copy link
Member

@kagaya85 kagaya85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kagaya85
Copy link
Member

kagaya85 commented Jul 14, 2025

Maybe we should include a benchmark test for performance-related changes @1911860538

@1911860538
Copy link
Contributor Author

Maybe we should include a benchmark test for performance-related changes @1911860538

Ok, I will update this PR after today's work.

@1911860538 1911860538 dismissed stale reviews from kagaya85 and demoManito via 9f609d0 July 14, 2025 12:28
@1911860538
Copy link
Contributor Author

Maybe we should include a benchmark test for performance-related changes @1911860538

benchmark code

func BenchmarkFormat(b *testing.B) {
	for i := 0; i < b.N; i++ {
		format("abc.txt")
	}
}

benchmark output before optimization

goos: darwin
goarch: amd64
pkg: github.com/go-kratos/kratos/v2/config/file
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
BenchmarkFormat
BenchmarkFormat-8   	276620788	         4.317 ns/op
PASS

Process finished with the exit code 0

benchmark output after optimization

goos: darwin
goarch: amd64
pkg: github.com/go-kratos/kratos/v2/config/file
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
BenchmarkFormat
BenchmarkFormat-8   	338712090	         3.683 ns/op
PASS

Process finished with the exit code 0

@kagaya85
Copy link
Member

Thanks for the update, please rebase the code☺️

@1911860538
Copy link
Contributor Author

Thanks for the update, please rebase the code☺️

Done.

@kagaya85 kagaya85 merged commit ac92cbe into go-kratos:main Jul 16, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LGTM size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants