diff options
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/string-roundtrip/guuid.go | 37 | ||||
l--------- | tests/benchmarks/string-roundtrip/main.go | 1 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/benchmarks/string-roundtrip/guuid.go b/tests/benchmarks/string-roundtrip/guuid.go new file mode 100644 index 0000000..9fef55c --- /dev/null +++ b/tests/benchmarks/string-roundtrip/guuid.go @@ -0,0 +1,37 @@ +package guuid + +import ( + "flag" + "fmt" +) + + + +var nFlag = flag.Int( + "n", + 10_000_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + uuid := New() + + for i := 0; i < n; i++ { + derived, err := FromString(uuid.String()) + if err != nil { + panic(err) + } + + eq := uuid == derived + if !eq { + panic(fmt.Sprintf( + "bad round trip: orig (%#v); derived (%#v)", + uuid, + derived, + )) + } + } +} diff --git a/tests/benchmarks/string-roundtrip/main.go b/tests/benchmarks/string-roundtrip/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/string-roundtrip/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file |