Skip to content

Instantly share code, notes, and snippets.

@maximelamure
Created October 24, 2016 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save maximelamure/af411199bd5c93db3dd0a7133914ebc3 to your computer and use it in GitHub Desktop.
Save maximelamure/af411199bd5c93db3dd0a7133914ebc3 to your computer and use it in GitHub Desktop.
package bench_test
import "testing"
func BenchmarkByteArray(b *testing.B) {
for n := 0; n < b.N; n++ {
GetBytes()
}
}
func BenchmarkString(b *testing.B) {
for n := 0; n < b.N; n++ {
GetString()
}
}
func GetString() string {
filtersKey := make([]string, 0, 0)
filtersKey = append(filtersKey, "chunks = ?")
filtersKey = append(filtersKey, "error_message = ?")
filtersKey = append(filtersKey, "error_status = ?")
filtersKey = append(filtersKey, "status = ?")
return ""
}
func GetBytes() string {
filtersKey := make([][]byte, 0, 0)
filtersKey = append(filtersKey, []byte("chunks = ?"))
filtersKey = append(filtersKey, []byte("error_message = ?"))
filtersKey = append(filtersKey, []byte("error_status = ?"))
filtersKey = append(filtersKey, []byte("status = ?"))
return ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment