Skip to content

refactor:refactor RandomString function#524

Merged
samber merged 11 commits into
samber:masterfrom
pigwantacat:master
Sep 19, 2024
Merged

refactor:refactor RandomString function#524
samber merged 11 commits into
samber:masterfrom
pigwantacat:master

Conversation

@pigwantacat
Copy link
Copy Markdown
Contributor

@pigwantacat pigwantacat commented Aug 22, 2024

reference resources:How to generate a random string of a fixed length in Go?

func BenchmarkApproach1(b *testing.B) {
	for i := 0; i < b.N; i++ {
		_ = RandomString(1<<10, lo.AlphanumericCharset)
	}
}

func BenchmarkApproach2(b *testing.B) {
	for i := 0; i < b.N; i++ {
		_ = lo.RandomString(1<<10, lo.AlphanumericCharset)
	}
}
$ go test -benchmem -benchtime=5s -bench .
goos: windows
goarch: amd64
pkg: mytttttt
cpu: Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz
BenchmarkApproach1-12            1000000              5423 ns/op            1024 B/op          1 allocs/op
BenchmarkApproach2-12             292579             20485 ns/op            5248 B/op          2 allocs/op
PASS
ok      mytttttt        12.160s

@samber
Copy link
Copy Markdown
Owner

samber commented Sep 11, 2024

that's cool!

Comment thread string.go Outdated
Comment thread string.go
Comment thread string.go
Comment thread string.go
Comment thread string.go Outdated
Comment thread string.go
Comment thread string.go Outdated
Comment thread string.go
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 19, 2024

Codecov Report

❌ Patch coverage is 84.61538% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.33%. Comparing base (bc0037c) to head (e8bb837).
⚠️ Report is 361 commits behind head on master.

Files with missing lines Patch % Lines
string.go 84.61% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #524      +/-   ##
==========================================
- Coverage   94.48%   94.33%   -0.15%     
==========================================
  Files          17       17              
  Lines        2757     2790      +33     
==========================================
+ Hits         2605     2632      +27     
- Misses        150      154       +4     
- Partials        2        4       +2     
Flag Coverage Δ
unittests 94.33% <84.61%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samber samber merged commit a6a53e1 into samber:master Sep 19, 2024
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.

4 participants