| 823 | } |
| 824 | |
| 825 | cli_options parse_cli(int argc, char* argv[], pdflib::decode_config& decode_config) |
| 826 | { |
| 827 | cxxopts::Options options("run_scaling", "Thread-scaling benchmark for docling-parse C++"); |
| 828 | options.add_options() |
| 829 | ("input", "Local PDF file or directory", cxxopts::value<std::string>()) |
| 830 | ("mode", "Benchmark stage: parse, render, or both", cxxopts::value<std::string>()->default_value("render")) |
| 831 | ("recursive,r", "Recurse into subdirectories", cxxopts::value<bool>()->default_value("false")->implicit_value("true")) |
| 832 | ("max-pages,l", "Maximum number of pages to process across all input PDFs", cxxopts::value<int>()) |
| 833 | ("max-concurrent-results", "Max buffered results for threaded processing", cxxopts::value<int>()->default_value("64")) |
| 834 | ("threads", "Comma-separated thread counts", cxxopts::value<std::string>()->default_value("1,2,4,8,12,16")) |
| 835 | ("scale", "Render scale for render mode", cxxopts::value<float>()->default_value("1.0")) |
| 836 | ("enable-timing", "Write one CSV timing row per page result", cxxopts::value<bool>()->default_value("false")->implicit_value("true")) |
| 837 | ("timing-csv", "CSV path used when --enable-timing is set", cxxopts::value<std::string>()->default_value("timing-cpp.csv")) |
| 838 | ("loglevel", "Log level [fatal, error, warning, info]", cxxopts::value<std::string>()->default_value("fatal")) |
| 839 | ("page-boundary", "Page boundary [crop_box, media_box]", cxxopts::value<std::string>()) |
| 840 | ("do-sanitization", "Run post-parse sanitization", cxxopts::value<std::string>()) |
| 841 | ("keep-char-cells", "Keep individual character cells", cxxopts::value<std::string>()) |
| 842 | ("keep-shapes", "Keep shape items", cxxopts::value<std::string>()) |
| 843 | ("keep-bitmaps", "Keep bitmap items", cxxopts::value<std::string>()) |
| 844 | ("max-num-lines", "Cap on number of lines per page", cxxopts::value<int>()) |
| 845 | ("max-num-bitmaps", "Cap on number of bitmaps per page", cxxopts::value<int>()) |
| 846 | ("create-word-cells", "Build word-level cells", cxxopts::value<std::string>()) |
| 847 | ("create-line-cells", "Build line-level cells", cxxopts::value<std::string>()) |
| 848 | ("enforce-same-font", "Require same font within a word/line cell", cxxopts::value<std::string>()) |
| 849 | ("horizontal-cell-tolerance", "Horizontal merge tolerance", cxxopts::value<double>()) |
| 850 | ("word-space-factor", "Space-width factor for word merging", cxxopts::value<double>()) |
| 851 | ("line-space-factor", "Space-width factor for line merging", cxxopts::value<double>()) |
| 852 | ("line-space-factor-with-space", "Space-width factor for line merging with space", cxxopts::value<double>()) |
| 853 | ("keep-glyphs", "Keep unmapped GLYPH<...> tokens", cxxopts::value<std::string>()) |
| 854 | ("keep-qpdf-warnings", "Emit QPDF warnings", cxxopts::value<std::string>()) |
| 855 | ("h,help", "Print usage"); |
| 856 | |
| 857 | options.parse_positional({"input"}); |
| 858 | options.positional_help("input"); |
| 859 | |
| 860 | auto result = options.parse(argc, argv); |
| 861 | if(result.count("help") or not result.count("input")) |
| 862 | { |
| 863 | std::cout << options.help() << "\n"; |
| 864 | std::exit(result.count("help") ? 0 : 1); |
| 865 | } |
| 866 | |
| 867 | cli_options cli; |
| 868 | cli.input = result["input"].as<std::string>(); |
| 869 | cli.recursive = result["recursive"].as<bool>(); |
| 870 | cli.max_concurrent_results = result["max-concurrent-results"].as<int>(); |
| 871 | if(cli.max_concurrent_results <= 0) |
| 872 | { |
| 873 | throw std::runtime_error("--max-concurrent-results must be positive"); |
| 874 | } |
| 875 | cli.threads = parse_thread_counts(result["threads"].as<std::string>()); |
| 876 | cli.scale = result["scale"].as<float>(); |
| 877 | cli.enable_timing = result["enable-timing"].as<bool>(); |
| 878 | cli.timing_csv = result["timing-csv"].as<std::string>(); |
| 879 | cli.loglevel = result["loglevel"].as<std::string>(); |
| 880 | |
| 881 | if(result.count("max-pages")) |
| 882 | { |
no test coverage detected