File tree 3 files changed +41
-0
lines changed
src/tools/miri/bench-cargo-miri/slice-chunked
3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
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 number Diff line number Diff line change
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 number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments