mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
add bench
This commit is contained in:
parent
851aa9cfaa
commit
51655176ca
21
tests/bench/.cargo/config.toml
Normal file
21
tests/bench/.cargo/config.toml
Normal file
@ -0,0 +1,21 @@
|
||||
[unstable]
|
||||
build-std = ["core"]
|
||||
build-std-features = ["panic_immediate_abort"]
|
||||
|
||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||
#runner = "../../sshprobe.sh"
|
||||
runner = "teleprobe local run --chip nRF52840_xxAA --elf"
|
||||
#runner = "teleprobe client run -s"
|
||||
#runner = "probe-rs run --chip nRF52840_xxAA"
|
||||
|
||||
rustflags = [
|
||||
# Code-size optimizations.
|
||||
"-Z", "trap-unreachable=no",
|
||||
"-C", "no-vectorize-loops",
|
||||
]
|
||||
|
||||
[build]
|
||||
target = "thumbv7em-none-eabi"
|
||||
|
||||
[env]
|
||||
DEFMT_LOG = "trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,smoltcp=info"
|
22
tests/bench/Cargo.toml
Normal file
22
tests/bench/Cargo.toml
Normal file
@ -0,0 +1,22 @@
|
||||
[package]
|
||||
edition = "2021"
|
||||
name = "embassy-bench"
|
||||
version = "0.1.0"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
teleprobe-meta = "1"
|
||||
embassy-executor = { version = "0.6.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "nightly"] }
|
||||
static_cell = { version = "2", features = ["nightly"] }
|
||||
defmt = "0.3"
|
||||
defmt-rtt = "0.4"
|
||||
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||
cortex-m-rt = "0.7.0"
|
||||
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
||||
debug = 2
|
||||
incremental = false
|
||||
lto = "fat"
|
||||
opt-level = 's'
|
10
tests/bench/build.rs
Normal file
10
tests/bench/build.rs
Normal file
@ -0,0 +1,10 @@
|
||||
use std::error::Error;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
println!("cargo:rustc-link-arg-bins=--nmagic");
|
||||
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
||||
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
||||
println!("cargo:rustc-link-arg-bins=-Tteleprobe.x");
|
||||
|
||||
Ok(())
|
||||
}
|
5
tests/bench/memory.x
Normal file
5
tests/bench/memory.x
Normal file
@ -0,0 +1,5 @@
|
||||
MEMORY
|
||||
{
|
||||
FLASH : ORIGIN = 0x00810000, LENGTH = 192K
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 64K
|
||||
}
|
56
tests/bench/src/bin/selfwake.rs
Normal file
56
tests/bench/src/bin/selfwake.rs
Normal file
@ -0,0 +1,56 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
teleprobe_meta::target!(b"nrf52840-dk");
|
||||
|
||||
use core::future::Future;
|
||||
use core::pin::Pin;
|
||||
use core::task::{Context, Poll};
|
||||
|
||||
use cortex_m_rt::{entry, exception};
|
||||
use defmt::{info, unwrap};
|
||||
use embassy_executor::raw::TaskStorage;
|
||||
use embassy_executor::Executor;
|
||||
use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
static mut COUNTER: u32 = 0;
|
||||
|
||||
#[exception]
|
||||
fn SysTick() -> ! {
|
||||
let c = unsafe { COUNTER };
|
||||
info!("Test OK, count={=u32}, cycles={=u32}", c, 0x00ffffff * 100 / c);
|
||||
cortex_m::asm::bkpt();
|
||||
loop {}
|
||||
}
|
||||
|
||||
struct Task1 {}
|
||||
impl Future for Task1 {
|
||||
type Output = ();
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
unsafe { COUNTER += 1 };
|
||||
cx.waker().wake_by_ref();
|
||||
Poll::Pending
|
||||
}
|
||||
}
|
||||
|
||||
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
|
||||
static TASK1: TaskStorage<Task1> = TaskStorage::new();
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
info!("Hello World!");
|
||||
|
||||
//let _p = embassy_nrf::init(Default::default());
|
||||
let executor = EXECUTOR.init(Executor::new());
|
||||
executor.run(|spawner| {
|
||||
unwrap!(spawner.spawn(TASK1.spawn(|| Task1 {})));
|
||||
|
||||
let mut systick: cortex_m::peripheral::SYST = unsafe { core::mem::transmute(()) };
|
||||
systick.disable_counter();
|
||||
systick.set_clock_source(cortex_m::peripheral::syst::SystClkSource::Core);
|
||||
systick.set_reload(0x00ffffff);
|
||||
systick.enable_interrupt();
|
||||
systick.enable_counter();
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user