Skip to content

Commit 43458b8

Browse files
authored
remove compressing again to get size in compress benchmark (#2097)
we already have the compressed sizes from the bench function, no need to compress again to get them later on
1 parent 07b37e4 commit 43458b8

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

bench-vortex/benches/compress.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,6 @@ fn parquet_decompress_read(buf: bytes::Bytes) -> usize {
103103
nbytes
104104
}
105105

106-
fn parquet_compressed_written_size(array: &ArrayData, compression: Compression) -> usize {
107-
let chunked = ChunkedArray::maybe_from(array).unwrap();
108-
let (batches, schema) = chunked_to_vec_record_batch(chunked);
109-
parquet_compress_write(batches, schema, compression, &mut Vec::new())
110-
}
111-
112106
#[inline(never)]
113107
fn vortex_compress_write(
114108
runtime: &Runtime,
@@ -197,6 +191,8 @@ fn benchmark_compress<F, U>(
197191
group.finish();
198192
}
199193

194+
let mut parquet_compressed_size = 0;
195+
200196
{
201197
let mut group = c.benchmark_group("parquet_rs-zstd compress time");
202198
group.sample_size(sample_size);
@@ -208,7 +204,7 @@ fn benchmark_compress<F, U>(
208204
let (batches, schema) = chunked_to_vec_record_batch(chunked);
209205

210206
b.iter_with_large_drop(|| {
211-
black_box(parquet_compress_write(
207+
parquet_compressed_size = black_box(parquet_compress_write(
212208
batches.clone(),
213209
schema.clone(),
214210
Compression::ZSTD(ZstdLevel::default()),
@@ -271,19 +267,11 @@ fn benchmark_compress<F, U>(
271267
.map(|x| Regex::new(&x).unwrap().is_match(bench_name))
272268
.unwrap_or(false)
273269
{
274-
let vortex_nbytes =
275-
vortex_compressed_written_size(runtime, compressor, uncompressed.as_ref()).unwrap();
276-
277-
let parquet_zstd_nbytes = parquet_compressed_written_size(
278-
uncompressed.as_ref(),
279-
Compression::ZSTD(ZstdLevel::default()),
280-
);
281-
282270
eprintln!(
283271
"{}",
284272
serde_json::to_string(&GenericBenchmarkResults {
285273
name: &format!("vortex:parquet-zstd size/{}", bench_name),
286-
value: (vortex_nbytes as f64) / (parquet_zstd_nbytes as f64),
274+
value: (compressed_size as f64) / (parquet_compressed_size as f64),
287275
unit: "ratio",
288276
range: 0.0,
289277
})

0 commit comments

Comments
 (0)