()
| 889 | |
| 890 | |
| 891 | def main(): |
| 892 | parser = argparse.ArgumentParser( |
| 893 | description='Benchmark the gunicorn dirty pool', |
| 894 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 895 | epilog=__doc__, |
| 896 | ) |
| 897 | |
| 898 | # Mode selection |
| 899 | mode_group = parser.add_mutually_exclusive_group() |
| 900 | mode_group.add_argument('--quick', action='store_true', |
| 901 | help='Run quick smoke test') |
| 902 | mode_group.add_argument('--isolated', action='store_true', |
| 903 | help='Run isolated benchmark suite') |
| 904 | mode_group.add_argument('--payload-tests', action='store_true', |
| 905 | help='Run payload size tests') |
| 906 | mode_group.add_argument('--config-sweep', action='store_true', |
| 907 | help='Sweep through configurations') |
| 908 | mode_group.add_argument('--integrated', action='store_true', |
| 909 | help='Run integrated HTTP benchmarks') |
| 910 | |
| 911 | # Configuration |
| 912 | parser.add_argument('--workers', type=int, default=2, |
| 913 | help='Number of dirty workers (default: 2)') |
| 914 | parser.add_argument('--threads', type=int, default=1, |
| 915 | help='Threads per dirty worker (default: 1)') |
| 916 | parser.add_argument('--duration', type=int, default=10, |
| 917 | help='Task duration in ms for custom run') |
| 918 | parser.add_argument('--concurrency', type=int, default=10, |
| 919 | help='Number of concurrent clients') |
| 920 | parser.add_argument('--requests', type=int, default=1000, |
| 921 | help='Total requests to make') |
| 922 | |
| 923 | # Integration mode options |
| 924 | parser.add_argument('--url', default='http://127.0.0.1:8000', |
| 925 | help='Server URL for integrated tests') |
| 926 | |
| 927 | # Output |
| 928 | parser.add_argument('--output', '-o', |
| 929 | help='Output JSON file for results') |
| 930 | parser.add_argument('--verbose', '-v', action='store_true', |
| 931 | help='Verbose output') |
| 932 | |
| 933 | args = parser.parse_args() |
| 934 | |
| 935 | results = [] |
| 936 | |
| 937 | try: |
| 938 | if args.quick: |
| 939 | results = run_quick_test(verbose=args.verbose) |
| 940 | elif args.isolated: |
| 941 | results = run_isolated_suite( |
| 942 | workers=args.workers, |
| 943 | threads=args.threads, |
| 944 | verbose=args.verbose, |
| 945 | ) |
| 946 | elif args.payload_tests: |
| 947 | results = run_payload_suite( |
| 948 | workers=args.workers, |
no test coverage detected