Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let width = 500;
- let height = 5000;
- let mut total = 0.0;
- let mut collection =vec![255;width*height*4];
- for i in 0..20 {
- println!("round {}",i);
- let now = SystemTime::now();
- for j in 0..height {
- for i in 0..width {
- if i > width/4 && i < width*3/4 {
- collection[i + j*width*4] = 0;
- collection[i+j*width*4 + 1] = 0;
- collection[i+j*width*4 +2] = 0;
- }
- }
- }
- total += now.elapsed().unwrap().as_millis() as f64;
- }
- println!("20 runs took {} total for each {}",total,total/20.0) ;
- println!("merge 20 20 {:?}",merge(20,20));
- for i in 0..20 {
- // merge height lines
- let mut collection = vec![255; width * height * 4]; //rgba for each pixel
- println!("round {}",i);
- let now = SystemTime::now();
- // skips four lines takes the next 8
- //for pixel in collection.chunks_mut(4 * width).skip(4).take(8).flat_map(|line| line[4 * 4 .. 12 * 4].chunks_mut(4)) {
- for pixel in collection.chunks_mut(4 * width).flat_map(|line| line[width/4 * 4 .. width*3/4 * 4].chunks_mut(4)) {
- pixel[.. 3].copy_from_slice(&[0, 0, 0]);
- }
- total +=now.elapsed().unwrap().as_millis() as f64;
- }
- println!("20 runs took {} total for each {}",total,total/20.0) ;
- // make a black square in the middle
- // canvas is 16x16 go from 4 to 12 for each
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement