Skip to content

AsaiYusuke/jsonpath-benchmark

Repository files navigation

JSONPath Benchmark

Benchmark JSONPath

This project provides a comprehensive benchmark comparing multiple JSONPath libraries implemented in the Go programming language. It aims to evaluate performance under specific scenarios and offer insights for developers choosing an appropriate library for their use case.

Overview

Results are generated using GitHub Actions to ensure consistency and automation.

The focus of the benchmark is on the cost per operation after the initial setup is complete. This means that preparatory steps, such as parsing or preloading data, are excluded from the measurements. Instead, the benchmark emphasizes scenarios involving intensive looping or query execution within the main operation.

The results may vary depending on several factors, such as the structure of the input data, the complexity of the JSONPath queries, and the specific runtime environment. For this reason, these benchmarks should be considered as a general reference and re-evaluated periodically.

Libraries Benchmarked

The following libraries are included in this benchmark:

Results: Simple Query

JSONPath:

$.store.book[0].price

Performance Summary:

This query was supported by all libraries included in the benchmark, enabling a direct performance comparison across all of them. The fastest performance was achieved by oliveagle/JsonPath, with my library ranking second.

goos: linux
goarch: amd64
pkg: github.com/AsaiYusuke/jsonpath_benchmark
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark1_oliveagle_JsonPath-4          	17907993	        66.96 ns/op	       0 B/op	       0 allocs/op
Benchmark1_AsaiYusuke_JSONPath-4         	10207662	       114.9 ns/op	      24 B/op	       2 allocs/op
Benchmark1_ohler55_OjG_jp-4              	 3250845	       369.4 ns/op	    1168 B/op	       2 allocs/op
Benchmark1_PaesslerAG_JSONPath-4         	 2992747	       399.6 ns/op	     208 B/op	       7 allocs/op
Benchmark1_vmware_labs_YAML_JSONPath-4   	 1327759	       892.5 ns/op	     464 B/op	      28 allocs/op
Benchmark1_bhmj_JSON_Slice-4             	  945770	      1280 ns/op	      24 B/op	       1 allocs/op
Benchmark1_Spyzhov_Abstract_JSON-4       	  779551	      1360 ns/op	     472 B/op	      25 allocs/op
PASS
ok  	github.com/AsaiYusuke/jsonpath_benchmark	10.153s

Results: Complex Query

JSONPath:

$..book[?(@.price > $.store.bicycle.price)]

Performance Summary:

This query involves more complex syntax, and only a subset of the libraries were able to process it. Among these, my library demonstrated the best performance.

goos: linux
goarch: amd64
pkg: github.com/AsaiYusuke/jsonpath_benchmark
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark2_AsaiYusuke_JSONPath-4         	  649182	      1821 ns/op	     240 B/op	       9 allocs/op
Benchmark2_ohler55_OjG_jp-4              	  319102	      3584 ns/op	    6008 B/op	      25 allocs/op
Benchmark2_vmware_labs_YAML_JSONPath-4   	  277615	      4121 ns/op	    4416 B/op	     136 allocs/op
Benchmark2_bhmj_JSON_Slice-4             	   75051	     15940 ns/op	    1784 B/op	      38 allocs/op
Benchmark2_Spyzhov_Abstract_JSON-4       	   76897	     15495 ns/op	    5480 B/op	     223 allocs/op
PASS
ok  	github.com/AsaiYusuke/jsonpath_benchmark	6.291s

Conclusion

This benchmark highlights significant performance differences among popular JSONPath libraries. Developers can use these results as a reference when selecting a library, particularly when performance is critical. For real-world use, consider running benchmarks tailored to your specific datasets and queries.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages