From 9e16a09b44e55eb26b8d2e647953826650b459a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Sun, 13 Aug 2023 16:10:17 +0200 Subject: [PATCH] Bump time dependency to 0.3 (#22) * Bump time dependency to 0.3 * downgrade time for rust 1.63.0 in ci --- .github/workflows/ci.yml | 7 +++++++ generator/Cargo.toml | 2 +- generator/src/phf.rs | 9 ++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ddfdf2..5948cc2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,6 +97,13 @@ jobs: profile: minimal override: true + - name: downgrade 'time' for Rust 1.63.0 + uses: actions-rs/cargo@v1 + with: + command: update + args: --package time --precise 0.3.20 + if: ${{ matrix.rust == '1.63.0' }} + - name: Build generator uses: actions-rs/cargo@v1 with: diff --git a/generator/Cargo.toml b/generator/Cargo.toml index 2763356..e8f4aca 100644 --- a/generator/Cargo.toml +++ b/generator/Cargo.toml @@ -9,7 +9,7 @@ authors = ["Huon Wilson "] unstable = [] [dependencies] -time = "0.1.10" +time = "0.3" log = "0" getopts = "0.2.21" rand = "0.8.5" diff --git a/generator/src/phf.rs b/generator/src/phf.rs index 1934a86..e5747a4 100644 --- a/generator/src/phf.rs +++ b/generator/src/phf.rs @@ -145,19 +145,18 @@ pub fn create_phf( max_tries: usize, ) -> (u64, Vec<(u32, u32)>, Vec) { let mut rng = StdRng::seed_from_u64(0xf0f0f0f0); - let start = time::precise_time_s(); + let start = time::Instant::now(); for i in 0..(max_tries) { - let my_start = time::precise_time_s(); + let my_start = time::Instant::now(); println!("PHF #{}: starting {:.2}", i, my_start - start); let seed = rng.gen(); if let Some((disp, map)) = try_phf_table(data, lambda, seed, &mut rng) { - let end = time::precise_time_s(); println!( "PHF took: total {:.2} s, successive {:.2} s", - end - start, - end - my_start + start.elapsed(), + my_start.elapsed() ); return (seed, disp, map); }