Skip to content

Commit 4440000

Browse files
goffrieConvex, Inc.
authored andcommitted
Add context creation benchmark to isolate (#41511)
GitOrigin-RevId: 5853adaf2070bfb9452910ceb75c61ed78da832d
1 parent d2391cf commit 4440000

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/isolate/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ async-broadcast = { workspace = true }
131131
async-channel = { workspace = true }
132132
common = { workspace = true, features = ["testing"] }
133133
database = { workspace = true, features = ["testing"] }
134+
divan = { workspace = true }
134135
errors = { workspace = true, features = ["testing"] }
135136
hyper = { workspace = true }
136137
keybroker = { workspace = true, features = ["testing"] }
@@ -151,5 +152,9 @@ usage_tracking = { workspace = true, features = ["testing"] }
151152
value = { workspace = true, features = ["testing"] }
152153
vector = { workspace = true, features = ["testing"] }
153154

155+
[[bench]]
156+
name = "new_context"
157+
harness = false
158+
154159
[lints]
155160
workspace = true
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use deno_core::v8;
2+
use isolate::ConcurrencyLimiter;
3+
use runtime::prod::ProdRuntime;
4+
5+
fn main() {
6+
isolate::client::initialize_v8();
7+
divan::main();
8+
}
9+
10+
#[divan::bench]
11+
fn create_context(bencher: divan::Bencher) {
12+
let tokio_rt = tokio::runtime::Builder::new_multi_thread().build().unwrap();
13+
let rt = ProdRuntime::new(&tokio_rt);
14+
let limiter = ConcurrencyLimiter::unlimited();
15+
let mut isolate = isolate::isolate::Isolate::new(rt.clone(), None, limiter.clone());
16+
bencher.bench_local(|| {
17+
let mut scope = isolate.handle_scope();
18+
v8::Context::new(&mut scope, v8::ContextOptions::default());
19+
});
20+
}
21+
22+
#[divan::bench]
23+
fn create_isolate(bencher: divan::Bencher) {
24+
let tokio_rt = tokio::runtime::Builder::new_multi_thread().build().unwrap();
25+
let rt = ProdRuntime::new(&tokio_rt);
26+
let limiter = ConcurrencyLimiter::unlimited();
27+
bencher.bench(|| {
28+
let mut isolate = isolate::isolate::Isolate::new(rt.clone(), None, limiter.clone());
29+
let mut scope = isolate.handle_scope();
30+
v8::Context::new(&mut scope, v8::ContextOptions::default());
31+
});
32+
}

0 commit comments

Comments
 (0)