feat: cargo bench, nightly in devshell
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
parent
1f6fe32adc
commit
3c1624814e
4 changed files with 21 additions and 2 deletions
3
.envrc
Normal file
3
.envrc
Normal file
|
@ -0,0 +1,3 @@
|
|||
if has nix; then
|
||||
use flake .
|
||||
fi
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
/target
|
||||
/result
|
||||
.direnv/*
|
||||
|
|
|
@ -161,7 +161,9 @@
|
|||
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";
|
||||
|
||||
# Extra inputs can be added here; cargo and rustc are provided by default.
|
||||
packages = [
|
||||
packages = with pkgs; [
|
||||
rustup
|
||||
toolchain
|
||||
# pkgs.ripgrep
|
||||
];
|
||||
};
|
||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -1,4 +1,7 @@
|
|||
/// GPLv3 2024 KLM banana bread©
|
||||
#![feature(test)]
|
||||
|
||||
extern crate test;
|
||||
|
||||
use chrono::prelude::*;
|
||||
use std::{env, io};
|
||||
use utils::print_time_delta;
|
||||
|
@ -73,6 +76,7 @@ mod utils {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use test::{black_box, Bencher};
|
||||
|
||||
const DATE: &str = "1998-01-20T16:00:00+01:00";
|
||||
|
||||
|
@ -157,6 +161,15 @@ mod utils {
|
|||
);
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_parse_timestamp_hms(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
for i in 1..1000 {
|
||||
black_box(parse_timestamp(&get_ctx(), &"23:59:59".to_string()));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "Couldn't parse timestamp.")]
|
||||
fn parse_timestamp_hms_highh() {
|
||||
|
|
Loading…
Reference in a new issue