Skip to content

Commit

Permalink
Remove dependency from benchmarks (#10)
Browse files Browse the repository at this point in the history
* 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//pull/7
Co-Authored-By: Johannes Lauinger <[email protected]>

* Remove benchmark dependency

Co-authored-by: wernerr <[email protected]>
Co-authored-by: Johannes Lauinger <[email protected]>
  • Loading branch information
3 people authored Jun 4, 2020
1 parent 00537c6 commit dcb0a76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Empty file removed go.sum
Empty file.
8 changes: 5 additions & 3 deletions utils_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
})
Expand Down

0 comments on commit dcb0a76

Please sign in to comment.