Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
json: improve performance by using a pool of scanners (#535)
* add benchmark for each detector with it's corresponding file * json/ndjson: use a pool of scanners for detection it helps by reducing memory allocations to amortized 0 ➜ mimetype git:(bench) ✗ benchstat master sync_pool goos: linux goarch: amd64 pkg: github.com/gabriel-vasile/mimetype cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz │ master │ sync_pool │ │ sec/op │ sec/op vs base │ Files/json.json/application/json-8 1.403µ ± 0% 1.355µ ± 1% -3.39% (p=0.000 n=20) Files/ndjson.xl.ndjson/application/x-ndjson-8 8.655µ ± 1% 8.504µ ± 1% -1.76% (p=0.001 n=20) Files/ndjson.ndjson/application/x-ndjson-8 3.069µ ± 1% 2.958µ ± 5% ~ (p=0.129 n=20) geomean 3.340µ 3.242µ -2.92% │ master │ sync_pool │ │ B/op │ B/op vs base │ Files/json.json/application/json-8 120.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=20) Files/ndjson.xl.ndjson/application/x-ndjson-8 720.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=20) Files/ndjson.ndjson/application/x-ndjson-8 240.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=20) geomean 274.7 ? ¹ ² ¹ summaries must be >0 to compute geomean ² ratios must be >0 to compute geomean │ master │ sync_pool │ │ allocs/op │ allocs/op vs base │ Files/json.json/application/json-8 4.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=20) Files/ndjson.xl.ndjson/application/x-ndjson-8 24.00 ± 0% 0.00 ± 0% -100.00% (p=0.000 n=20) Files/ndjson.ndjson/application/x-ndjson-8 8.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=20) geomean 9.158 ? ¹ ² ¹ summaries must be >0 to compute geomean ² ratios must be >0 to compute geomean * benchmark: use sequential instead of concurrent benchmarks there is no reason to make it concurrent
- Loading branch information