Skip to content

Commit a1c5f61

Browse files
committed
samples: bench: rustfmt update
Update code formatting. Signed-off-by: David Brown <[email protected]>
1 parent 4f6032b commit a1c5f61

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

samples/bench/src/basesem.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@
2828

2929
use core::{cell::UnsafeCell, ffi::c_uint, mem, sync::atomic::Ordering};
3030

31-
use zephyr::{error::to_result_void, raw::{k_sem, k_sem_give, k_sem_init, k_sem_take}, sync::atomic::AtomicUsize, time::Timeout};
3231
use zephyr::Result;
32+
use zephyr::{
33+
error::to_result_void,
34+
raw::{k_sem, k_sem_give, k_sem_init, k_sem_take},
35+
sync::atomic::AtomicUsize,
36+
time::Timeout,
37+
};
3338

3439
pub struct Semaphore {
3540
state: AtomicUsize,
@@ -38,8 +43,8 @@ pub struct Semaphore {
3843

3944
// SAFETY: These are both Send and Sync. The semaphore itself is safe, and the atomic+critical
4045
// section protects the state.
41-
unsafe impl Send for Semaphore { }
42-
unsafe impl Sync for Semaphore { }
46+
unsafe impl Send for Semaphore {}
47+
unsafe impl Sync for Semaphore {}
4348

4449
impl Semaphore {
4550
/// Construct a new semaphore, with the given initial_count and limit. There is a bit of
@@ -91,7 +96,8 @@ impl Semaphore {
9196
k_sem_init(ptr, initial_count, limit);
9297
}
9398

94-
self.state.store(self as *const Self as usize, Ordering::Release);
99+
self.state
100+
.store(self as *const Self as usize, Ordering::Release);
95101
self.item.get()
96102
})
97103
}

samples/bench/src/lib.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ extern "C" fn rust_main() {
8787
num = num * 13 / 10;
8888
}
8989

90-
9190
printkln!("Done with all tests\n");
9291
}
9392

@@ -835,7 +834,13 @@ impl Simple {
835834
0.0
836835
};
837836

838-
printkln!(" {:8.3} us, {} of {} workers {} times", time, total, workers, iterations);
837+
printkln!(
838+
" {:8.3} us, {} of {} workers {} times",
839+
time,
840+
total,
841+
workers,
842+
iterations
843+
);
839844
}
840845
}
841846

@@ -848,7 +853,11 @@ struct SimpleWorker {
848853

849854
impl SimpleWorker {
850855
fn new(main: Pin<Arc<Work<SimpleMain>>>, workq: Arc<WorkQueue>, id: usize) -> Self {
851-
Self { main, workq, _id: id }
856+
Self {
857+
main,
858+
workq,
859+
_id: id,
860+
}
852861
}
853862
}
854863

@@ -983,7 +992,8 @@ impl<'a> BenchTimer<'a> {
983992

984993
pub fn stop(self) {
985994
let stop = now();
986-
let time = (stop - self.start) as f64 / (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC as f64) * 1000.0;
995+
let time =
996+
(stop - self.start) as f64 / (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC as f64) * 1000.0;
987997
let time = if self.count > 0 {
988998
time / (self.count as f64) * 1000.0
989999
} else {

0 commit comments

Comments
 (0)