Backup work on performance improvements.
This commit is contained in:
parent
1d65cfdd7b
commit
30a0d80d84
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
|
@ -12,16 +13,23 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
bytes, _ := ioutil.ReadAll(os.Stdin)
|
||||||
|
input := string(bytes)
|
||||||
|
|
||||||
toml := BuildGrammar()
|
toml := BuildGrammar()
|
||||||
fmt.Printf("Reading TOML document from STDIN ...\n")
|
|
||||||
t := profile.Start() //profile.CPUProfile)
|
t := profile.Start() //profile.CPUProfile)
|
||||||
result, err := toml.Match(os.Stdin)
|
var result *tokenize.Result
|
||||||
|
var err error
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
fmt.Printf(".")
|
||||||
|
result, err = toml.Match(input)
|
||||||
|
}
|
||||||
t.Stop()
|
t.Stop()
|
||||||
fmt.Printf("Completed reading document.\n")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error in parsing TOML: %s\n", err)
|
log.Fatalf("Error in parsing TOML: %s\n", err)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Result:\n")
|
|
||||||
for i, t := range result.Tokens() {
|
for i, t := range result.Tokens() {
|
||||||
fmt.Printf("[%d] %v\n", i, t)
|
fmt.Printf("[%d] %v\n", i, t)
|
||||||
}
|
}
|
||||||
|
|
BIN
parse2/parse2
BIN
parse2/parse2
Binary file not shown.
|
@ -9,11 +9,7 @@
|
||||||
|
|
||||||
#ppfile=` | ./parse2 2>&1 | grep "cpu profiling enabled" | cut -d, -f2`
|
#ppfile=` | ./parse2 2>&1 | grep "cpu profiling enabled" | cut -d, -f2`
|
||||||
|
|
||||||
echo "Building ..."
|
|
||||||
go build
|
go build
|
||||||
echo "Running ..."
|
ppfile=`cat long.toml | time ./parse2 2>&1 | grep "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 +1 @@
|
||||||
c=[1]
|
x=1
|
||||||
|
|
Loading…
Reference in New Issue