Skip to content

Commit e34f35e

Browse files
Add benchmark for TB slowdown
1 parent e26779e commit e34f35e

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is automatically @generated by Cargo.
2+
# It is not intended for manual editing.
3+
version = 3
4+
5+
[[package]]
6+
name = "slice-chunked"
7+
version = "0.1.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "slice-chunked"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//! This is a small example using slice::chunks, which creates a very large Tree Borrows tree.
2+
//! Thanks to ##3837, the GC now compacts the tree, so this test can be run in a reasonable time again.
3+
//! The actual code is adapted from tiny_skia, see https://github.com/RazrFalcon/tiny-skia/blob/master/src/pixmap.rs#L121
4+
//! To make this benchmark demonstrate the effectiveness, run with MIRIFLAGS="-Zmiri-tree-borrows -Zmiri-provenance-gc=100"
5+
6+
const N: usize = 1000;
7+
8+
fn input_vec() -> Vec<u8> {
9+
vec![0; N]
10+
}
11+
12+
fn main() {
13+
let data_len = 2 * N;
14+
let mut rgba_data = Vec::with_capacity(data_len);
15+
let img_data = input_vec();
16+
for slice in img_data.chunks(2) {
17+
let gray = slice[0];
18+
let alpha = slice[1];
19+
rgba_data.push(gray);
20+
rgba_data.push(gray);
21+
rgba_data.push(gray);
22+
rgba_data.push(alpha);
23+
}
24+
25+
assert_eq!(rgba_data.len(), data_len);
26+
}

0 commit comments

Comments
 (0)