Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Jun 20, 2024
1 parent 3891179 commit 5371c86
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 10 additions & 9 deletions dev/ast/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"
"testing"

"github.com/bytedance/sonic/ast"
"github.com/bytedance/sonic/internal/decoder"
"github.com/davecgh/go-spew/spew"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -65,17 +66,17 @@ func TestNodeParse(t *testing.T) {

func BenchmarkNode_GetByPath(b *testing.B) {
b.Run("10/2", func(b *testing.B) {
src := getSample(10, 1)
src := getSample(10, 0)
b.ResetTimer()
n, _ := NewParser(src).Parse()
n, _ := ast.NewParser(src).Parse()
for i := 0; i < b.N; i++ {
_ = n.GetByPath("5")
}
})
b.Run("10/2/2", func(b *testing.B) {
src := getSample(10, 1)
b.ResetTimer()
n, _ := NewParser(src).Parse()
n, _ := ast.NewParser(src).Parse()
for i := 0; i < b.N; i++ {
x := n.GetByPath("5", "5")
if x.Check() != nil {
Expand All @@ -84,17 +85,17 @@ func BenchmarkNode_GetByPath(b *testing.B) {
}
})
b.Run("100/2", func(b *testing.B) {
src := getSample(100, 1)
src := getSample(100, 0)
b.ResetTimer()
n, _ := NewParser(src).Parse()
n, _ := ast.NewParser(src).Parse()
for i := 0; i < b.N; i++ {
_ = n.GetByPath("50")
}
})
b.Run("100/2/2", func(b *testing.B) {
src := getSample(100, 1)
b.ResetTimer()
n, _ := NewParser(src).Parse()
n, _ := ast.NewParser(src).Parse()
for i := 0; i < b.N; i++ {
x := n.GetByPath("50", "50")
if x.Check() != nil {
Expand All @@ -103,17 +104,17 @@ func BenchmarkNode_GetByPath(b *testing.B) {
}
})
b.Run("1000/2", func(b *testing.B) {
src := getSample(1000, 1)
src := getSample(1000, 0)
b.ResetTimer()
n, _ := NewParser(src).Parse()
n, _ := ast.NewParser(src).Parse()
for i := 0; i < b.N; i++ {
_ = n.GetByPath("500")
}
})
b.Run("1000/2/2", func(b *testing.B) {
src := getSample(1000, 1)
b.ResetTimer()
n, _ := NewParser(src).Parse()
n, _ := ast.NewParser(src).Parse()
for i := 0; i < b.N; i++ {
x := n.GetByPath("500", "500")
if x.Check() != nil {
Expand Down
2 changes: 0 additions & 2 deletions dev/ast/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/bytedance/sonic/internal/native"
"github.com/bytedance/sonic/internal/native/types"
"github.com/bytedance/sonic/internal/rt"
"github.com/davecgh/go-spew/spew"
)

type Parser struct {
Expand All @@ -40,7 +39,6 @@ func (self *Parser) Pos() int {
// parse one layer but no validate sub layers
func (self *Parser) Parse() (Node, error) {
node, err := parseLazy(self.src, nil)
spew.Dump(node.node)
if err != nil {
return Node{}, err
}
Expand Down

0 comments on commit 5371c86

Please sign in to comment.