Skip to content

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 <[email protected]>
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
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