benchmarks

This commit is contained in:
2023-11-18 17:52:07 +01:00
parent eb723f5112
commit ad6ddf4f75
5 changed files with 109 additions and 9 deletions

View File

@@ -2,8 +2,37 @@
to: <%= dir %>/rust/main.rs
unless_exists: true
---
fn main() {
// Part A
let contents = include_str!("../test.txt").trim();
println!("A: {}", contents);
#![feature(test)]
extern crate test;
#[cfg(test)]
mod tests {
use super::*;
use test::Bencher;
#[bench]
fn bench_a(b: &mut Bencher) {
b.iter(|| part_a());
}
#[bench]
fn bench_b(b: &mut Bencher) {
b.iter(|| part_b());
}
}
fn part_a() {
let result = include_str!("../input.txt");
println!("A: {}", result);
}
fn part_b() {
let result = include_str!("../input.txt");
println!("A: {}", result);
}
fn main() {
part_a();
part_b();
}