Lowering the number of forks required.
This commit is contained in:
parent
68ab1293f2
commit
bf7b693cb8
|
@ -133,8 +133,8 @@ const (
|
||||||
TypeImplicitTable ValueType = "implicit-table"
|
TypeImplicitTable ValueType = "implicit-table"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetKeyValuePair is used to set a key and an accompanying value in the
|
// SetKeyValuePair sets a key and an accompanying value in the currently active
|
||||||
// currently active TOML table of the TOML Document.
|
// TOML table of the TOML Document.
|
||||||
func (doc *Document) SetKeyValuePair(key Key, value *Value) error {
|
func (doc *Document) SetKeyValuePair(key Key, value *Value) error {
|
||||||
// First make sure the table structure for storing the value exists.
|
// First make sure the table structure for storing the value exists.
|
||||||
node, lastKeyPart, err := doc.makeTablePath(key)
|
node, lastKeyPart, err := doc.makeTablePath(key)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
PROFILE_COUNT=100
|
||||||
|
|
||||||
b:
|
b:
|
||||||
go build
|
go build
|
||||||
mv burntsushi-tester B
|
mv burntsushi-tester B
|
||||||
|
@ -21,20 +23,30 @@ profile: profile-a profile-b
|
||||||
test-a:
|
test-a:
|
||||||
numactl --physcpubind=+1 bash -c "time ./A < testfile.toml"
|
numactl --physcpubind=+1 bash -c "time ./A < testfile.toml"
|
||||||
|
|
||||||
|
test2-a:
|
||||||
|
numactl --physcpubind=+1 bash -c "time ./A < testfile2.toml"
|
||||||
|
|
||||||
profile-a:
|
profile-a:
|
||||||
numactl --physcpubind=+1 bash -c "./A -p 250 < testfile.toml"
|
numactl --physcpubind=+1 bash -c "./A -p ${PROFILE_COUNT} < testfile.toml"
|
||||||
|
|
||||||
|
|
||||||
test-b:
|
test-b:
|
||||||
numactl --physcpubind=+2 bash -c "time ./B < testfile.toml"
|
numactl --physcpubind=+2 bash -c "time ./B < testfile.toml"
|
||||||
|
|
||||||
|
test2-b:
|
||||||
|
numactl --physcpubind=+2 bash -c "time ./B < testfile2.toml"
|
||||||
|
|
||||||
profile-b:
|
profile-b:
|
||||||
numactl --physcpubind=+2 bash -c "./B -p 250 < testfile.toml"
|
numactl --physcpubind=+2 bash -c "./B -p ${PROFILE_COUNT} < testfile.toml"
|
||||||
|
|
||||||
test-sushi:
|
test-sushi:
|
||||||
|
|
||||||
numactl --physcpubind=+3 bash -c "time ${GOPATH}/bin/toml-test-decoder < testfile.toml"
|
numactl --physcpubind=+3 bash -c "time ${GOPATH}/bin/toml-test-decoder < testfile.toml"
|
||||||
|
|
||||||
|
test2-sushi:
|
||||||
|
|
||||||
|
numactl --physcpubind=+3 bash -c "time ${GOPATH}/bin/toml-test-decoder < testfile2.toml"
|
||||||
|
|
||||||
|
|
||||||
test-sushi-a:
|
test-sushi-a:
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ func (t *parser) startKeyValuePair(p *parse.API) {
|
||||||
if value, ok := t.parseValue(p); ok {
|
if value, ok := t.parseValue(p); ok {
|
||||||
err := t.doc.SetKeyValuePair(key, value)
|
err := t.doc.SetKeyValuePair(key, value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.Error("%s", err)
|
p.SetError("%s", err)
|
||||||
} else if !p.Accept(endOfLineOrComment) {
|
} else if !p.Accept(endOfLineOrComment) {
|
||||||
p.Expected("end of line")
|
p.Expected("end of line")
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ func (t *parser) parseArray(p *parse.API) (*ast.Value, bool) {
|
||||||
// considered the same type, and so should arrays with different element types).
|
// considered the same type, and so should arrays with different element types).
|
||||||
// This constraint is checked by ast.Array.Append().
|
// This constraint is checked by ast.Array.Append().
|
||||||
if err := a.Append(value); err != nil {
|
if err := a.Append(value); err != nil {
|
||||||
p.Error(err.Error())
|
p.SetError(err.Error())
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ func (t *parser) parseDateTime(p *parse.API) (*ast.Value, bool) {
|
||||||
}
|
}
|
||||||
value, err := time.Parse(layout, p.Result.String())
|
value, err := time.Parse(layout, p.Result.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.Error("invalid date/time value %s: %s", p.Result.String(), err)
|
p.SetError("invalid date/time value %s: %s", p.Result.String(), err)
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,6 @@ func (t *parser) parseIntegerStartingWithZero(p *parse.API) (*ast.Value, bool) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return ast.NewValue(ast.TypeInteger, value), true
|
return ast.NewValue(ast.TypeInteger, value), true
|
||||||
}
|
}
|
||||||
p.Error("invalid integer value 0%s: %s", p.Result.String(), err)
|
p.SetError("invalid integer value 0%s: %s", p.Result.String(), err)
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,19 +104,19 @@ func (t *parser) parseBasicString(name string, p *parse.API) (string, bool) {
|
||||||
for {
|
for {
|
||||||
switch {
|
switch {
|
||||||
case p.PeekWithResult(controlCharacter):
|
case p.PeekWithResult(controlCharacter):
|
||||||
p.Error("invalid character in %s: %q (must be escaped)", name, p.Result.Runes[0])
|
p.SetError("invalid character in %s: %q (must be escaped)", name, p.Result.Runes[0])
|
||||||
return sb.String(), false
|
return sb.String(), false
|
||||||
case p.Accept(validEscape):
|
case p.Accept(validEscape):
|
||||||
if !appendEscapedRune(p, sb) {
|
if !appendEscapedRune(p, sb) {
|
||||||
return sb.String(), false
|
return sb.String(), false
|
||||||
}
|
}
|
||||||
case p.Peek(a.Backslash):
|
case p.Peek(a.Backslash):
|
||||||
p.Error("invalid escape sequence")
|
p.SetError("invalid escape sequence")
|
||||||
return sb.String(), false
|
return sb.String(), false
|
||||||
case p.Accept(basicStringDelimiter):
|
case p.Accept(basicStringDelimiter):
|
||||||
return sb.String(), true
|
return sb.String(), true
|
||||||
case p.Peek(a.InvalidRune):
|
case p.Peek(a.InvalidRune):
|
||||||
p.Error("invalid UTF8 rune")
|
p.SetError("invalid UTF8 rune")
|
||||||
return sb.String(), false
|
return sb.String(), false
|
||||||
case p.Accept(a.ValidRune):
|
case p.Accept(a.ValidRune):
|
||||||
sb.WriteString(p.Result.String())
|
sb.WriteString(p.Result.String())
|
||||||
|
@ -147,10 +147,10 @@ func (t *parser) parseLiteralString(name string, p *parse.API) (string, bool) {
|
||||||
case p.Accept(a.Tab):
|
case p.Accept(a.Tab):
|
||||||
sb.WriteString("\t")
|
sb.WriteString("\t")
|
||||||
case p.PeekWithResult(controlCharacter):
|
case p.PeekWithResult(controlCharacter):
|
||||||
p.Error("invalid character in %s: %q (no control chars allowed, except for tab)", name, p.Result.Runes[0])
|
p.SetError("invalid character in %s: %q (no control chars allowed, except for tab)", name, p.Result.Runes[0])
|
||||||
return sb.String(), false
|
return sb.String(), false
|
||||||
case p.Peek(a.InvalidRune):
|
case p.Peek(a.InvalidRune):
|
||||||
p.Error("invalid UTF8 rune")
|
p.SetError("invalid UTF8 rune")
|
||||||
return sb.String(), false
|
return sb.String(), false
|
||||||
case p.Accept(a.ValidRune):
|
case p.Accept(a.ValidRune):
|
||||||
sb.WriteString(p.Result.String())
|
sb.WriteString(p.Result.String())
|
||||||
|
@ -195,7 +195,7 @@ func (t *parser) parseMultiLineBasicString(p *parse.API) (string, bool) {
|
||||||
case p.Accept(newline):
|
case p.Accept(newline):
|
||||||
sb.WriteString("\n")
|
sb.WriteString("\n")
|
||||||
case p.PeekWithResult(controlCharacter):
|
case p.PeekWithResult(controlCharacter):
|
||||||
p.Error("invalid character in multi-line basic string: %q (must be escaped)", p.Result.Runes[0])
|
p.SetError("invalid character in multi-line basic string: %q (must be escaped)", p.Result.Runes[0])
|
||||||
return sb.String(), false
|
return sb.String(), false
|
||||||
case p.Accept(validEscape):
|
case p.Accept(validEscape):
|
||||||
if !appendEscapedRune(p, sb) {
|
if !appendEscapedRune(p, sb) {
|
||||||
|
@ -204,14 +204,14 @@ func (t *parser) parseMultiLineBasicString(p *parse.API) (string, bool) {
|
||||||
case p.Accept(lineEndingBackslash):
|
case p.Accept(lineEndingBackslash):
|
||||||
// NOOP, the line-ending backslash sequence is skipped.
|
// NOOP, the line-ending backslash sequence is skipped.
|
||||||
case p.Peek(a.Backslash):
|
case p.Peek(a.Backslash):
|
||||||
p.Error("invalid escape sequence")
|
p.SetError("invalid escape sequence")
|
||||||
return sb.String(), false
|
return sb.String(), false
|
||||||
case p.Accept(closingMultiLineBasicString):
|
case p.Accept(closingMultiLineBasicString):
|
||||||
return sb.String(), true
|
return sb.String(), true
|
||||||
case p.Accept(a.ValidRune):
|
case p.Accept(a.ValidRune):
|
||||||
sb.WriteString(p.Result.String())
|
sb.WriteString(p.Result.String())
|
||||||
case p.Peek(a.InvalidRune):
|
case p.Peek(a.InvalidRune):
|
||||||
p.Error("invalid UTF8 rune")
|
p.SetError("invalid UTF8 rune")
|
||||||
return sb.String(), false
|
return sb.String(), false
|
||||||
default:
|
default:
|
||||||
p.Expected("closing three quotation marks")
|
p.Expected("closing three quotation marks")
|
||||||
|
@ -243,7 +243,7 @@ func appendEscapedRune(p *parse.API, sb *strings.Builder) bool {
|
||||||
val, _ := strconv.ParseUint(hex, 16, 32) // hex format already validated by parser
|
val, _ := strconv.ParseUint(hex, 16, 32) // hex format already validated by parser
|
||||||
r := rune(val)
|
r := rune(val)
|
||||||
if !utf8.ValidRune(r) {
|
if !utf8.ValidRune(r) {
|
||||||
p.Error(fmt.Sprintf("invalid UTF8 escape '%s'", s))
|
p.SetError(fmt.Sprintf("invalid UTF8 escape '%s'", s))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
sb.WriteRune(r)
|
sb.WriteRune(r)
|
||||||
|
@ -279,12 +279,12 @@ func (t *parser) parseMultiLineLiteralString(p *parse.API) (string, bool) {
|
||||||
case p.Accept(newline):
|
case p.Accept(newline):
|
||||||
sb.WriteString("\n")
|
sb.WriteString("\n")
|
||||||
case p.PeekWithResult(controlCharacter):
|
case p.PeekWithResult(controlCharacter):
|
||||||
p.Error("invalid character in literal string: %q (no control chars allowed, except for tab and newline)", p.Result.Runes[0])
|
p.SetError("invalid character in literal string: %q (no control chars allowed, except for tab and newline)", p.Result.Runes[0])
|
||||||
return sb.String(), false
|
return sb.String(), false
|
||||||
case p.Accept(a.ValidRune):
|
case p.Accept(a.ValidRune):
|
||||||
sb.WriteString(p.Result.String())
|
sb.WriteString(p.Result.String())
|
||||||
case p.Peek(a.InvalidRune):
|
case p.Peek(a.InvalidRune):
|
||||||
p.Error("invalid UTF8 rune")
|
p.SetError("invalid UTF8 rune")
|
||||||
return sb.String(), false
|
return sb.String(), false
|
||||||
default:
|
default:
|
||||||
p.Expected("closing three single quotes")
|
p.Expected("closing three single quotes")
|
||||||
|
|
|
@ -80,7 +80,7 @@ func (t *parser) startArrayOfTables(p *parse.API) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := t.doc.OpenArrayOfTables(key); err != nil {
|
if err := t.doc.OpenArrayOfTables(key); err != nil {
|
||||||
p.Error("%s", err)
|
p.SetError("%s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.Handle(t.startDocument)
|
p.Handle(t.startDocument)
|
||||||
|
@ -136,7 +136,7 @@ func (t *parser) startPlainTable(p *parse.API) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := t.doc.OpenTable(key); err != nil {
|
if err := t.doc.OpenTable(key); err != nil {
|
||||||
p.Error("%s", err)
|
p.SetError("%s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.Handle(t.startDocument)
|
p.Handle(t.startDocument)
|
||||||
|
@ -188,7 +188,7 @@ func (t *parser) parseInlineTable(p *parse.API) (*ast.Value, bool) {
|
||||||
}
|
}
|
||||||
err := subdoc.doc.SetKeyValuePair(key, value)
|
err := subdoc.doc.SetKeyValuePair(key, value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.Error("%s", err)
|
p.SetError("%s", err)
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ FILE=normal.toml
|
||||||
ITER=10000
|
ITER=10000
|
||||||
|
|
||||||
cd ../cmd/burntsushi-tester
|
cd ../cmd/burntsushi-tester
|
||||||
go build
|
go build -gcflags=all=-l
|
||||||
cd ../../parse2
|
cd ../../parse2
|
||||||
ppfile=`cat $FILE | ../cmd/burntsushi-tester/burntsushi-tester -p $ITER 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
|
||||||
|
|
|
@ -11,6 +11,6 @@
|
||||||
|
|
||||||
#go build -gcflags=all=-l -v
|
#go build -gcflags=all=-l -v
|
||||||
go build -v
|
go build -v
|
||||||
ppfile=`cat long.toml | ./parse2 -p 25 2>&1 | grep "profiling enabled" | cut -d, -f2`
|
ppfile=`cat long.toml | ./parse2 -p 50 2>&1 | grep "profiling enabled" | cut -d, -f2`
|
||||||
go tool pprof -http 0.0.0.0:8888 ./parse2 $ppfile
|
go tool pprof -http 0.0.0.0:8888 ./parse2 $ppfile
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue