-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2021-2023 Protocol Labs | ||
// SPDX-License-Identifier: Apache-2.0, MIT | ||
use std::hint::black_box; | ||
use std::time::Duration; | ||
|
||
use cid::Cid; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use fvm::engine::EnginePool; | ||
use fvm::machine::{Manifest, NetworkConfig}; | ||
|
||
use fvm_integration_tests::bundle; | ||
use fvm_ipld_blockstore::MemoryBlockstore; | ||
use fvm_ipld_encoding::CborStore; | ||
use fvm_shared::version::NetworkVersion; | ||
|
||
fn bench_compile(c: &mut Criterion) { | ||
c.bench_function("bench actor compile", |b| { | ||
let blockstore = MemoryBlockstore::default(); | ||
let bundle_cid = bundle::import_bundle(&blockstore, actors_v12::BUNDLE_CAR).unwrap(); | ||
|
||
let (manifest_version, manifest_cid): (u32, Cid) = | ||
blockstore.get_cbor(&bundle_cid).unwrap().unwrap(); | ||
let manifest = Manifest::load(&blockstore, &manifest_cid, manifest_version).unwrap(); | ||
let nc = NetworkConfig::new(NetworkVersion::V21); | ||
b.iter_batched( | ||
|| EnginePool::new((&nc).into()).unwrap(), | ||
|engine| { | ||
black_box( | ||
engine | ||
.acquire() | ||
.preload_all(&blockstore, manifest.builtin_actor_codes()) | ||
.unwrap(), | ||
); | ||
}, | ||
criterion::BatchSize::SmallInput, | ||
) | ||
}); | ||
} | ||
|
||
criterion_group! { | ||
name = benches; | ||
config = Criterion::default().sample_size(10).measurement_time(Duration::from_secs(30)); | ||
targets = bench_compile | ||
} | ||
|
||
criterion_main!(benches); |