Some changes due to the performance improvements in parsekit.
This commit is contained in:
parent
2fb6a5fd34
commit
c37404875d
|
@ -38,14 +38,21 @@ func main() {
|
|||
fmt.Println("Profiling ...")
|
||||
inputBytes, _ := ioutil.ReadAll(os.Stdin)
|
||||
inputStr := string(inputBytes)
|
||||
|
||||
p := profile.Start()
|
||||
start := time.Now()
|
||||
|
||||
for i := 0; i < *doProfile; i++ {
|
||||
result, err = toml.Match(inputStr)
|
||||
if err != nil {
|
||||
panic("Cannot profile, parsing input failed: " + err.Error())
|
||||
}
|
||||
fmt.Printf("cycle %d / %d, tokens=%d\r", i+1, *doProfile, len(result.Tokens))
|
||||
}
|
||||
|
||||
duration := time.Since(start)
|
||||
p.Stop()
|
||||
|
||||
fmt.Printf("\n")
|
||||
fmt.Println("Duration:", duration)
|
||||
return
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func BenchmarkLongToml(b *testing.B) {
|
||||
benchmarkFile(b, "long.toml")
|
||||
}
|
||||
|
||||
func BenchmarkNormalToml(b *testing.B) {
|
||||
benchmarkFile(b, "normal.toml")
|
||||
}
|
||||
|
||||
func BenchmarkShortToml(b *testing.B) {
|
||||
benchmarkFile(b, "short.toml")
|
||||
}
|
||||
|
||||
func benchmarkFile(b *testing.B, file string) {
|
||||
toml := BuildGrammar()
|
||||
inputBytes, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
b.Fatalf("Cannot read input file (%s): %s", file, err)
|
||||
}
|
||||
inputStr := string(inputBytes)
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := toml.Match(inputStr)
|
||||
if err != nil {
|
||||
b.Fatalf("Error in parsing TOML input: %s\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBugfix(t *testing.T) {
|
||||
toml := BuildGrammar()
|
||||
inputBytes, err := ioutil.ReadFile("short.toml")
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot read input file (%s): %s", "short.toml", err)
|
||||
}
|
||||
inputStr := string(inputBytes)
|
||||
|
||||
_, err = toml.Match(inputStr)
|
||||
if err != nil {
|
||||
t.Fatalf("Error in parsing TOML input: %s\n", err)
|
||||
}
|
||||
}
|
BIN
parse2/parse2
BIN
parse2/parse2
Binary file not shown.
|
@ -25,4 +25,13 @@
|
|||
185.826552ms qa-long-loads-of-comments.toml
|
||||
|
||||
0.190 time ./parse2 < long.toml
|
||||
0.005 time ./parse2 < x
|
||||
0.005 time ./parse2 < x
|
||||
|
||||
--- new benchmark tests
|
||||
NO CURSOR UPDATES BASELINE
|
||||
0.264 (test-sushi)
|
||||
274544444 256706465
|
||||
2259506 2118384
|
||||
23911 22624
|
||||
|
||||
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
#############################################################
|
||||
key={key={}}
|
||||
|
|
Loading…
Reference in New Issue