Skip to content

Commit

Permalink
feat: Add more Unix time conversion methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Sep 28, 2024
1 parent e4de4c2 commit 01864b6
Show file tree
Hide file tree
Showing 3 changed files with 467 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ project adheres to https://semver.org/[Semantic Versioning].
* Implement `rand::distributions::Distribution` for `FileTime`
({pull-request-url}/227[#227])
* Add benchmarks ({pull-request-url}/228[#228])
* Add methods to convert between `FileTime` and Unix time in milliseconds and
microseconds ({pull-request-url}/229[#229])

== {compare-url}/v0.9.1\...v0.10.0[0.10.0] - 2024-09-27

Expand Down
20 changes: 20 additions & 0 deletions benches/unix_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ fn to_unix_time_secs(b: &mut Bencher) {
b.iter(|| FileTime::UNIX_EPOCH.to_unix_time_secs());
}

#[bench]
fn to_unix_time_millis(b: &mut Bencher) {
b.iter(|| FileTime::UNIX_EPOCH.to_unix_time_millis());
}

#[bench]
fn to_unix_time_micros(b: &mut Bencher) {
b.iter(|| FileTime::UNIX_EPOCH.to_unix_time_micros());
}

#[bench]
fn to_unix_time_nanos(b: &mut Bencher) {
b.iter(|| FileTime::UNIX_EPOCH.to_unix_time_nanos());
Expand All @@ -41,6 +51,16 @@ fn from_unix_time_secs(b: &mut Bencher) {
b.iter(|| FileTime::from_unix_time_secs(i64::default()).unwrap());
}

#[bench]
fn from_unix_time_millis(b: &mut Bencher) {
b.iter(|| FileTime::from_unix_time_millis(i64::default()).unwrap());
}

#[bench]
fn from_unix_time_micros(b: &mut Bencher) {
b.iter(|| FileTime::from_unix_time_micros(i64::default()).unwrap());
}

#[bench]
fn from_unix_time_nanos(b: &mut Bencher) {
b.iter(|| FileTime::from_unix_time_nanos(i128::default()).unwrap());
Expand Down
Loading

0 comments on commit 01864b6

Please sign in to comment.