Various small updates, related to speed improvements.
This commit is contained in:
parent
c37404875d
commit
96a72c4c48
|
@ -1,5 +1,8 @@
|
||||||
# Build output
|
# Build output
|
||||||
cmd/burntsushi-tester/burntsushi-tester
|
cmd/burntsushi-tester/burntsushi-tester
|
||||||
|
cmd/burntsushi-tester/A
|
||||||
|
cmd/burntsushi-tester/B
|
||||||
|
parse2/parse2
|
||||||
|
|
||||||
# ---> Vim
|
# ---> Vim
|
||||||
# Swap
|
# Swap
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
a:
|
||||||
|
go build
|
||||||
|
mv burntsushi-tester A
|
||||||
|
|
||||||
|
b:
|
||||||
|
go build
|
||||||
|
mv burntsushi-tester B
|
||||||
|
|
||||||
|
test: test-a test-b test-sushi
|
||||||
|
|
||||||
|
test-a:
|
||||||
|
numactl --physcpubind=+1 bash -c "time ./A < testfile.toml"
|
||||||
|
|
||||||
|
|
||||||
|
test-b:
|
||||||
|
numactl --physcpubind=+2 bash -c "time ./B < testfile.toml"
|
||||||
|
|
||||||
|
test-sushi:
|
||||||
|
|
||||||
|
numactl --physcpubind=+3 bash -c "time ~/go-workspace/bin/toml-test-decoder < testfile.toml"
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,7 +9,7 @@ func TestComment(t *testing.T) {
|
||||||
{``, `{}`, ``},
|
{``, `{}`, ``},
|
||||||
{`#`, `{}`, ``},
|
{`#`, `{}`, ``},
|
||||||
{`# `, `{}`, ``},
|
{`# `, `{}`, ``},
|
||||||
{`# with data`, `{}`, ``},
|
{`# aaaaaa`, `{}`, ``},
|
||||||
{"# ending in EOL & EOF\r\n", `{}`, ``},
|
{"# ending in EOL & EOF\r\n", `{}`, ``},
|
||||||
{`# \xxx/ \u can't escape/`, `{}`, ``},
|
{`# \xxx/ \u can't escape/`, `{}`, ``},
|
||||||
{"# \tlexe\r accepts embedded ca\r\riage \returns\r\n", `{}`, ``},
|
{"# \tlexe\r accepts embedded ca\r\riage \returns\r\n", `{}`, ``},
|
||||||
|
|
|
@ -11,7 +11,7 @@ var (
|
||||||
c, a, m, tok = tokenize.C, tokenize.A, tokenize.M, tokenize.T
|
c, a, m, tok = tokenize.C, tokenize.A, tokenize.M, tokenize.T
|
||||||
|
|
||||||
// Whitespace means tab (0x09) or space (0x20).
|
// Whitespace means tab (0x09) or space (0x20).
|
||||||
// The matches the blanks as defined by parsekit.
|
// This matches the blanks as defined by parsekit.
|
||||||
|
|
||||||
whitespace = a.Blanks.Optional()
|
whitespace = a.Blanks.Optional()
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ var (
|
||||||
// A '#' hash symbol marks the rest of the line as a comment.
|
// A '#' hash symbol marks the rest of the line as a comment.
|
||||||
// All characters up to the end of the line are included in the comment.
|
// All characters up to the end of the line are included in the comment.
|
||||||
|
|
||||||
comment = c.Seq(a.Hash, a.UntilEndOfLine.Optional())
|
comment = c.Seq(a.Hash, m.DropUntilEndOfLine)
|
||||||
optionalComment = comment.Optional()
|
optionalComment = comment.Optional()
|
||||||
|
|
||||||
endOfLineOrComment = c.Seq(whitespace, optionalComment, a.EndOfLine)
|
endOfLineOrComment = c.Seq(whitespace, optionalComment, a.EndOfLine)
|
||||||
|
|
|
@ -1,47 +1,269 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BenchmarkLongToml(b *testing.B) {
|
// func BenchmarkLongToml(b *testing.B) {
|
||||||
benchmarkFile(b, "long.toml")
|
// benchmarkFile(b, "long.toml")
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func BenchmarkNormalToml(b *testing.B) {
|
||||||
|
// benchmarkFile(b, "normal.toml")
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func BenchmarkShortToml(b *testing.B) {
|
||||||
|
// benchmarkFile(b, "short.toml")
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func benchmarkFile(b *testing.B, file string) {
|
||||||
|
// toml := BuildGrammar()
|
||||||
|
// inputBytes, err := ioutil.ReadFile(file)
|
||||||
|
// if err != nil {
|
||||||
|
// b.Fatalf("Cannot read input file (%s): %s", file, err)
|
||||||
|
// }
|
||||||
|
// inputStr := string(inputBytes)
|
||||||
|
// for i := 0; i < b.N; i++ {
|
||||||
|
// _, err := toml.Match(inputStr)
|
||||||
|
// if err != nil {
|
||||||
|
// b.Fatalf("Error in parsing TOML input: %s\n", err)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func BenchmarkReadArrayOfInt(b *testing.B) {
|
||||||
|
// type F [10]int
|
||||||
|
// arr := make([]F, 10000)
|
||||||
|
// for i := 0; i < 10000; i++ {
|
||||||
|
// arr[i] = [10]int{i, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||||
|
// }
|
||||||
|
|
||||||
|
// for i := 0; i < b.N; i++ {
|
||||||
|
// for x := 0; x < 10000; x++ {
|
||||||
|
// val := arr[x][0] + arr[x][1] + arr[x][2] + arr[x][3] + arr[x][4] + arr[x][5] + arr[x][6] + arr[x][7] + arr[x][8] + arr[x][9]
|
||||||
|
// val += 0
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func BenchmarkWriteArrayOfInt(b *testing.B) {
|
||||||
|
// type F [10]int
|
||||||
|
// for i := 0; i < b.N; i++ {
|
||||||
|
// arr := make([]F, 10000)
|
||||||
|
// for i := 0; i < 10000; i++ {
|
||||||
|
// arr[i] = [10]int{i, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func BenchmarkWriteRandomArrayOfInt(b *testing.B) {
|
||||||
|
// type F [10]int
|
||||||
|
// for i := 0; i < b.N; i++ {
|
||||||
|
// arr := make([]F, 10000)
|
||||||
|
// for i := 0; i < 10000; i++ {
|
||||||
|
// arr[i] = [10]int{i, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||||
|
// arr[i][0] = 666
|
||||||
|
// arr[i][1] = 666
|
||||||
|
// arr[i][2] = 666
|
||||||
|
// arr[i][3] = 666
|
||||||
|
// arr[i][4] = 666
|
||||||
|
// arr[i][5] = 666
|
||||||
|
// arr[i][6] = 666
|
||||||
|
// arr[i][7] = 666
|
||||||
|
// arr[i][8] = 666
|
||||||
|
// arr[i][9] = 666
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
func BenchmarkReadArrayOfStructs(b *testing.B) {
|
||||||
|
type F struct {
|
||||||
|
A int
|
||||||
|
B int
|
||||||
|
C int
|
||||||
|
D int
|
||||||
|
E int
|
||||||
|
F int
|
||||||
|
G int
|
||||||
|
H int
|
||||||
|
I int
|
||||||
|
J int
|
||||||
|
}
|
||||||
|
arr := make([]F, 10000)
|
||||||
|
for i := 0; i < 10000; i++ {
|
||||||
|
arr[i] = F{i, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkNormalToml(b *testing.B) {
|
|
||||||
benchmarkFile(b, "normal.toml")
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkShortToml(b *testing.B) {
|
|
||||||
benchmarkFile(b, "short.toml")
|
|
||||||
}
|
|
||||||
|
|
||||||
func benchmarkFile(b *testing.B, file string) {
|
|
||||||
toml := BuildGrammar()
|
|
||||||
inputBytes, err := ioutil.ReadFile(file)
|
|
||||||
if err != nil {
|
|
||||||
b.Fatalf("Cannot read input file (%s): %s", file, err)
|
|
||||||
}
|
|
||||||
inputStr := string(inputBytes)
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
_, err := toml.Match(inputStr)
|
for x := 0; x < 10000; x++ {
|
||||||
if err != nil {
|
val := arr[x].A + arr[x].B + arr[x].C + arr[x].D + arr[x].E + arr[x].F + arr[x].G + arr[x].H + arr[x].I + arr[x].J
|
||||||
b.Fatalf("Error in parsing TOML input: %s\n", err)
|
val += 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBugfix(t *testing.T) {
|
func BenchmarkReadStructOfArrays(b *testing.B) {
|
||||||
toml := BuildGrammar()
|
type F struct {
|
||||||
inputBytes, err := ioutil.ReadFile("short.toml")
|
A []int
|
||||||
if err != nil {
|
B []int
|
||||||
t.Fatalf("Cannot read input file (%s): %s", "short.toml", err)
|
C []int
|
||||||
|
D []int
|
||||||
|
E []int
|
||||||
|
F []int
|
||||||
|
G []int
|
||||||
|
H []int
|
||||||
|
I []int
|
||||||
|
J []int
|
||||||
|
}
|
||||||
|
s := F{}
|
||||||
|
for i := 0; i < 10000; i++ {
|
||||||
|
s.A = append(s.A, 1)
|
||||||
|
s.B = append(s.B, 1)
|
||||||
|
s.C = append(s.C, 1)
|
||||||
|
s.D = append(s.D, 1)
|
||||||
|
s.E = append(s.E, 1)
|
||||||
|
s.F = append(s.F, 1)
|
||||||
|
s.G = append(s.G, 1)
|
||||||
|
s.H = append(s.H, 1)
|
||||||
|
s.I = append(s.I, 1)
|
||||||
|
s.J = append(s.J, 1)
|
||||||
}
|
}
|
||||||
inputStr := string(inputBytes)
|
|
||||||
|
|
||||||
_, err = toml.Match(inputStr)
|
for i := 0; i < b.N; i++ {
|
||||||
if err != nil {
|
for x := 0; x < 10000; x++ {
|
||||||
t.Fatalf("Error in parsing TOML input: %s\n", err)
|
val := s.A[x] + s.B[x] + s.C[x] + s.D[x] + s.E[x] + s.F[x] + s.G[x] + s.H[x] + s.I[x] + s.J[x]
|
||||||
|
val += 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// func BenchmarkWriteArrayOfStructs(b *testing.B) {
|
||||||
|
// type F struct {
|
||||||
|
// A int
|
||||||
|
// B int
|
||||||
|
// C int
|
||||||
|
// D int
|
||||||
|
// E int
|
||||||
|
// F int
|
||||||
|
// G int
|
||||||
|
// H int
|
||||||
|
// I int
|
||||||
|
// J int
|
||||||
|
// }
|
||||||
|
// for i := 0; i < b.N; i++ {
|
||||||
|
// arr := make([]F, 10000)
|
||||||
|
// for i := 0; i < 10000; i++ {
|
||||||
|
// arr[i] = F{i, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func BenchmarkWriteRandomArrayOfStructs(b *testing.B) {
|
||||||
|
// type F struct {
|
||||||
|
// A int
|
||||||
|
// B int
|
||||||
|
// C int
|
||||||
|
// D int
|
||||||
|
// E int
|
||||||
|
// F int
|
||||||
|
// G int
|
||||||
|
// H int
|
||||||
|
// I int
|
||||||
|
// J int
|
||||||
|
// }
|
||||||
|
// for i := 0; i < b.N; i++ {
|
||||||
|
// arr := make([]F, 10000)
|
||||||
|
// for i := 0; i < 10000; i++ {
|
||||||
|
// arr[i] = F{i, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||||
|
// arr[i].A = 666
|
||||||
|
// arr[i].B = 666
|
||||||
|
// arr[i].C = 666
|
||||||
|
// arr[i].D = 666
|
||||||
|
// arr[i].E = 666
|
||||||
|
// arr[i].F = 666
|
||||||
|
// arr[i].G = 666
|
||||||
|
// arr[i].H = 666
|
||||||
|
// arr[i].I = 666
|
||||||
|
// arr[i].J = 666
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func BenchmarkReadMapOfStructs(b *testing.B) {
|
||||||
|
// type F struct {
|
||||||
|
// A int
|
||||||
|
// B int
|
||||||
|
// C int
|
||||||
|
// D int
|
||||||
|
// E int
|
||||||
|
// F int
|
||||||
|
// G int
|
||||||
|
// H int
|
||||||
|
// I int
|
||||||
|
// J int
|
||||||
|
// }
|
||||||
|
// fMap := make(map[int]F)
|
||||||
|
// for i := 0; i < 10000; i++ {
|
||||||
|
// fMap[i] = F{i, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||||
|
// }
|
||||||
|
|
||||||
|
// for i := 0; i < b.N; i++ {
|
||||||
|
// for x := 0; x < 10000; x++ {
|
||||||
|
// val := fMap[x].A + fMap[x].B + fMap[x].C + fMap[x].D + fMap[x].E + fMap[x].F + fMap[x].G + fMap[x].H + fMap[x].I + fMap[x].J
|
||||||
|
// val += 0
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func BenchmarkWriteMapOfStructs(b *testing.B) {
|
||||||
|
// type F struct {
|
||||||
|
// A int
|
||||||
|
// B int
|
||||||
|
// C int
|
||||||
|
// D int
|
||||||
|
// E int
|
||||||
|
// F int
|
||||||
|
// G int
|
||||||
|
// H int
|
||||||
|
// I int
|
||||||
|
// J int
|
||||||
|
// }
|
||||||
|
// for i := 0; i < b.N; i++ {
|
||||||
|
// fMap := make(map[int]F)
|
||||||
|
// for i := 0; i < 10000; i++ {
|
||||||
|
// fMap[i] = F{i, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func BenchmarkWriteRandomMapOfStructs(b *testing.B) {
|
||||||
|
// type F struct {
|
||||||
|
// A int
|
||||||
|
// B int
|
||||||
|
// C int
|
||||||
|
// D int
|
||||||
|
// E int
|
||||||
|
// F int
|
||||||
|
// G int
|
||||||
|
// H int
|
||||||
|
// I int
|
||||||
|
// J int
|
||||||
|
// }
|
||||||
|
// for i := 0; i < b.N; i++ {
|
||||||
|
// fMap := make(map[int]F)
|
||||||
|
// for i := 0; i < 10000; i++ {
|
||||||
|
// fMap[i] = F{i, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||||
|
// s := fMap[i]
|
||||||
|
// s.A = 666
|
||||||
|
// s.B = 666
|
||||||
|
// s.C = 666
|
||||||
|
// s.D = 666
|
||||||
|
// s.E = 666
|
||||||
|
// s.F = 666
|
||||||
|
// s.G = 666
|
||||||
|
// s.H = 666
|
||||||
|
// s.I = 666
|
||||||
|
// s.J = 666
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
BIN
parse2/parse2
BIN
parse2/parse2
Binary file not shown.
|
@ -6,16 +6,16 @@ $(cd ../cmd/burntsushi-tester/; go build)
|
||||||
DURATION=`./parse2 -p 10 < long.toml 2>&1 | grep Duration | awk '{print $2}'`
|
DURATION=`./parse2 -p 10 < long.toml 2>&1 | grep Duration | awk '{print $2}'`
|
||||||
echo "$DURATION parse2 10 iteration profiling of long.toml"
|
echo "$DURATION parse2 10 iteration profiling of long.toml"
|
||||||
|
|
||||||
DURATION=`./parse2 -p 1000 < x 2>&1 | grep Duration | awk '{print $2}'`
|
DURATION=`./parse2 -p 1000 < normal.toml 2>&1 | grep Duration | awk '{print $2}'`
|
||||||
echo "$DURATION parse2 1000 iteration profiling of x"
|
echo "$DURATION parse2 1000 iteration profiling of normal.toml"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
DURATION=`../cmd/burntsushi-tester/burntsushi-tester -p 10 < long.toml 2>&1 | grep Duration | awk '{print $2}'`
|
DURATION=`../cmd/burntsushi-tester/burntsushi-tester -p 10 < long.toml 2>&1 | grep Duration | awk '{print $2}'`
|
||||||
echo "$DURATION burntsushi-tester 10 iteration profiling of long.toml"
|
echo "$DURATION burntsushi-tester 10 iteration profiling of long.toml"
|
||||||
|
|
||||||
DURATION=`../cmd/burntsushi-tester/burntsushi-tester -p 1000 < x 2>&1 | grep Duration | awk '{print $2}'`
|
DURATION=`../cmd/burntsushi-tester/burntsushi-tester -p 1000 < normal.toml 2>&1 | grep Duration | awk '{print $2}'`
|
||||||
echo "$DURATION burntsushi-tester 1000 iteration profiling of x"
|
echo "$DURATION burntsushi-tester 1000 iteration profiling of normal.toml"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#cd $GOPATH/src/git.makaay.nl/mauricem/go-toml/cmd/burntsushi-tester/
|
#FILE=short.toml
|
||||||
#go build
|
FILE=normal.toml
|
||||||
#go install
|
#FILE=long.toml
|
||||||
#cd $GOPATH/src/git.makaay.nl/mauricem/go-toml/parse2
|
ITER=10000
|
||||||
#PPFILE=`cat long.toml | $GOPATH/bin/burntsushi-tester 2>&1 | grep "profiling enabled" | cut -d, -f2`
|
|
||||||
#echo $PPFILE
|
|
||||||
|
|
||||||
#ppfile=` | ./parse2 2>&1 | grep "cpu profiling enabled" | cut -d, -f2`
|
|
||||||
|
|
||||||
cd ../cmd/burntsushi-tester
|
cd ../cmd/burntsushi-tester
|
||||||
go build
|
go build
|
||||||
cd ../../parse2
|
cd ../../parse2
|
||||||
ppfile=`cat x | ../cmd/burntsushi-tester/burntsushi-tester -p 100 2>&1 | grep "profiling enabled" | cut -d, -f2`
|
ppfile=`cat $FILE | ../cmd/burntsushi-tester/burntsushi-tester -p $ITER 2>&1 | grep "profiling enabled" | cut -d, -f2`
|
||||||
go tool pprof -http 0.0.0.0:8888 ../cmd/burntsushi-tester/burntsushi-tester $ppfile
|
go tool pprof -http 0.0.0.0:8888 ../cmd/burntsushi-tester/burntsushi-tester $ppfile
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#############################################################
|
#
|
||||||
key={key={}}
|
key={key={}}
|
||||||
|
|
Loading…
Reference in New Issue