-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.sh
executable file
·49 lines (39 loc) · 2.25 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
GOCMD=${GOCMD:-go}
function build() {
(
pkg=$1
regex=$2
echo "$pkg"
dir="gen/$pkg"
mkdir -p "$dir"
$GOCMD run main.go "$regex" > "$dir/main.go"
$GOCMD build -o "$dir/main" "$dir/main.go"
$GOCMD tool objdump -S -s "main.Match" "$dir/main" > "$dir/main.asm"
dir="examples/$pkg"
mkdir -p "$dir"
$GOCMD run main.go -pkg "$pkg" "$regex" > "$dir/main.go"
rm -f "$dir/main"
) &
}
rm -rf gen examples benchmark.test cpu.prof mem.prof
echo "Building sample regexps"
build mail_crawler '(?i)\b([a-z0-9._%+-]+)@([a-z0-9.-]+\.[a-z]{2,})\b'
build log_parse '(?m)^INFO res=([0-9]+) msg=(.*)$'
build line_prefix '(?m)^>(.*)$'
build dna '(?:(agggtaaa|tttaccct)|([cgt]gggtaaa|tttaccc[acg])|(a[act]ggtaaa|tttacc[agt]t)|(ag[act]gtaaa|tttac[agt]ct)|(agg[act]taaa|ttta[agt]cct)|(aggg[acg]aaa|ttt[cgt]ccct)|(agggt[cgt]aa|tt[acg]accct)|(agggta[cgt]a|t[acg]taccct)|(agggtaa[cgt]|[acg]ttaccct))'
build prefix 'Hello ([^!]+)!'
build unicode '私は((?:\p{Katakana}|\p{Hiragana}|\p{Han})+)です'
build suffix '[a-z]+$'
build ipv6 '(?:(?:[0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?:(?::[0-9a-fA-F]{1,4}){1,6})|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(?::[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(?:ffff(?::0{1,4}){0,1}:){0,1}(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])|(?:[0-9a-fA-F]{1,4}:){1,4}:(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9]))'
build quoted '(?i)"([a-z0-9,.;:@!#$%^&*()_ -]+)"'
build pathological '(a*)*b'
build plain 'plain'
wait
echo "Testing"
$GOCMD test .
echo "Gathering profiles"
$GOCMD test -c ./benchmark # build benchmark.test
$GOCMD test -bench=. -cpuprofile=cpu.prof -memprofile=mem.prof -benchtime=1s -cpu=1 -short ./benchmark/ >/dev/null
echo "Running benchmarks"
benchstat <($GOCMD test -bench=. -benchtime=0.1s -benchmem -count=10 -cpu=1 ./benchmark/)