Skip to content

Commit 5a10f34

Browse files
committed
Merge version peek and reset
Implementing peeking Add more peek functions Fix failing tests Implemented peek Fix n key peek function Added peek tests for n advances Implemented reset Added reset test for dashmap stable formatting fix failing no)_std tests Fix formatting Clippy lints Add test for peek Add tests Add tests Add dashmap tests assert coverage test Address coverage formatting Move reset from unit to bool return type Change to nested results Format code direct tests codecov Codecov wip Improve codecov and tests Codecov wip formatting Codecov wip formatting Improve runtime Add rand dep Test peek formatting fix compiling fix std lib Improve tests formattings non std import removed Improve reset tests Adressed comments Added tests Call measure and peek in collision Added peek test for codecov Include test for M1 since now fixed Remove clock default impl Add coverage code Silence clippy Increase coverage Clippy fixes Trigger pipeline Rebase upstream Add race condition test formatting limit test to std Trigger pipeline Retrigger pipeline trigger compare_exchange_weak failure Improve comment Add comments Reduce sleep Add tests for clone and default Add clone and debug formatting Fix debug test
1 parent 5cd2d5e commit 5a10f34

File tree

20 files changed

+1171
-102
lines changed

20 files changed

+1171
-102
lines changed

governor/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ libc = "0.2.70"
3333
futures = "0.3.5"
3434
proptest = "1.0.0"
3535
all_asserts = "2.2.0"
36+
rand = "0.8.0"
37+
num_cpus = "1.13.0"
3638

3739
[features]
3840
default = ["std", "dashmap", "jitter", "quanta"]

governor/benches/realtime_clock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn bench_all(c: &mut Criterion) {
1717
macro_rules! with_realtime_clocks {
1818
{($name:expr, $group:ident) |$b:pat, $clock:pat| $closure:block} => {
1919
{
20-
let clock = clock::MonotonicClock::default();
20+
let clock = clock::MonotonicClock;
2121
$group.bench_with_input(BenchmarkId::new($name, "MonotonicClock"), &clock, |$b, $clock| $closure);
2222
}
2323
{

governor/src/clock/quanta.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,23 @@ mod test {
135135
#[test]
136136
fn quanta_upkeep_impls_coverage() {
137137
let one_ns = Nanos::new(1);
138-
// let _c1 =
139-
// QuantaUpkeepClock::from_builder(quanta::Upkeep::new(Duration::from_secs(1))).unwrap();
140138
let c = QuantaUpkeepClock::from_interval(Duration::from_secs(1)).unwrap();
141-
let now = c.now();
139+
let n = c;
140+
let now = n.now();
142141
assert_ne!(now + one_ns, now);
143142
assert_eq!(one_ns, Reference::duration_since(&(now + one_ns), now));
144143
assert_eq!(Nanos::new(0), Reference::duration_since(&now, now + one_ns));
145144
assert_eq!(
146145
Reference::saturating_sub(&(now + Duration::from_nanos(1).into()), one_ns),
147146
now
148147
);
148+
149+
// Test the Clone implementation
150+
let c_clone = n.clone();
151+
let now_clone = c_clone.now();
152+
assert_eq!(now, now_clone);
153+
// Check that the debug string is not empty
154+
let debug_str = format!("{:?}", c_clone);
155+
assert!(!debug_str.is_empty());
149156
}
150157
}

governor/src/clock/with_std.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,33 +96,31 @@ impl ReasonablyRealtime for SystemClock {}
9696
/// Some tests to ensure that the code above gets exercised. We don't
9797
/// rely on them in tests (being nastily tainted by realism), so we
9898
/// have to get creative.
99+
#[allow(clippy::default_constructed_unit_structs)]
99100
#[cfg(test)]
100101
mod test {
101102
use super::*;
102103
use crate::clock::{Clock, Reference, SystemClock};
103104
use crate::nanos::Nanos;
104105
use std::time::Duration;
105106

106-
cfg_if::cfg_if! {
107-
// This test is broken on macOS on M1 machines, due to
108-
// https://github.com/rust-lang/rust/issues/91417:
109-
if #[cfg(not(all(target_arch = "aarch64", target_os = "macos")))] {
110-
use crate::clock::MonotonicClock;
111-
#[test]
112-
fn instant_impls_coverage() {
113-
let one_ns = Nanos::new(1);
114-
let c = MonotonicClock::default();
115-
let now = c.now();
116-
let ns_dur = Duration::from(one_ns);
117-
assert_ne!(now + ns_dur, now, "{:?} + {:?}", ns_dur, now);
118-
assert_eq!(one_ns, Reference::duration_since(&(now + one_ns), now));
119-
assert_eq!(Nanos::new(0), Reference::duration_since(&now, now + one_ns));
120-
assert_eq!(
121-
Reference::saturating_sub(&(now + Duration::from_nanos(1)), one_ns),
122-
now
123-
);
124-
}
125-
}
107+
use crate::clock::MonotonicClock;
108+
#[test]
109+
fn instant_impls_coverage() {
110+
let one_ns = Nanos::new(1);
111+
112+
let c = MonotonicClock::default();
113+
format!("{:?}", c);
114+
let n = c;
115+
let now = n.now();
116+
let ns_dur = Duration::from(one_ns);
117+
assert_ne!(now + ns_dur, now, "{:?} + {:?}", ns_dur, now);
118+
assert_eq!(one_ns, Reference::duration_since(&(now + one_ns), now));
119+
assert_eq!(Nanos::new(0), Reference::duration_since(&now, now + one_ns));
120+
assert_eq!(
121+
Reference::saturating_sub(&(now + Duration::from_nanos(1)), one_ns),
122+
now
123+
);
126124
}
127125

128126
#[test]

governor/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ mod test {
2929
#[test]
3030
fn coverage() {
3131
let display_output = format!("{}", InsufficientCapacity(3));
32-
assert!(display_output.contains("3"));
32+
assert!(display_output.contains('3'));
3333
let debug_output = format!("{:?}", InsufficientCapacity(3));
34-
assert!(debug_output.contains("3"));
34+
assert!(debug_output.contains('3'));
3535
assert_eq!(InsufficientCapacity(3), InsufficientCapacity(3));
3636
}
3737
}

0 commit comments

Comments
 (0)