github.com/stealthrocket/wzprof@v0.2.1-0.20230830205924-5fa86be5e5b3/testdata/rust/simple/src/main.rs (about)

     1  fn main() {
     2      let a = allocate_memory(10);
     3      let b = allocate_memory(20);
     4      let c = allocate_memory(30);
     5      println!("Allocated memory: a={:?}, b={:?}, c={:?}", a, b, c);
     6  }
     7  
     8  fn allocate_memory(size: usize) -> Vec<i32> {
     9      let mut vec = Vec::with_capacity(size);
    10      for i in 0..size {
    11          vec.push(i as i32);
    12      }
    13      let d = allocate_more_memory(size);
    14      vec.extend(d);
    15      vec
    16  }
    17  
    18  fn allocate_more_memory(size: usize) -> Vec<i32> {
    19      let mut vec = Vec::with_capacity(size);
    20      for i in 0..size {
    21          vec.push((i as i32) * 2);
    22      }
    23      let e = allocate_even_more_memory(size);
    24      vec.extend(e);
    25      vec
    26  }
    27  
    28  fn allocate_even_more_memory(size: usize) -> Vec<i32> {
    29      let mut vec = Vec::with_capacity(size);
    30      for i in 0..size {
    31          vec.push((i as i32) * 3);
    32      }
    33      vec
    34  }