From 80951bb36b52e875a893e75cf756e23fa7734e6b Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Tue, 26 Dec 2023 15:34:32 +0800 Subject: [PATCH] Init a temp DATA_DIR for bench-test --- benches/benches/benchmarks/resolve.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/benches/benches/benchmarks/resolve.rs b/benches/benches/benchmarks/resolve.rs index ebc278351b..29ce56bc8c 100644 --- a/benches/benches/benchmarks/resolve.rs +++ b/benches/benches/benchmarks/resolve.rs @@ -5,6 +5,7 @@ use ckb_chain_spec::{ChainSpec, IssuedCell}; use ckb_jsonrpc_types::JsonBytes; use ckb_resource::Resource; use ckb_shared::{Shared, SharedBuilder, Snapshot}; +use ckb_types::global::DATA_DIR; use ckb_types::{ bytes::Bytes, core::{ @@ -123,6 +124,11 @@ pub fn gen_txs_from_genesis(block: &BlockView) -> Vec { fn bench(c: &mut Criterion) { let mut group = c.benchmark_group("resolve"); + let tmp_dir = tempfile::tempdir().expect("create tmp_dir failed"); + DATA_DIR + .set(tmp_dir.path().join("data")) + .expect("DATA_DIR set only once"); + group.bench_with_input(BenchmarkId::new("resolve", SIZE), &SIZE, |b, txs_size| { b.iter_batched( || setup_chain(*txs_size),