From dcb0a76158f4843e3fc3321e22de053d456aff8b Mon Sep 17 00:00:00 2001 From: fenny <25108519+Fenny@users.noreply.github.com> Date: Thu, 4 Jun 2020 11:08:01 -0400 Subject: [PATCH] Remove dependency from benchmarks (#10) * Update utils.go * Update utils_test.go * Update README.md * Add benchmarks * add method to copy a string with reference(unsafe string) * Update bench results * Create go.sum * Add UUID test * Add UUID bench * Add UUID function * Update GetBytes https: //github.com/gofiber/utils/pull/7 Co-Authored-By: Johannes Lauinger * Remove benchmark dependency Co-authored-by: wernerr Co-authored-by: Johannes Lauinger --- go.sum | 0 utils_bench_test.go | 8 +++++--- 2 files changed, 5 insertions(+), 3 deletions(-) delete mode 100644 go.sum diff --git a/go.sum b/go.sum deleted file mode 100644 index e69de29..0000000 diff --git a/utils_bench_test.go b/utils_bench_test.go index 9da9aeb..f14a962 100644 --- a/utils_bench_test.go +++ b/utils_bench_test.go @@ -6,11 +6,11 @@ package utils import ( "bytes" + "crypto/rand" + "fmt" "mime" "strings" "testing" - - stduuid "github.com/google/uuid" ) // go test -v -run=^$ -bench=Benchmark_UUID -benchmem -count=2 @@ -24,8 +24,10 @@ func Benchmark_UUID(b *testing.B) { AssertEqual(b, 36, len(res)) }) b.Run("default", func(b *testing.B) { + rnd := make([]byte, 16) + _, _ = rand.Read(rnd) for n := 0; n < b.N; n++ { - res = stduuid.New().String() + res = fmt.Sprintf("%x-%x-%x-%x-%x", rnd[0:4], rnd[4:6], rnd[6:8], rnd[8:10], rnd[10:]) } AssertEqual(b, 36, len(res)) })