diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-04-16 05:37:14 -0700 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-04-16 08:37:14 -0400 |
commit | 6e2cb00008cbf09e556b00f87603797fcaa47e09 (patch) | |
tree | 3c0eb55ff4226a3f024aad373140d1fb860a6404 /vendor/golang.org/x/text/secure/precis/benchmark_test.go | |
parent | bf24f51c4e1cc6286885460672f7f449e8c6f5ef (diff) | |
download | chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.gz chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.bz2 chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.zip |
Depenancy upgrades and movign to dep. (#8630)
Diffstat (limited to 'vendor/golang.org/x/text/secure/precis/benchmark_test.go')
-rw-r--r-- | vendor/golang.org/x/text/secure/precis/benchmark_test.go | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/vendor/golang.org/x/text/secure/precis/benchmark_test.go b/vendor/golang.org/x/text/secure/precis/benchmark_test.go deleted file mode 100644 index 6337d0063..000000000 --- a/vendor/golang.org/x/text/secure/precis/benchmark_test.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.7 - -package precis - -import ( - "testing" - - "golang.org/x/text/internal/testtext" -) - -var benchData = []struct{ name, str string }{ - {"ASCII", "Malvolio"}, - {"NotNormalized", "abcdefg\u0301\u031f"}, - {"Arabic", "دبي"}, - {"Hangul", "동일조건변경허락"}, -} - -var benchProfiles = []struct { - name string - p *Profile -}{ - {"FreeForm", NewFreeform()}, - {"Nickname", Nickname}, - {"OpaqueString", OpaqueString}, - {"UsernameCaseMapped", UsernameCaseMapped}, - {"UsernameCasePreserved", UsernameCasePreserved}, -} - -func doBench(b *testing.B, f func(b *testing.B, p *Profile, s string)) { - for _, bp := range benchProfiles { - for _, d := range benchData { - testtext.Bench(b, bp.name+"/"+d.name, func(b *testing.B) { - f(b, bp.p, d.str) - }) - } - } -} - -func BenchmarkString(b *testing.B) { - doBench(b, func(b *testing.B, p *Profile, s string) { - for i := 0; i < b.N; i++ { - p.String(s) - } - }) -} - -func BenchmarkBytes(b *testing.B) { - doBench(b, func(b *testing.B, p *Profile, s string) { - src := []byte(s) - b.ResetTimer() - for i := 0; i < b.N; i++ { - p.Bytes(src) - } - }) -} - -func BenchmarkAppend(b *testing.B) { - doBench(b, func(b *testing.B, p *Profile, s string) { - src := []byte(s) - dst := make([]byte, 0, 4096) - b.ResetTimer() - for i := 0; i < b.N; i++ { - p.Append(dst, src) - } - }) -} - -func BenchmarkTransform(b *testing.B) { - doBench(b, func(b *testing.B, p *Profile, s string) { - src := []byte(s) - dst := make([]byte, 2*len(s)) - t := p.NewTransformer() - b.ResetTimer() - for i := 0; i < b.N; i++ { - t.Transform(dst, src, true) - } - }) -} |