Add some basic benchmarking.
This CL adds a "benchmarking" directory containing a driver and
4 JSON files that can be used to benchmark how fast loads() is.
The four files are taken from a Chromium checkout, revision 2d1b70999b
(#495218, from 2017-18-03):
chromium.linux.json is //testing/buildbot/chromium.linux.json
chromium.perf.json is //testing/buildbot/chromium.perf.json
ios-simulator.json is //ios/build/bots/ios-simulator.json
mb_config.json is //tools/mb/mb_config.pyl, converted to the equivalent
JSON object via json.dumps(ast.literal_eval(), indent=2, sort_keys=True).
which are 5k, 111k, 2k, and 95 lines, respectively, and probably give
a decent range of sizes.
The benchmark driver reads the four files into memory, and then calls
json.loads() and json5.loads() on each. The driver can be configured
to use either the default json decoder (which contains native C routines)
or the pure-python implementation.
Running the benchmarks on a mid-2015 27" Retina iMac (with a 3.3 GHz
Core i5 CPU and 32 GB of RAM) using Python 2.7.10 on MacOS 10.12.6,
the JSON5 decoder is roughly 1000-6000x slower than the C JSON decoder,
and 200x+ slower than the pure Python JSON decoder.
5 files changed