message: age: Clean up buffers in throughput benchmarks
diff: @@ -10,7 +10,11 @@ fn bench(c: &mut Criterion<CyclesPerByte>) {
  let identity = x25519::Identity::generate();
  let recipient = identity.to_public();
  let mut group = c.benchmark_group("stream");
  - let mut buf = vec![0u8; 1024 * KB];
  +
  + // Prepare buffers to use in the benchmarks.
  + let pt_buf = vec![7u8; 1024 * KB];
  + let mut ct_buf = vec![];
  + let mut out_buf = vec![0u8; 1024 * KB];
  for &size in &[
  KB,
  @@ -29,29 +33,30 @@ fn bench(c: &mut Criterion<CyclesPerByte>) {
  let mut output = Encryptor::with_recipients(vec![Box::new(recipient.clone())])
  .wrap_output(io::sink())
  .unwrap();
  - output.write_all(&buf[..size]).unwrap();
  + output.write_all(&pt_buf[..size]).unwrap();
  output.finish().unwrap();
  })
  });
  group.bench_function(BenchmarkId::new("decrypt", size), |b| {
  - let mut encrypted = vec![];
  let mut output = Encryptor::with_recipients(vec![Box::new(recipient.clone())])
  - .wrap_output(&mut encrypted)
  + .wrap_output(&mut ct_buf)
  .unwrap();
  - output.write_all(&buf[..size]).unwrap();
  + output.write_all(&pt_buf[..size]).unwrap();
  output.finish().unwrap();
  b.iter(|| {
  - let decryptor = match Decryptor::new(&encrypted[..]).unwrap() {
  + let decryptor = match Decryptor::new(&ct_buf[..]).unwrap() {
  Decryptor::Recipients(decryptor) => decryptor,
  _ => panic!(),
  };
  let mut input = decryptor
  .decrypt(iter::once(&identity as &dyn age::Identity))
  .unwrap();
  - input.read_exact(&mut buf[..size]).unwrap();
  - })
  + input.read_exact(&mut out_buf[..size]).unwrap();
  + });
  +
  + ct_buf.clear();
  });
  }
  