Closed Nykakin closed 3 years ago
Experimenting with optimizing the code. Results so far... less impressive that I hoped:
Benchmark 1:
import base64 import itertools import timeit from _chompjs import parse keys = (''.join(i) for i in itertools.combinations_with_replacement('abcdefghijklmnopqrstuvwxyz', 2)) keys_values = ('\'{}\': "{}",'.format(key, base64.b64encode('aa'.encode('ascii')).decode('utf-8')) for key in keys) json_input = "{{{}}}".format(''.join(keys_values)) timeit.timeit('parse(json_input)', 'from __main__ import json_input, parse')
Benchmark 2:
import timeit from _chompjs import parse json_input = '[' * 400 + '2' + ']' * 400 timeit.timeit('parse(json_input)', 'from __main__ import json_input, parse')
Benchmark 3:
import timeit from _chompjs import parse json_data = str(list(range(500))) timeit.timeit('parse(json_input)', 'from __main__ import json_input, parse')
Experimenting with optimizing the code. Results so far... less impressive that I hoped:
Benchmark 1:
Benchmark 2:
Benchmark 3: