X7ROOT File Manager
Current Path:
/opt/golang/1.17.2/test/bench/go1
opt
/
golang
/
1.17.2
/
test
/
bench
/
go1
/
📁
..
📄
binarytree_test.go
(1.57 KB)
📄
fannkuch_test.go
(1.47 KB)
📄
fasta_test.go
(3.7 KB)
📄
fmt_test.go
(1.36 KB)
📄
go.mod
(31 B)
📄
gob_test.go
(1.75 KB)
📄
gzip_test.go
(1.01 KB)
📄
http_test.go
(949 B)
📄
json_test.go
(1.61 KB)
📄
jsondata_test.go
(115.1 KB)
📄
mandel_test.go
(848 B)
📄
parser_test.go
(888 B)
📄
parserdata_test.go
(19 KB)
📄
regexp_test.go
(1.64 KB)
📄
revcomp_test.go
(1.75 KB)
📄
template_test.go
(1.41 KB)
📄
time_test.go
(516 B)
Editing: regexp_test.go
// Copyright 2013 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. package go1 import ( "math/rand" "regexp" "testing" ) // benchmark based on regexp/exec_test.go var regexpText []byte func makeRegexpText(n int) []byte { rand.Seed(0) // For reproducibility. if len(regexpText) >= n { return regexpText[:n] } regexpText = make([]byte, n) for i := range regexpText { if rand.Intn(30) == 0 { regexpText[i] = '\n' } else { regexpText[i] = byte(rand.Intn(0x7E+1-0x20) + 0x20) } } return regexpText } func benchmark(b *testing.B, re string, n int) { r := regexp.MustCompile(re) t := makeRegexpText(n) b.ResetTimer() b.SetBytes(int64(n)) for i := 0; i < b.N; i++ { if r.Match(t) { b.Fatal("match!") } } } const ( easy0 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ$" easy1 = "A[AB]B[BC]C[CD]D[DE]E[EF]F[FG]G[GH]H[HI]I[IJ]J$" medium = "[XYZ]ABCDEFGHIJKLMNOPQRSTUVWXYZ$" hard = "[ -~]*ABCDEFGHIJKLMNOPQRSTUVWXYZ$" ) func BenchmarkRegexpMatchEasy0_32(b *testing.B) { benchmark(b, easy0, 32<<0) } func BenchmarkRegexpMatchEasy0_1K(b *testing.B) { benchmark(b, easy0, 1<<10) } func BenchmarkRegexpMatchEasy1_32(b *testing.B) { benchmark(b, easy1, 32<<0) } func BenchmarkRegexpMatchEasy1_1K(b *testing.B) { benchmark(b, easy1, 1<<10) } func BenchmarkRegexpMatchMedium_32(b *testing.B) { benchmark(b, medium, 32<<0) } func BenchmarkRegexpMatchMedium_1K(b *testing.B) { benchmark(b, medium, 1<<10) } func BenchmarkRegexpMatchHard_32(b *testing.B) { benchmark(b, hard, 32<<0) } func BenchmarkRegexpMatchHard_1K(b *testing.B) { benchmark(b, hard, 1<<10) }
Upload File
Create Folder