From 18dacba7bc42b64c2540139b38839f5cb1ee42ae Mon Sep 17 00:00:00 2001 From: Alex Saveau Date: Tue, 12 Dec 2023 12:25:28 -0800 Subject: [PATCH] Use io-adapters in another place Signed-off-by: Alex Saveau --- benches/generator.rs | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/benches/generator.rs b/benches/generator.rs index a3b85bb..cc791d3 100644 --- a/benches/generator.rs +++ b/benches/generator.rs @@ -1,20 +1,13 @@ -use std::{fmt, num::NonZeroU64, time::Duration}; +use std::{io::sink, num::NonZeroU64, time::Duration}; use criterion::{ criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion, PlotConfiguration, Throughput, }; use ftzz::{Generator, NumFilesWithRatio}; +use io_adapters::WriteExtension; use tempfile::tempdir; -struct Sink; - -impl fmt::Write for Sink { - fn write_str(&mut self, _: &str) -> fmt::Result { - Ok(()) - } -} - fn simple_generate(c: &mut Criterion) { let mut group = c.benchmark_group("simple_generate"); group.plot_config(PlotConfiguration::default().summary_scale(AxisScale::Logarithmic)); @@ -35,7 +28,7 @@ fn simple_generate(c: &mut Criterion) { )) .max_depth(5) .build() - .generate(&mut Sink) + .generate(&mut sink().write_adapter()) .unwrap(); dir @@ -66,7 +59,7 @@ fn huge_generate(c: &mut Criterion) { )) .max_depth(5) .build() - .generate(&mut Sink) + .generate(&mut sink().write_adapter()) .unwrap(); dir @@ -94,7 +87,7 @@ fn deep_generate(c: &mut Criterion) { )) .max_depth(100) .build() - .generate(&mut Sink) + .generate(&mut sink().write_adapter()) .unwrap(); dir @@ -122,7 +115,7 @@ fn shallow_generate(c: &mut Criterion) { )) .max_depth(0) .build() - .generate(&mut Sink) + .generate(&mut sink().write_adapter()) .unwrap(); dir @@ -154,7 +147,7 @@ fn sparse_generate(c: &mut Criterion) { ) .max_depth(5) .build() - .generate(&mut Sink) + .generate(&mut sink().write_adapter()) .unwrap(); dir @@ -186,7 +179,7 @@ fn dense_generate(c: &mut Criterion) { ) .max_depth(5) .build() - .generate(&mut Sink) + .generate(&mut sink().write_adapter()) .unwrap(); dir @@ -215,7 +208,7 @@ fn bytes_generate(c: &mut Criterion) { .max_depth(5) .num_bytes(num_bytes) .build() - .generate(&mut Sink) + .generate(&mut sink().write_adapter()) .unwrap(); dir