diff options
Diffstat (limited to 'src/bin/obnam-benchmark.rs')
-rw-r--r-- | src/bin/obnam-benchmark.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/bin/obnam-benchmark.rs b/src/bin/obnam-benchmark.rs index 85ef3f9..1a26ae0 100644 --- a/src/bin/obnam-benchmark.rs +++ b/src/bin/obnam-benchmark.rs @@ -1,4 +1,5 @@ use log::{debug, error, info}; +use obnam_benchmark::junk::junk; use obnam_benchmark::result::Result; use obnam_benchmark::specification::Specification; use obnam_benchmark::suite::Suite; @@ -24,6 +25,7 @@ fn real_main() -> anyhow::Result<()> { debug!("parsed: {:#?}", opt); match opt.cmd { + Command::GenerateJunk(x) => x.run()?, Command::Run(x) => x.run()?, Command::Spec(x) => x.run()?, } @@ -44,6 +46,9 @@ enum Command { /// Dump the specification as JSON Spec(Spec), + + /// Generate some junk data in a file. + GenerateJunk(GenerateJunk), } #[derive(Debug, StructOpt)] @@ -98,3 +103,27 @@ impl Spec { Ok(()) } } + +#[derive(Debug, StructOpt)] +struct GenerateJunk { + /// Number of bytes of junk to create + #[structopt()] + bytes: u64, + + /// Name of the output file + #[structopt(parse(from_os_str))] + filename: PathBuf, +} + +impl GenerateJunk { + fn run(&self) -> anyhow::Result<()> { + info!( + "generating {} bytes of junk into {}", + self.bytes, + self.filename.display() + ); + let mut output = File::create(&self.filename)?; + junk(&mut output, self.bytes)?; + Ok(()) + } +} |