Add benchmark for TB slowdown
This commit is contained in:
parent
e26779e784
commit
e34f35edd8
3 changed files with 41 additions and 0 deletions
7
src/tools/miri/bench-cargo-miri/slice-chunked/Cargo.lock
Normal file
7
src/tools/miri/bench-cargo-miri/slice-chunked/Cargo.lock
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "slice-chunked"
|
||||
version = "0.1.0"
|
||||
8
src/tools/miri/bench-cargo-miri/slice-chunked/Cargo.toml
Normal file
8
src/tools/miri/bench-cargo-miri/slice-chunked/Cargo.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "slice-chunked"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
26
src/tools/miri/bench-cargo-miri/slice-chunked/src/main.rs
Normal file
26
src/tools/miri/bench-cargo-miri/slice-chunked/src/main.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//! This is a small example using slice::chunks, which creates a very large Tree Borrows tree.
|
||||
//! Thanks to ##3837, the GC now compacts the tree, so this test can be run in a reasonable time again.
|
||||
//! The actual code is adapted from tiny_skia, see https://github.com/RazrFalcon/tiny-skia/blob/master/src/pixmap.rs#L121
|
||||
//! To make this benchmark demonstrate the effectiveness, run with MIRIFLAGS="-Zmiri-tree-borrows -Zmiri-provenance-gc=100"
|
||||
|
||||
const N: usize = 1000;
|
||||
|
||||
fn input_vec() -> Vec<u8> {
|
||||
vec![0; N]
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let data_len = 2 * N;
|
||||
let mut rgba_data = Vec::with_capacity(data_len);
|
||||
let img_data = input_vec();
|
||||
for slice in img_data.chunks(2) {
|
||||
let gray = slice[0];
|
||||
let alpha = slice[1];
|
||||
rgba_data.push(gray);
|
||||
rgba_data.push(gray);
|
||||
rgba_data.push(gray);
|
||||
rgba_data.push(alpha);
|
||||
}
|
||||
|
||||
assert_eq!(rgba_data.len(), data_len);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue