From ccd30400b0c39a8af1b04f300e3b15887ee9c086 Mon Sep 17 00:00:00 2001 From: joncrall Date: Wed, 20 Apr 2022 11:37:36 -0400 Subject: [PATCH 1/7] Generalize the way new json modules can be added to existing benchmarks --- tests/benchmark.py | 223 ++++++++++++++++++++++++++++----------------- 1 file changed, 139 insertions(+), 84 deletions(-) diff --git a/tests/benchmark.py b/tests/benchmark.py index c0f494d6..df5496db 100644 --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -1,11 +1,13 @@ # coding=UTF-8 +import cpuinfo import json import os import platform import random import sys import timeit +from collections import defaultdict import ujson @@ -33,6 +35,20 @@ benchmark_results = [] +benchmark_registry = defaultdict(dict) + + +# ============================================================================= +# Benchmark registration +# ============================================================================= + +def register_benchmark(libname, testname): + def _wrap(func): + benchmark_registry[testname][libname] = func + return func + return _wrap + + # ============================================================================= # Logging benchmarking results. # ============================================================================= @@ -63,14 +79,14 @@ def results_record_result(callback, is_encode, count): ) -def results_output_table(): - LIBRARIES = ("ujson", "nujson", "orjson", "simplejson", "json") - +def results_output_table(libraries): uname_system, _, uname_release, uname_version, _, uname_processor = platform.uname() + cpu_brand = cpuinfo.get_cpu_info()['brand_raw'] print() print("### Test machine") print() print(uname_system, uname_release, uname_processor, uname_version) + print(cpu_brand) print() print("### Versions") print() @@ -79,19 +95,17 @@ def results_output_table(): platform.python_implementation(), sys.version.replace("\n", "") ) ) - if not skip_lib_comparisons: - print(f"- nujson : {nujson.__version__}") - print(f"- orjson : {orjson.__version__}") - print(f"- simplejson: {simplejson.__version__}") - print(f"- ujson : {ujson.__version__}") + for libname in libraries: + module = globals()[libname] + print(f"- {libname:<12} : {module.__version__}") print() column_widths = [max(len(r[0]) for r in benchmark_results)] - for library in LIBRARIES: + for library in libraries: column_widths.append(max(10, len(library))) columns = [" " * (width + 2) for width in column_widths] - for i, library in enumerate(LIBRARIES): + for i, library in enumerate(libraries): columns[i + 1] = (" " + library).ljust(column_widths[i + 1] + 2) print("|{}|".format("|".join(columns))) @@ -111,7 +125,7 @@ def results_output_table(): columns = [None] * len(column_widths) columns[0] = " encode".ljust(column_widths[0] + 2) - for i, library in enumerate(LIBRARIES): + for i, library in enumerate(libraries): if library in encodes: columns[i + 1] = f"{encodes[library]:,.0f} ".rjust( column_widths[i + 1] + 2 @@ -123,7 +137,7 @@ def results_output_table(): if decodes: columns = [None] * len(column_widths) columns[0] = " decode".ljust(column_widths[0] + 2) - for i, library in enumerate(LIBRARIES): + for i, library in enumerate(libraries): if library in decodes: columns[i + 1] = f"{decodes[library]:,.0f} ".rjust( column_widths[i + 1] + 2 @@ -136,22 +150,31 @@ def results_output_table(): # ============================================================================= # JSON encoding. # ============================================================================= + +_testname = 'dumps' + + +@register_benchmark('json', _testname) def dumps_with_json(): json.dumps(test_object) +@register_benchmark('nujson', _testname) def dumps_with_nujson(): nujson.dumps(test_object) +@register_benchmark('orjson', _testname) def dumps_with_orjson(): orjson.dumps(test_object) +@register_benchmark('simplejson', _testname) def dumps_with_simplejson(): simplejson.dumps(test_object) +@register_benchmark('ujson', _testname) def dumps_with_ujson(): ujson.dumps(test_object, ensure_ascii=False) @@ -159,22 +182,31 @@ def dumps_with_ujson(): # ============================================================================= # JSON encoding with sort_keys=True. # ============================================================================= + +_testname = 'dumps-sort_keys=True' + + +@register_benchmark('json', _testname) def dumps_sorted_with_json(): json.dumps(test_object, sort_keys=True) +@register_benchmark('simplejson', _testname) def dumps_sorted_with_simplejson(): simplejson.dumps(test_object, sort_keys=True) +@register_benchmark('nujson', _testname) def dumps_sorted_with_nujson(): nujson.dumps(test_object, sort_keys=True) +@register_benchmark('orjson', _testname) def dumps_sorted_with_orjson(): orjson.dumps(test_object, sort_keys=True) +@register_benchmark('ujson', _testname) def dumps_sorted_with_ujson(): ujson.dumps(test_object, ensure_ascii=False, sort_keys=True) @@ -182,22 +214,31 @@ def dumps_sorted_with_ujson(): # ============================================================================= # JSON decoding. # ============================================================================= + +_testname = 'loads' + + +@register_benchmark('json', _testname) def loads_with_json(): json.loads(decode_data) +@register_benchmark('nujson', _testname) def loads_with_nujson(): nujson.loads(decode_data) +@register_benchmark('orjson', _testname) def loads_with_orjson(): orjson.loads(decode_data) +@register_benchmark('simplejson', _testname) def loads_with_simplejson(): simplejson.loads(decode_data) +@register_benchmark('ujson', _testname) def loads_with_ujson(): ujson.loads(decode_data) @@ -205,54 +246,48 @@ def loads_with_ujson(): # ============================================================================= # Benchmarks. # ============================================================================= -def run_decode(count): - results_record_result(loads_with_ujson, False, count) - if not skip_lib_comparisons: - results_record_result(loads_with_simplejson, False, count) - results_record_result(loads_with_nujson, False, count) - results_record_result(loads_with_orjson, False, count) - results_record_result(loads_with_json, False, count) - - -def run_encode(count): - results_record_result(dumps_with_ujson, True, count) - if not skip_lib_comparisons: - results_record_result(dumps_with_simplejson, True, count) - results_record_result(dumps_with_nujson, True, count) - results_record_result(dumps_with_orjson, True, count) - results_record_result(dumps_with_json, True, count) - - -def run_encode_sort_keys(count): - results_record_result(dumps_sorted_with_ujson, True, count) - if not skip_lib_comparisons: - results_record_result(dumps_sorted_with_simplejson, True, count) - results_record_result(dumps_sorted_with_nujson, True, count) - results_record_result(dumps_sorted_with_orjson, True, count) - results_record_result(dumps_sorted_with_json, True, count) - - -def benchmark_array_doubles(): +def run_decode(count, libraries): + _testname = 'loads' + for libname in libraries: + func = benchmark_registry[_testname][libname] + results_record_result(func, False, count) + + +def run_encode(count, libraries): + _testname = 'dumps' + for libname in libraries: + func = benchmark_registry[_testname][libname] + results_record_result(func, True, count) + + +def run_encode_sort_keys(count, libraries): + _testname = 'dumps-sort_keys=True' + for libname in libraries: + func = benchmark_registry[_testname][libname] + results_record_result(func, True, count) + + +def benchmark_array_doubles(libraries, factor=1): global decode_data, test_object results_new_benchmark("Array with 256 doubles") - COUNT = 10000 + COUNT = max(int(10000 * factor), 1) test_object = [] for x in range(256): test_object.append(sys.maxsize * random.random()) - run_encode(COUNT) + run_encode(COUNT, libraries) decode_data = json.dumps(test_object) test_object = None - run_decode(COUNT) + run_decode(COUNT, libraries) decode_data = None -def benchmark_array_utf8_strings(): +def benchmark_array_utf8_strings(libraries, factor=1): global decode_data, test_object results_new_benchmark("Array with 256 UTF-8 strings") - COUNT = 2000 + COUNT = max(int(2000 * factor), 1) test_object = [] for x in range(256): @@ -261,36 +296,36 @@ def benchmark_array_utf8_strings(): "في الذكور من ذرية السيد تركي بن سعيد بن سلطان ويشترط فيمن يختار لولاية" " الحكم من بينهم ان يكون مسلما رشيدا عاقلا ًوابنا شرعيا لابوين عمانيين " ) - run_encode(COUNT) + run_encode(COUNT, libraries) decode_data = json.dumps(test_object) test_object = None - run_decode(COUNT) + run_decode(COUNT, libraries) decode_data = None -def benchmark_array_byte_strings(): +def benchmark_array_byte_strings(libraries, factor=1): global decode_data, test_object results_new_benchmark("Array with 256 strings") - COUNT = 10000 + COUNT = max(int(10000 * factor), 1) test_object = [] for x in range(256): test_object.append("A pretty long string which is in a list") - run_encode(COUNT) + run_encode(COUNT, libraries) decode_data = json.dumps(test_object) test_object = None - run_decode(COUNT) + run_decode(COUNT, libraries) decode_data = None -def benchmark_medium_complex_object(): +def benchmark_medium_complex_object(libraries, factor=1): global decode_data, test_object results_new_benchmark("Medium complex object") - COUNT = 5000 + COUNT = max(int(5000 * factor), 1) test_object = [ [USER, FRIENDS], @@ -300,53 +335,53 @@ def benchmark_medium_complex_object(): [USER, FRIENDS], [USER, FRIENDS], ] - run_encode(COUNT) + run_encode(COUNT, libraries) decode_data = json.dumps(test_object) test_object = None - run_decode(COUNT) + run_decode(COUNT, libraries) decode_data = None -def benchmark_array_true_values(): +def benchmark_array_true_values(libraries, factor=1): global decode_data, test_object results_new_benchmark("Array with 256 True values") - COUNT = 50000 + COUNT = max(int(50000 * factor), 1) test_object = [] for x in range(256): test_object.append(True) - run_encode(COUNT) + run_encode(COUNT, libraries) decode_data = json.dumps(test_object) test_object = None - run_decode(COUNT) + run_decode(COUNT, libraries) decode_data = None -def benchmark_array_of_dict_string_int_pairs(): +def benchmark_array_of_dict_string_int_pairs(libraries, factor=1): global decode_data, test_object results_new_benchmark("Array with 256 dict{string, int} pairs") - COUNT = 5000 + COUNT = max(int(5000 * factor), 1) test_object = [] for x in range(256): test_object.append({str(random.random() * 20): int(random.random() * 1000000)}) - run_encode(COUNT) + run_encode(COUNT, libraries) decode_data = json.dumps(test_object) test_object = None - run_decode(COUNT) + run_decode(COUNT, libraries) decode_data = None -def benchmark_dict_of_arrays_of_dict_string_int_pairs(): +def benchmark_dict_of_arrays_of_dict_string_int_pairs(libraries, factor=1): global decode_data, test_object results_new_benchmark("Dict with 256 arrays with 256 dict{string, int} pairs") - COUNT = 50 + COUNT = max(int(50 * factor), 1) test_object = {} for y in range(256): @@ -354,33 +389,33 @@ def benchmark_dict_of_arrays_of_dict_string_int_pairs(): for x in range(256): arrays.append({str(random.random() * 20): int(random.random() * 1000000)}) test_object[str(random.random() * 20)] = arrays - run_encode(COUNT) + run_encode(COUNT, libraries) decode_data = json.dumps(test_object) - run_decode(COUNT) + run_decode(COUNT, libraries) decode_data = None results_new_benchmark( "Dict with 256 arrays with 256 dict{string, int} pairs, outputting sorted keys" ) - run_encode_sort_keys(COUNT) + run_encode_sort_keys(COUNT, libraries) test_object = None -def benchmark_complex_object(): +def benchmark_complex_object(libraries, factor=1): global decode_data, test_object results_new_benchmark("Complex object") - COUNT = 100 + COUNT = int(100 * factor) with open(os.path.join(os.path.dirname(__file__), "sample.json")) as f: test_object = json.load(f) - run_encode(COUNT) + run_encode(COUNT, libraries) decode_data = json.dumps(test_object) test_object = None - run_decode(COUNT) + run_decode(COUNT, libraries) decode_data = None @@ -388,16 +423,36 @@ def benchmark_complex_object(): # ============================================================================= # Main. # ============================================================================= -if __name__ == "__main__": + +def main(): if len(sys.argv) > 1 and "skip-lib-comps" in sys.argv: - skip_lib_comparisons = True - - benchmark_array_doubles() - benchmark_array_utf8_strings() - benchmark_array_byte_strings() - benchmark_medium_complex_object() - benchmark_array_true_values() - benchmark_array_of_dict_string_int_pairs() - benchmark_dict_of_arrays_of_dict_string_int_pairs() - benchmark_complex_object() - results_output_table() + # skip_lib_comparisons = True + libraries = ( + "ujson", + ) + else: + libraries = ( + "ujson", + "nujson", + "orjson", + "simplejson", + "json" + ) + + # Set to a fraction to speed up benchmarks for development / testing + factor = 1.0 + + benchmark_array_doubles(libraries, factor) + benchmark_array_utf8_strings(libraries, factor) + benchmark_array_byte_strings(libraries, factor) + benchmark_medium_complex_object(libraries, factor) + benchmark_array_true_values(libraries, factor) + benchmark_array_of_dict_string_int_pairs(libraries, factor) + benchmark_dict_of_arrays_of_dict_string_int_pairs(libraries, factor) + benchmark_complex_object(libraries, factor) + + results_output_table(libraries) + + +if __name__ == "__main__": + main() From 32de298ee7da52cd9df7b5ea21f922087223c21c Mon Sep 17 00:00:00 2001 From: joncrall Date: Thu, 21 Apr 2022 16:39:34 -0400 Subject: [PATCH 2/7] Added argparse CLI with ability to disable specific modules --- tests/benchmark.py | 75 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/tests/benchmark.py b/tests/benchmark.py index df5496db..ae910097 100644 --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -1,5 +1,4 @@ # coding=UTF-8 - import cpuinfo import json import os @@ -8,9 +7,13 @@ import sys import timeit from collections import defaultdict - import ujson +# Will be set by "main" if user requests them +simplejson = None +nujson = None +orjson = None + USER = { "userId": 3381293, "age": 213, @@ -26,11 +29,6 @@ decode_data = None test_object = None -skip_lib_comparisons = False -if not skip_lib_comparisons: - import nujson - import orjson - import simplejson benchmark_results = [] @@ -425,23 +423,56 @@ def benchmark_complex_object(libraries, factor=1): # ============================================================================= def main(): - if len(sys.argv) > 1 and "skip-lib-comps" in sys.argv: - # skip_lib_comparisons = True - libraries = ( - "ujson", - ) - else: - libraries = ( - "ujson", - "nujson", - "orjson", - "simplejson", - "json" - ) + import argparse + import importlib + parser = argparse.ArgumentParser( + prog='ujson-benchmarks', + description='Benchmark ujson against other json implementations') + + known_libraries = [ + 'ujson', + 'nujson', + 'orjson', + 'simplejson', + 'json', + ] + + parser.add_argument('--disable', nargs='+', choices=known_libraries, help=( + 'Remove specified libraries from the benchmarks') + ) + + parser.add_argument('--factor', type=float, default=1.0, help=( + 'Specify as a fraction speed up benchmarks for development / testing' + )) + + parser.add_argument('command', nargs='?', help=( + 'Exists for backwards compatibility. ' + 'Can be "skip-lib-comps" to disable computing benchmarks ' + 'for other json libraries.'), default=None) + + args = parser.parse_args() + + if args.command == "skip-lib-comps": + args.disable.extend(known_libraries[1:]) + + disabled_libraires = set(args.disable) + enabled_libraries = {} + for libname in known_libraries: + if libname not in disabled_libraires: + try: + module = importlib.import_module(libname) + except ImportError: + raise ImportError(f'{libname} is not available') + else: + enabled_libraries[libname] = module - # Set to a fraction to speed up benchmarks for development / testing - factor = 1.0 + # Ensure the modules are avilable in a the global scope + for libname, module in enabled_libraries.items(): + print(f'Enabled {libname} benchmarks') + globals()[libname] = module + libraries = list(enabled_libraries.keys()) + factor = args.factor benchmark_array_doubles(libraries, factor) benchmark_array_utf8_strings(libraries, factor) benchmark_array_byte_strings(libraries, factor) From 78f24e290e3bbb4e318ef1d652eae6f70c564274 Mon Sep 17 00:00:00 2001 From: joncrall Date: Thu, 21 Apr 2022 16:57:05 -0400 Subject: [PATCH 3/7] Add note about units of benchmarks --- tests/benchmark.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/benchmark.py b/tests/benchmark.py index ae910097..8f30df0a 100644 --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -144,6 +144,9 @@ def results_output_table(libraries): columns[i + 1] = " " * (column_widths[i + 1] + 2) print("|{}|".format("|".join(columns))) + print() + print('Above metrics are in call/sec, larger is better.') + # ============================================================================= # JSON encoding. From 79a6122e5fae8fdee6eee197d0d479d92d9d2550 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 21 Apr 2022 20:59:31 +0000 Subject: [PATCH 4/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/benchmark.py | 100 ++++++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 41 deletions(-) diff --git a/tests/benchmark.py b/tests/benchmark.py index ae910097..7a55363e 100644 --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -1,5 +1,4 @@ # coding=UTF-8 -import cpuinfo import json import os import platform @@ -7,6 +6,8 @@ import sys import timeit from collections import defaultdict + +import cpuinfo import ujson # Will be set by "main" if user requests them @@ -40,10 +41,12 @@ # Benchmark registration # ============================================================================= + def register_benchmark(libname, testname): def _wrap(func): benchmark_registry[testname][libname] = func return func + return _wrap @@ -79,7 +82,7 @@ def results_record_result(callback, is_encode, count): def results_output_table(libraries): uname_system, _, uname_release, uname_version, _, uname_processor = platform.uname() - cpu_brand = cpuinfo.get_cpu_info()['brand_raw'] + cpu_brand = cpuinfo.get_cpu_info()["brand_raw"] print() print("### Test machine") print() @@ -149,30 +152,30 @@ def results_output_table(libraries): # JSON encoding. # ============================================================================= -_testname = 'dumps' +_testname = "dumps" -@register_benchmark('json', _testname) +@register_benchmark("json", _testname) def dumps_with_json(): json.dumps(test_object) -@register_benchmark('nujson', _testname) +@register_benchmark("nujson", _testname) def dumps_with_nujson(): nujson.dumps(test_object) -@register_benchmark('orjson', _testname) +@register_benchmark("orjson", _testname) def dumps_with_orjson(): orjson.dumps(test_object) -@register_benchmark('simplejson', _testname) +@register_benchmark("simplejson", _testname) def dumps_with_simplejson(): simplejson.dumps(test_object) -@register_benchmark('ujson', _testname) +@register_benchmark("ujson", _testname) def dumps_with_ujson(): ujson.dumps(test_object, ensure_ascii=False) @@ -181,30 +184,30 @@ def dumps_with_ujson(): # JSON encoding with sort_keys=True. # ============================================================================= -_testname = 'dumps-sort_keys=True' +_testname = "dumps-sort_keys=True" -@register_benchmark('json', _testname) +@register_benchmark("json", _testname) def dumps_sorted_with_json(): json.dumps(test_object, sort_keys=True) -@register_benchmark('simplejson', _testname) +@register_benchmark("simplejson", _testname) def dumps_sorted_with_simplejson(): simplejson.dumps(test_object, sort_keys=True) -@register_benchmark('nujson', _testname) +@register_benchmark("nujson", _testname) def dumps_sorted_with_nujson(): nujson.dumps(test_object, sort_keys=True) -@register_benchmark('orjson', _testname) +@register_benchmark("orjson", _testname) def dumps_sorted_with_orjson(): orjson.dumps(test_object, sort_keys=True) -@register_benchmark('ujson', _testname) +@register_benchmark("ujson", _testname) def dumps_sorted_with_ujson(): ujson.dumps(test_object, ensure_ascii=False, sort_keys=True) @@ -213,30 +216,30 @@ def dumps_sorted_with_ujson(): # JSON decoding. # ============================================================================= -_testname = 'loads' +_testname = "loads" -@register_benchmark('json', _testname) +@register_benchmark("json", _testname) def loads_with_json(): json.loads(decode_data) -@register_benchmark('nujson', _testname) +@register_benchmark("nujson", _testname) def loads_with_nujson(): nujson.loads(decode_data) -@register_benchmark('orjson', _testname) +@register_benchmark("orjson", _testname) def loads_with_orjson(): orjson.loads(decode_data) -@register_benchmark('simplejson', _testname) +@register_benchmark("simplejson", _testname) def loads_with_simplejson(): simplejson.loads(decode_data) -@register_benchmark('ujson', _testname) +@register_benchmark("ujson", _testname) def loads_with_ujson(): ujson.loads(decode_data) @@ -245,21 +248,21 @@ def loads_with_ujson(): # Benchmarks. # ============================================================================= def run_decode(count, libraries): - _testname = 'loads' + _testname = "loads" for libname in libraries: func = benchmark_registry[_testname][libname] results_record_result(func, False, count) def run_encode(count, libraries): - _testname = 'dumps' + _testname = "dumps" for libname in libraries: func = benchmark_registry[_testname][libname] results_record_result(func, True, count) def run_encode_sort_keys(count, libraries): - _testname = 'dumps-sort_keys=True' + _testname = "dumps-sort_keys=True" for libname in libraries: func = benchmark_registry[_testname][libname] results_record_result(func, True, count) @@ -422,33 +425,48 @@ def benchmark_complex_object(libraries, factor=1): # Main. # ============================================================================= + def main(): import argparse import importlib + parser = argparse.ArgumentParser( - prog='ujson-benchmarks', - description='Benchmark ujson against other json implementations') + prog="ujson-benchmarks", + description="Benchmark ujson against other json implementations", + ) known_libraries = [ - 'ujson', - 'nujson', - 'orjson', - 'simplejson', - 'json', + "ujson", + "nujson", + "orjson", + "simplejson", + "json", ] - parser.add_argument('--disable', nargs='+', choices=known_libraries, help=( - 'Remove specified libraries from the benchmarks') + parser.add_argument( + "--disable", + nargs="+", + choices=known_libraries, + help=("Remove specified libraries from the benchmarks"), ) - parser.add_argument('--factor', type=float, default=1.0, help=( - 'Specify as a fraction speed up benchmarks for development / testing' - )) + parser.add_argument( + "--factor", + type=float, + default=1.0, + help=("Specify as a fraction speed up benchmarks for development / testing"), + ) - parser.add_argument('command', nargs='?', help=( - 'Exists for backwards compatibility. ' - 'Can be "skip-lib-comps" to disable computing benchmarks ' - 'for other json libraries.'), default=None) + parser.add_argument( + "command", + nargs="?", + help=( + "Exists for backwards compatibility. " + 'Can be "skip-lib-comps" to disable computing benchmarks ' + "for other json libraries." + ), + default=None, + ) args = parser.parse_args() @@ -462,13 +480,13 @@ def main(): try: module = importlib.import_module(libname) except ImportError: - raise ImportError(f'{libname} is not available') + raise ImportError(f"{libname} is not available") else: enabled_libraries[libname] = module # Ensure the modules are avilable in a the global scope for libname, module in enabled_libraries.items(): - print(f'Enabled {libname} benchmarks') + print(f"Enabled {libname} benchmarks") globals()[libname] = module libraries = list(enabled_libraries.keys()) From 3eb7a19f603fa5f78ce036be868d32b00139f840 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 21 Apr 2022 21:13:27 +0000 Subject: [PATCH 5/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/benchmark.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/benchmark.py b/tests/benchmark.py index a8e7822b..5d29b04d 100644 --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -148,7 +148,7 @@ def results_output_table(libraries): print("|{}|".format("|".join(columns))) print() - print('Above metrics are in call/sec, larger is better.') + print("Above metrics are in call/sec, larger is better.") # ============================================================================= From 3850b93182f29a81cca209e1f515302fbd02087c Mon Sep 17 00:00:00 2001 From: joncrall Date: Thu, 21 Apr 2022 17:33:29 -0400 Subject: [PATCH 6/7] Remove cpuinfo --- tests/benchmark.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/benchmark.py b/tests/benchmark.py index a8e7822b..0398e4d2 100644 --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -7,7 +7,6 @@ import timeit from collections import defaultdict -import cpuinfo import ujson # Will be set by "main" if user requests them @@ -82,12 +81,10 @@ def results_record_result(callback, is_encode, count): def results_output_table(libraries): uname_system, _, uname_release, uname_version, _, uname_processor = platform.uname() - cpu_brand = cpuinfo.get_cpu_info()["brand_raw"] print() print("### Test machine") print() print(uname_system, uname_release, uname_processor, uname_version) - print(cpu_brand) print() print("### Versions") print() From 3d25fb4fe61fc6cc5501b3d2270b00b569fea6e8 Mon Sep 17 00:00:00 2001 From: joncrall Date: Fri, 22 Apr 2022 18:57:46 -0400 Subject: [PATCH 7/7] remove skip-lib-comps command --- tests/benchmark.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tests/benchmark.py b/tests/benchmark.py index 85b2a41c..8d37b6a3 100644 --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -457,22 +457,8 @@ def main(): help=("Specify as a fraction speed up benchmarks for development / testing"), ) - parser.add_argument( - "command", - nargs="?", - help=( - "Exists for backwards compatibility. " - 'Can be "skip-lib-comps" to disable computing benchmarks ' - "for other json libraries." - ), - default=None, - ) - args = parser.parse_args() - if args.command == "skip-lib-comps": - args.disable.extend(known_libraries[1:]) - disabled_libraires = set(args.disable) enabled_libraries = {} for libname in known_libraries: