Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add ut for util_test #2840

Merged
merged 4 commits into from Feb 14, 2024
Merged

Conversation

rfyiamcool
Copy link
Contributor

summary

  1. add ut for util functions.
  2. add benchmark for toLower.

I'm curious why the native tolower ( strings.ToLower() ) method is not used. Through stress testing, I learned that the speed of the native tolower is not good. 馃榿 The ToLower implemented by go-redis is three times faster than strings.ToLower.

toLower benchmark

use strings.ToLower()

goos: darwin
goarch: amd64
pkg: github.com/redis/go-redis/v9/internal
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkToLowerStd
BenchmarkToLowerStd-12    	10940630	        99.88 ns/op	      24 B/op	       1 allocs/op
PASS
ok  	github.com/redis/go-redis/v9/internal	1.823s

use utils.ToLower

goos: darwin
goarch: amd64
pkg: github.com/redis/go-redis/v9/internal
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkToLowerInternal
BenchmarkToLowerInternal-12    	35665322	        33.31 ns/op	      24 B/op	       1 allocs/op
PASS
ok  	github.com/redis/go-redis/v9/internal	2.377s

Signed-off-by: rfyiamcool <rfyiamcool@163.com>
Copy link
Collaborator

@ofekshenawa ofekshenawa left a comment

Choose a reason for hiding this comment

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

LGTM!

@ofekshenawa ofekshenawa merged commit 9133749 into redis:master Feb 14, 2024
8 of 9 checks passed
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.

None yet

2 participants