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
|
/target
|
||||||
/result
|
/result
|
||||||
|
.direnv/*
|
||||||
|
|
|
@ -161,7 +161,9 @@
|
||||||
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";
|
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";
|
||||||
|
|
||||||
# Extra inputs can be added here; cargo and rustc are provided by default.
|
# Extra inputs can be added here; cargo and rustc are provided by default.
|
||||||
packages = [
|
packages = with pkgs; [
|
||||||
|
rustup
|
||||||
|
toolchain
|
||||||
# pkgs.ripgrep
|
# 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 chrono::prelude::*;
|
||||||
use std::{env, io};
|
use std::{env, io};
|
||||||
use utils::print_time_delta;
|
use utils::print_time_delta;
|
||||||
|
@ -73,6 +76,7 @@ mod utils {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use test::{black_box, Bencher};
|
||||||
|
|
||||||
const DATE: &str = "1998-01-20T16:00:00+01:00";
|
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]
|
#[test]
|
||||||
#[should_panic(expected = "Couldn't parse timestamp.")]
|
#[should_panic(expected = "Couldn't parse timestamp.")]
|
||||||
fn parse_timestamp_hms_highh() {
|
fn parse_timestamp_hms_highh() {
|
||||||
|
|
Loading…
Reference in a new issue