| 50 | |
| 51 | impl Config { |
| 52 | fn parse() -> Result<Self> { |
| 53 | let mut config = Self { |
| 54 | output: "materialize-bench.json".into(), |
| 55 | files: 24, |
| 56 | lines: 128, |
| 57 | edits: 24, |
| 58 | iterations: 5, |
| 59 | warmups: 1, |
| 60 | allow_debug: false, |
| 61 | keep_fixtures: false, |
| 62 | }; |
| 63 | let mut args = std::env::args().skip(1); |
| 64 | while let Some(arg) = args.next() { |
| 65 | match arg.as_str() { |
| 66 | "--allow-debug" => config.allow_debug = true, |
| 67 | "--keep-fixtures" => config.keep_fixtures = true, |
| 68 | "--output" => config.output = args.next().context("--output needs a path")?.into(), |
| 69 | "--files" => { |
| 70 | config.files = args.next().context("--files needs a value")?.parse()? |
| 71 | } |
| 72 | "--lines" => { |
| 73 | config.lines = args.next().context("--lines needs a value")?.parse()? |
| 74 | } |
| 75 | "--edits" => { |
| 76 | config.edits = args.next().context("--edits needs a value")?.parse()? |
| 77 | } |
| 78 | "--iterations" => { |
| 79 | config.iterations = |
| 80 | args.next().context("--iterations needs a value")?.parse()? |
| 81 | } |
| 82 | "--warmups" => { |
| 83 | config.warmups = args.next().context("--warmups needs a value")?.parse()? |
| 84 | } |
| 85 | _ => bail!("unknown argument: {arg}"), |
| 86 | } |
| 87 | } |
| 88 | config.validate()?; |
| 89 | Ok(config) |
| 90 | } |
| 91 | |
| 92 | fn validate(&self) -> Result<()> { |
| 93 | ensure!( |