| 69 | public bool SchemaMismatch { get; init; } |
| 70 | |
| 71 | public static BenchmarkOptions Parse(string[] args) |
| 72 | { |
| 73 | HashSet<string> dataFilter = new(StringComparer.OrdinalIgnoreCase); |
| 74 | HashSet<string> serializerFilter = new(StringComparer.OrdinalIgnoreCase); |
| 75 | double warmupSeconds = 1.0; |
| 76 | double durationSeconds = 3.0; |
| 77 | string outputPath = "benchmark_results.json"; |
| 78 | bool showHelp = false; |
| 79 | bool schemaMismatch = Environment.GetEnvironmentVariable(SchemaMismatchEnv) == "1"; |
| 80 | |
| 81 | for (int i = 0; i < args.Length; i++) |
| 82 | { |
| 83 | switch (args[i]) |
| 84 | { |
| 85 | case "--help": |
| 86 | case "-h": |
| 87 | showHelp = true; |
| 88 | break; |
| 89 | case "--data": |
| 90 | RequireValue(args, i); |
| 91 | dataFilter.Add(args[++i]); |
| 92 | break; |
| 93 | case "--serializer": |
| 94 | RequireValue(args, i); |
| 95 | serializerFilter.Add(args[++i]); |
| 96 | break; |
| 97 | case "--warmup": |
| 98 | RequireValue(args, i); |
| 99 | warmupSeconds = ParsePositiveDouble(args[++i], "warmup"); |
| 100 | break; |
| 101 | case "--duration": |
| 102 | RequireValue(args, i); |
| 103 | durationSeconds = ParsePositiveDouble(args[++i], "duration"); |
| 104 | break; |
| 105 | case "--output": |
| 106 | RequireValue(args, i); |
| 107 | outputPath = args[++i]; |
| 108 | break; |
| 109 | default: |
| 110 | throw new ArgumentException($"unknown option: {args[i]}"); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | return new BenchmarkOptions |
| 115 | { |
| 116 | DataFilter = dataFilter, |
| 117 | SerializerFilter = serializerFilter, |
| 118 | WarmupSeconds = warmupSeconds, |
| 119 | DurationSeconds = durationSeconds, |
| 120 | OutputPath = outputPath, |
| 121 | ShowHelp = showHelp, |
| 122 | SchemaMismatch = schemaMismatch, |
| 123 | }; |
| 124 | } |
| 125 | |
| 126 | public bool IsDataEnabled(string dataType) |
| 127 | { |