feat: cargo bench, nightly in devshell

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
Christina Sørensen 2024-05-14 16:06:01 +02:00
parent 1f6fe32adc
commit 3c1624814e
Signed by: cafkafk
GPG key ID: 26C542FD97F965CE
4 changed files with 21 additions and 2 deletions

3
.envrc Normal file
View file

@ -0,0 +1,3 @@
if has nix; then
use flake .
fi

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/target
/result
.direnv/*

View file

@ -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
];
};

View file

@ -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() {