Backup work to performance tuning.

This commit is contained in:
Maurice Makaay 2019-07-05 08:08:33 +00:00
parent af5d35ecee
commit c97a21b146
8 changed files with 22697 additions and 8 deletions

View File

@ -28,7 +28,7 @@ var (
// 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.
comment = c.Seq(a.Hash, c.ZeroOrMore(c.Not(a.EndOfLine)))
comment = c.Seq(a.Hash, a.UntilEndOfLine)
optionalComment = comment.Optional()
endOfLineOrComment = c.Seq(whitespace, optionalComment, a.EndOfLine)

View File

@ -14,7 +14,7 @@ import (
func main() {
toml := BuildGrammar()
fmt.Printf("Reading TOML document from STDIN ...\n")
t := profile.Start()
t := profile.Start() //profile.CPUProfile)
result, err := toml.Match(os.Stdin)
t.Stop()
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("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("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"))))
// 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))

22680
parse2/long.toml Normal file

File diff suppressed because it is too large Load Diff

BIN
parse2/main Executable file

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
#!/bin/bash
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

3
parse2/short.toml Normal file
View File

@ -0,0 +1,3 @@
a=1
b=2
c=3

2
parse2/xtime Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
/usr/bin/time -f '%Uu %Ss %er %MkB %C' "$@"