Backup changes for performance fixes.
This commit is contained in:
parent
68dbf2d78e
commit
1d65cfdd7b
|
@ -41,7 +41,7 @@ func (g Grammar) Get(name string) tokenize.Handler {
|
||||||
if handler, ok := g[name]; ok {
|
if handler, ok := g[name]; ok {
|
||||||
return handler
|
return handler
|
||||||
}
|
}
|
||||||
return func(t *tokenize.API) bool {
|
return func(t tokenize.API) bool {
|
||||||
if handler, ok := g[name]; ok {
|
if handler, ok := g[name]; ok {
|
||||||
return handler(t)
|
return handler(t)
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,7 @@ func BuildGrammar() tokenize.Handler {
|
||||||
m.Drop(G("ml-basic-string-delim"))))
|
m.Drop(G("ml-basic-string-delim"))))
|
||||||
|
|
||||||
// Literal String
|
// Literal String
|
||||||
|
|
||||||
R("literal-char", c.Any(G("tab"), a.RuneRange(0x20, 0x26), a.RuneRange(0x28, 0x7E), G("non-ascii")))
|
R("literal-char", c.Any(G("tab"), a.RuneRange(0x20, 0x26), a.RuneRange(0x28, 0x7E), G("non-ascii")))
|
||||||
R("literal-string", c.Seq(
|
R("literal-string", c.Seq(
|
||||||
m.Drop(G("apostrophe")),
|
m.Drop(G("apostrophe")),
|
||||||
|
@ -177,7 +178,7 @@ func BuildGrammar() tokenize.Handler {
|
||||||
|
|
||||||
R("float", c.Any(
|
R("float", c.Any(
|
||||||
tok.Float64("float", G("standard-float")),
|
tok.Float64("float", G("standard-float")),
|
||||||
tok.ByCallback("float", G("inf-float"), func(t *tokenize.API) interface{} {
|
tok.ByCallback("float", G("inf-float"), func(t tokenize.API) interface{} {
|
||||||
if t.Result().Rune(0) == '-' {
|
if t.Result().Rune(0) == '-' {
|
||||||
return math.Inf(-1)
|
return math.Inf(-1)
|
||||||
}
|
}
|
||||||
|
@ -220,7 +221,7 @@ func BuildGrammar() tokenize.Handler {
|
||||||
R("local-date", G("date"))
|
R("local-date", G("date"))
|
||||||
R("local-time", G("time"))
|
R("local-time", G("time"))
|
||||||
|
|
||||||
makeDateTimeValue := func(t *tokenize.API) interface{} {
|
makeDateTimeValue := func(t tokenize.API) interface{} {
|
||||||
layout := ""
|
layout := ""
|
||||||
input := ""
|
input := ""
|
||||||
for _, t := range t.Result().Tokens() {
|
for _, t := range t.Result().Tokens() {
|
||||||
|
@ -244,16 +245,18 @@ func BuildGrammar() tokenize.Handler {
|
||||||
// Inline Table
|
// Inline Table
|
||||||
|
|
||||||
R("inline-table-open", a.CurlyOpen.Then(G("ws")))
|
R("inline-table-open", a.CurlyOpen.Then(G("ws")))
|
||||||
R("inline-table-close", G("ws").Then(a.CurlyClose))
|
|
||||||
R("inline-table-sep", c.Seq(G("ws"), a.Comma, G("ws")))
|
R("inline-table-sep", c.Seq(G("ws"), a.Comma, G("ws")))
|
||||||
R("inline-table-keyvals", c.Seq(G("keyval"), c.ZeroOrMore(c.Seq(G("inline-table-sep"), G("keyval")))))
|
R("inline-table-keyvals", c.Separated(G("inline-table-sep"), G("keyval")))
|
||||||
|
R("inline-table-close", G("ws").Then(a.CurlyClose))
|
||||||
|
|
||||||
R("inline-table", tok.Group("inline-table", c.Seq(G("inline-table-open"), G("inline-table-keyvals"), G("inline-table-close"))))
|
R("inline-table", tok.Group("inline-table", c.Seq(
|
||||||
|
G("inline-table-open"),
|
||||||
|
G("inline-table-keyvals"),
|
||||||
|
G("inline-table-close"))))
|
||||||
|
|
||||||
// Array
|
// Inline Array
|
||||||
|
|
||||||
R("array-open", a.SquareOpen)
|
R("array-open", a.SquareOpen)
|
||||||
R("array-close", a.SquareClose)
|
|
||||||
R("array-sep", G("ws").Then(a.Comma))
|
R("array-sep", G("ws").Then(a.Comma))
|
||||||
R("ws-comment-newline", c.ZeroOrMore(G("whitespaceChar").Or(G("comment").Optional().Then(G("newline")))))
|
R("ws-comment-newline", c.ZeroOrMore(G("whitespaceChar").Or(G("comment").Optional().Then(G("newline")))))
|
||||||
R("array-values", c.Seq(
|
R("array-values", c.Seq(
|
||||||
|
@ -261,6 +264,7 @@ func BuildGrammar() tokenize.Handler {
|
||||||
G("val"),
|
G("val"),
|
||||||
c.ZeroOrMore(c.Seq(G("ws"), G("array-sep"), G("ws-comment-newline"), G("val"))),
|
c.ZeroOrMore(c.Seq(G("ws"), G("array-sep"), G("ws-comment-newline"), G("val"))),
|
||||||
G("array-sep").Optional()))
|
G("array-sep").Optional()))
|
||||||
|
R("array-close", a.SquareClose)
|
||||||
|
|
||||||
R("inline-array", tok.Group("array", c.Seq(G("array-open"), G("array-values").Optional(), G("ws-comment-newline"), G("array-close"))))
|
R("inline-array", tok.Group("array", c.Seq(G("array-open"), G("array-values").Optional(), G("ws-comment-newline"), G("array-close"))))
|
||||||
|
|
||||||
|
@ -288,13 +292,21 @@ func BuildGrammar() tokenize.Handler {
|
||||||
R("quoted-key", G("basic-string").Or(G("literal-string")))
|
R("quoted-key", G("basic-string").Or(G("literal-string")))
|
||||||
R("key-sep", c.Seq(G("ws"), a.Dot, G("ws")))
|
R("key-sep", c.Seq(G("ws"), a.Dot, G("ws")))
|
||||||
R("simple-key", tok.Str("key-part", G("quoted-key").Or(G("unquoted-key"))))
|
R("simple-key", tok.Str("key-part", G("quoted-key").Or(G("unquoted-key"))))
|
||||||
R("dotted-key", c.Separated(G("simple-key"), G("key-sep")))
|
R("dotted-key", c.Separated(G("key-sep"), G("simple-key")))
|
||||||
|
|
||||||
R("key", c.FlushInput(tok.Group("key", G("dotted-key").Or(G("simple-key")))))
|
R("key", c.FlushInput(tok.Group("key", G("dotted-key").Or(G("simple-key")))))
|
||||||
|
|
||||||
R("keyval-sep", c.FlushInput(c.Seq(G("ws"), a.Equal, G("ws"))))
|
R("keyval-sep", c.FlushInput(c.Seq(G("ws"), a.Equal, G("ws"))))
|
||||||
|
|
||||||
R("val", c.FlushInput(tok.Group("val", c.Any(G("string"), G("boolean"), G("inline-array"), G("inline-table"), G("date-time"), G("float"), G("integer")))))
|
R("val", tok.Group("val", c.Any(
|
||||||
|
G("string"),
|
||||||
|
G("date-time"),
|
||||||
|
G("float"),
|
||||||
|
G("integer"),
|
||||||
|
G("boolean"),
|
||||||
|
G("inline-array"),
|
||||||
|
G("inline-table"),
|
||||||
|
)))
|
||||||
|
|
||||||
R("keyval", tok.Group("keyval", c.Seq(G("key"), G("keyval-sep"), G("val"))))
|
R("keyval", tok.Group("keyval", c.Seq(G("key"), G("keyval-sep"), G("val"))))
|
||||||
|
|
||||||
|
|
BIN
parse2/parse2
BIN
parse2/parse2
Binary file not shown.
|
@ -1,6 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#cd $GOPATH/src/git.makaay.nl/mauricem/go-toml/cmd/burntsushi-tester/
|
||||||
|
#go build
|
||||||
|
#go install
|
||||||
|
#cd $GOPATH/src/git.makaay.nl/mauricem/go-toml/parse2
|
||||||
|
#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`
|
||||||
|
|
||||||
|
echo "Building ..."
|
||||||
go build
|
go build
|
||||||
ppfile=`cat long.toml | ./parse2 2>&1 | grep "cpu profiling enabled" | cut -d, -f2`
|
echo "Running ..."
|
||||||
#ppfile=`cat short.toml | ./parse2 2>&1 | grep "cpu profiling enabled" | cut -d, -f2`
|
time cat long.toml | ./parse2 2>&1
|
||||||
|
echo "Profiling ..."
|
||||||
|
ppfile=`cat long.toml | time ./parse2 2>&1 | grep "cpu 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
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
a=1
|
c=[1]
|
||||||
b=2
|
|
||||||
c=3
|
|
||||||
|
|
Loading…
Reference in New Issue