Skip to content

Commit e9f7729

Browse files
committed
update
1 parent 9747fba commit e9f7729

File tree

1 file changed

+72
-3
lines changed

1 file changed

+72
-3
lines changed

oscars/benches/mark_sweep_gc_vs_arena3.rs

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn bench_alloc(c: &mut Criterion) {
66

77
for num_objects in [100, 500, 1000].iter() {
88
group.bench_with_input(
9-
BenchmarkId::from_parameter(num_objects),
9+
BenchmarkId::new("oscars", num_objects),
1010
num_objects,
1111
|b, &num_objects| {
1212
b.iter_batched(
@@ -27,6 +27,27 @@ fn bench_alloc(c: &mut Criterion) {
2727
);
2828
},
2929
);
30+
31+
group.bench_with_input(
32+
BenchmarkId::new("boa_gc", num_objects),
33+
num_objects,
34+
|b, &num_objects| {
35+
b.iter_batched(
36+
|| {
37+
boa_gc::force_collect();
38+
},
39+
|()| {
40+
let mut roots = Vec::new();
41+
for i in 0..num_objects {
42+
let root = boa_gc::Gc::new(boa_gc::GcRefCell::new(i));
43+
roots.push(root);
44+
}
45+
black_box(roots.len())
46+
},
47+
criterion::BatchSize::SmallInput,
48+
);
49+
},
50+
);
3051
}
3152

3253
group.finish();
@@ -37,7 +58,7 @@ fn bench_collect(c: &mut Criterion) {
3758

3859
for num_objects in [100, 500, 1000].iter() {
3960
group.bench_with_input(
40-
BenchmarkId::from_parameter(num_objects),
61+
BenchmarkId::new("oscars", num_objects),
4162
num_objects,
4263
|b, &num_objects| {
4364
b.iter_batched(
@@ -60,6 +81,29 @@ fn bench_collect(c: &mut Criterion) {
6081
);
6182
},
6283
);
84+
85+
group.bench_with_input(
86+
BenchmarkId::new("boa_gc", num_objects),
87+
num_objects,
88+
|b, &num_objects| {
89+
b.iter_batched(
90+
|| {
91+
boa_gc::force_collect();
92+
let mut roots = Vec::new();
93+
for i in 0..num_objects {
94+
let root = boa_gc::Gc::new(boa_gc::GcRefCell::new(i));
95+
roots.push(root);
96+
}
97+
roots
98+
},
99+
|roots| {
100+
boa_gc::force_collect();
101+
black_box(roots.len())
102+
},
103+
criterion::BatchSize::SmallInput,
104+
);
105+
},
106+
);
63107
}
64108

65109
group.finish();
@@ -71,7 +115,7 @@ fn bench_collect_with_dead(c: &mut Criterion) {
71115

72116
for num_objects in [100, 500, 1000].iter() {
73117
group.bench_with_input(
74-
BenchmarkId::from_parameter(num_objects),
118+
BenchmarkId::new("oscars", num_objects),
75119
num_objects,
76120
|b, &num_objects| {
77121
b.iter_batched(
@@ -97,6 +141,31 @@ fn bench_collect_with_dead(c: &mut Criterion) {
97141
);
98142
},
99143
);
144+
145+
group.bench_with_input(
146+
BenchmarkId::new("boa_gc", num_objects),
147+
num_objects,
148+
|b, &num_objects| {
149+
b.iter_batched(
150+
|| {
151+
boa_gc::force_collect();
152+
let mut roots = Vec::new();
153+
for i in 0..num_objects {
154+
let root = boa_gc::Gc::new(boa_gc::GcRefCell::new(i));
155+
if i % 4 == 0 {
156+
roots.push(root);
157+
}
158+
}
159+
roots
160+
},
161+
|roots| {
162+
boa_gc::force_collect();
163+
black_box(roots.len())
164+
},
165+
criterion::BatchSize::SmallInput,
166+
);
167+
},
168+
);
100169
}
101170

102171
group.finish();

0 commit comments

Comments
 (0)