Backup work to performance tuning.
This commit is contained in:
parent
af5d35ecee
commit
c97a21b146
|
@ -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, c.ZeroOrMore(c.Not(a.EndOfLine)))
|
comment = c.Seq(a.Hash, a.UntilEndOfLine)
|
||||||
optionalComment = comment.Optional()
|
optionalComment = comment.Optional()
|
||||||
|
|
||||||
endOfLineOrComment = c.Seq(whitespace, optionalComment, a.EndOfLine)
|
endOfLineOrComment = c.Seq(whitespace, optionalComment, a.EndOfLine)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
func main() {
|
func main() {
|
||||||
toml := BuildGrammar()
|
toml := BuildGrammar()
|
||||||
fmt.Printf("Reading TOML document from STDIN ...\n")
|
fmt.Printf("Reading TOML document from STDIN ...\n")
|
||||||
t := profile.Start()
|
t := profile.Start() //profile.CPUProfile)
|
||||||
result, err := toml.Match(os.Stdin)
|
result, err := toml.Match(os.Stdin)
|
||||||
t.Stop()
|
t.Stop()
|
||||||
fmt.Printf("Completed reading document.\n")
|
fmt.Printf("Completed reading document.\n")
|
||||||
|
@ -288,19 +288,23 @@ 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.Seq(G("simple-key"), c.OneOrMore(G("key-sep").Then(G("simple-key")))))
|
R("dotted-key", c.Separated(G("simple-key"), G("key-sep")))
|
||||||
|
|
||||||
R("keyval-sep", c.Seq(G("ws"), a.Equal, G("ws")))
|
R("key", c.FlushInput(tok.Group("key", G("dotted-key").Or(G("simple-key")))))
|
||||||
|
|
||||||
R("key", tok.Group("key", G("dotted-key").Or(G("simple-key"))))
|
R("keyval-sep", c.FlushInput(c.Seq(G("ws"), a.Equal, G("ws"))))
|
||||||
|
|
||||||
R("val", tok.Group("val", c.Any(G("string"), G("boolean"), G("inline-array"), G("inline-table"), G("date-time"), G("float"), G("integer"))))
|
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("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"))))
|
||||||
|
|
||||||
// Overall Structure
|
// Overall Structure
|
||||||
|
|
||||||
R("expression", c.Seq(G("ws"), c.Optional(G("table").Or(G("keyval"))), G("ws"), G("comment").Optional()))
|
R("expression", c.Seq(
|
||||||
|
c.FlushInput(G("ws")),
|
||||||
|
c.FlushInput(c.Optional(G("table").Or(G("keyval")))),
|
||||||
|
c.FlushInput(G("ws")),
|
||||||
|
c.FlushInput(G("comment").Optional())))
|
||||||
|
|
||||||
R("toml", c.Seq(G("expression"), c.ZeroOrMore(G("newline").Then(G("expression"))), a.EndOfFile))
|
R("toml", c.Seq(G("expression"), c.ZeroOrMore(G("newline").Then(G("expression"))), a.EndOfFile))
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
BIN
parse2/parse2
BIN
parse2/parse2
Binary file not shown.
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
go build
|
go build
|
||||||
ppfile=`cat /tmp/y | ./parse2 2>&1 | grep "cpu profiling enabled" | cut -d, -f2`
|
ppfile=`cat long.toml | ./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
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
a=1
|
||||||
|
b=2
|
||||||
|
c=3
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
/usr/bin/time -f '%Uu %Ss %er %MkB %C' "$@"
|
Loading…
Reference in New Issue