-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjpath_test.go
21 lines (19 loc) · 881 Bytes
/
jpath_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package main
import (
"github.com/prashanth-hegde/jpath/common"
"github.com/prashanth-hegde/jpath/input"
"github.com/prashanth-hegde/jpath/parser"
"testing"
)
// Benchmark_Jpath benchmarking function - generates a flame graph of usage
// To use, put a large file in /tmp/output.json (or whatever filename)
// and then update a complex query in the test below
// Then run this command
// go test -bench=Jpath -cpuprofile=cpuprof_jpath.out
// To render the flame graph, upload cpuprof_jpath.out on this page https://www.speedscope.app/
// refer: https://sathishvj.medium.com/flamegraphs-for-code-optimization-with-golang-and-speedscope-80c20725fdd2
func Benchmark_Jpath(b *testing.B) {
jsonb, _ := input.ParseInputJson("/tmp/output.json")
json, _ := common.Tokenize(jsonb)
_, _ = parser.ProcessExpression(".event_context.container[location_id=3857].changed_values", json)
}