Browse Source

Benchmarks for String()

Chris Bandy 11 years ago
parent
commit
658dfb434e
1 changed files with 29 additions and 0 deletions
  1. +29
    -0
      semver_test.go

+ 29
- 0
semver_test.go View File

@ -291,6 +291,35 @@ func BenchmarkParseAverage(b *testing.B) {
} }
} }
func BenchmarkStringSimple(b *testing.B) {
const VERSION = "0.0.1"
v, _ := New(VERSION)
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
v.String()
}
}
func BenchmarkStringComplex(b *testing.B) {
const VERSION = "0.0.1-alpha.preview+123.456"
v, _ := New(VERSION)
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
v.String()
}
}
func BenchmarkStringAverage(b *testing.B) {
l := len(formatTests)
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
formatTests[n%l].v.String()
}
}
func BenchmarkValidateSimple(b *testing.B) { func BenchmarkValidateSimple(b *testing.B) {
const VERSION = "0.0.1" const VERSION = "0.0.1"
v, _ := New(VERSION) v, _ := New(VERSION)


Loading…
Cancel
Save