Skip to content

Commit

Permalink
Use io-adapters in another place
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
  • Loading branch information
SUPERCILEX committed Dec 12, 2023
1 parent 7c73745 commit 18dacba
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions benches/generator.rs
Original file line number Diff line number Diff line change
@@ -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));
Expand All @@ -35,7 +28,7 @@ fn simple_generate(c: &mut Criterion) {
))
.max_depth(5)
.build()
.generate(&mut Sink)
.generate(&mut sink().write_adapter())
.unwrap();

dir
Expand Down Expand Up @@ -66,7 +59,7 @@ fn huge_generate(c: &mut Criterion) {
))
.max_depth(5)
.build()
.generate(&mut Sink)
.generate(&mut sink().write_adapter())
.unwrap();

dir
Expand Down Expand Up @@ -94,7 +87,7 @@ fn deep_generate(c: &mut Criterion) {
))
.max_depth(100)
.build()
.generate(&mut Sink)
.generate(&mut sink().write_adapter())
.unwrap();

dir
Expand Down Expand Up @@ -122,7 +115,7 @@ fn shallow_generate(c: &mut Criterion) {
))
.max_depth(0)
.build()
.generate(&mut Sink)
.generate(&mut sink().write_adapter())
.unwrap();

dir
Expand Down Expand Up @@ -154,7 +147,7 @@ fn sparse_generate(c: &mut Criterion) {
)
.max_depth(5)
.build()
.generate(&mut Sink)
.generate(&mut sink().write_adapter())
.unwrap();

dir
Expand Down Expand Up @@ -186,7 +179,7 @@ fn dense_generate(c: &mut Criterion) {
)
.max_depth(5)
.build()
.generate(&mut Sink)
.generate(&mut sink().write_adapter())
.unwrap();

dir
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 18dacba

Please sign in to comment.