Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: unit variable support #57

Merged
merged 1 commit into from
Dec 4, 2023
Merged

add: unit variable support #57

merged 1 commit into from
Dec 4, 2023

Conversation

sivertjoe
Copy link
Collaborator

context 🐦

I added this to my/the template

let fmt = std::env::var("TASKUNIT").unwrap_or("ms".to_owned());
let (u, elapsed) = match fmt.as_str() {
    "ms" => ("ms", elapsed.as_millis()),
    "ns" => ("ns", elapsed.as_nanos()),
    "us" => ("μs", elapsed.as_micros()),
    "s" => ("s", elapsed.as_secs() as u128),
    _ => panic!("unsupported time format"),
};

So that I can run TASKUNIT=us cargo aoc run and get the microsecond performance, for instance

This code breaks the tally, and , more importantly, run -S 1|2 command, so I had to fix that

Let me know what you think

@sivertjoe sivertjoe requested a review from seblyng December 2, 2023 16:28
Copy link
Owner

@seblyng seblyng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice🙌

@sivertjoe sivertjoe merged commit d0c4650 into master Dec 4, 2023
1 check passed
sivertjoe added a commit that referenced this pull request Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants