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

[DRAFT] Durations are now zeptosecond counters (1e-21 second) #326

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hifitime"
version = "4.0.0-alpha.1"
version = "4.0.0-beta.0"
authors = ["Christopher Rabotin <[email protected]>"]
description = "Ultra-precise date and time handling in Rust for scientific applications with leap second support"
homepage = "https://nyxspace.com/"
Expand Down Expand Up @@ -36,6 +36,7 @@ tabled = { version = "0.16.0", optional = true }
openssl = { version = "0.10", features = ["vendored"], optional = true }
web-time = { version = "1.0.0", optional = true }
snafu = { version = "0.8.2", default-features = false }
typed-builder = "0.20.0"

[features]
default = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ assert_eq!(format!("{rounded}"), "12 min");

// And this works on Epochs as well.
let previous_post = Epoch::from_gregorian_utc_hms(2015, 2, 7, 11, 22, 33);
let example_now = Epoch::from_gregorian_utc_hms(2015, 8, 17, 22, 55, 01);
let example_now = Epoch::from_gregorian_utc_hms(2015, 8, 17, 22, 55, 1);

// We'll round to the nearest fifteen days
let this_much_ago = example_now - previous_post;
Expand Down
2 changes: 1 addition & 1 deletion benches/crit_duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
b.iter(|| {
let interval_length_s: f64 = 6311433599.999999;
let interval_length: Duration = black_box(interval_length_s * Unit::Second);
interval_length.to_parts().1;
interval_length.total_nanoseconds()
})
},
);
Expand Down
4 changes: 2 additions & 2 deletions benches/iai_duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ fn duration_from_f64_seconds_via_units() {

fn duration_from_i64_nanoseconds() {
let value: i64 = 6311433599;
black_box(Duration::from_truncated_nanoseconds(value));
black_box(Duration::from_total_nanoseconds(value.into()));
}

fn duration_from_i64_nanoseconds_via_units() {
let value: i64 = 6311433599;
let value: i128 = 6311433599;
black_box(value * Unit::Nanosecond);
}

Expand Down
Loading
Loading