| 902 | |
| 903 | |
| 904 | def parse_args() -> argparse.Namespace: |
| 905 | parser = argparse.ArgumentParser( |
| 906 | description="Comprehensive Fory/Pickle/Protobuf benchmark for Python" |
| 907 | ) |
| 908 | parser.add_argument( |
| 909 | "--operation", |
| 910 | default="all", |
| 911 | choices=["all", "serialize", "deserialize"], |
| 912 | help="Benchmark operation: all, serialize, deserialize", |
| 913 | ) |
| 914 | parser.add_argument( |
| 915 | "--data", |
| 916 | default="all", |
| 917 | help="Comma-separated data types: struct,sample,mediacontent,structlist,samplelist,mediacontentlist or all", |
| 918 | ) |
| 919 | parser.add_argument( |
| 920 | "--serializer", |
| 921 | default="all", |
| 922 | help="Comma-separated serializers: fory,protobuf,pickle or all", |
| 923 | ) |
| 924 | parser.add_argument( |
| 925 | "--warmup", |
| 926 | type=int, |
| 927 | default=3, |
| 928 | help="Warmup iterations (default: 3)", |
| 929 | ) |
| 930 | parser.add_argument( |
| 931 | "--iterations", |
| 932 | type=int, |
| 933 | default=15, |
| 934 | help="Measurement iterations (default: 15)", |
| 935 | ) |
| 936 | parser.add_argument( |
| 937 | "--repeat", |
| 938 | type=int, |
| 939 | default=5, |
| 940 | help="Timer repeat count per iteration (default: 5)", |
| 941 | ) |
| 942 | parser.add_argument( |
| 943 | "--number", |
| 944 | type=int, |
| 945 | default=1000, |
| 946 | help="Function calls per timer measurement (default: 1000)", |
| 947 | ) |
| 948 | parser.add_argument( |
| 949 | "--proto-dir", |
| 950 | default=str(Path(__file__).with_name("proto")), |
| 951 | help="Directory containing generated bench_pb2.py", |
| 952 | ) |
| 953 | parser.add_argument( |
| 954 | "--output-json", |
| 955 | default=str(Path(__file__).with_name("results") / "benchmark_results.json"), |
| 956 | help="Output JSON file path", |
| 957 | ) |
| 958 | return parser.parse_args() |
| 959 | |
| 960 | |
| 961 | def main() -> int: |