mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
this version of benchmark works.
This commit is contained in:
parent
31e58c3337
commit
d235218ec3
4 changed files with 22 additions and 4 deletions
|
|
@ -1,11 +1,25 @@
|
|||
use xous::{Message, ScalarMessage};
|
||||
use xous_names::api::Lookup;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct TestStruct {
|
||||
pub challenge: [u32; 8],
|
||||
}
|
||||
impl TestStruct {
|
||||
pub fn new() -> Self {
|
||||
TestStruct {
|
||||
challenge: [0; 8],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub enum Opcode {
|
||||
TestScalar(u32),
|
||||
TestMemory(Lookup),
|
||||
//TestMemory(Lookup),
|
||||
TestMemory(TestStruct),
|
||||
}
|
||||
|
||||
impl core::convert::TryFrom<& Message> for Opcode {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#![cfg_attr(target_os = "none", no_std)]
|
||||
|
||||
pub mod api;
|
||||
use api::*;
|
||||
|
||||
use xous::{CID, send_message};
|
||||
use xous_names::api::Lookup;
|
||||
use xous::ipc::Sendable;
|
||||
|
|
@ -15,7 +17,8 @@ pub fn test_scalar(cid: CID, testvar: u32) -> Result<u32, xous::Error> {
|
|||
}
|
||||
|
||||
pub fn test_memory(cid: CID, testvar: u32) -> Result<u32, xous::Error> {
|
||||
let reg = Lookup::new();
|
||||
//let reg = Lookup::new();
|
||||
let reg = TestStruct::new();
|
||||
let mut sendable_reg = Sendable::new(reg).expect("can't create test structure");
|
||||
sendable_reg.challenge[0] = testvar;
|
||||
sendable_reg.lend_mut(cid, 0).expect("test failure");
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ fn xmain() -> ! {
|
|||
_ => error!("BENCHTARGET: opcode not yet implemented"),
|
||||
}
|
||||
} else if let xous::Message::MutableBorrow(m) = &envelope.body {
|
||||
let lookup: &mut Lookup = unsafe { &mut *(m.buf.as_mut_ptr() as *mut Lookup) };
|
||||
//let lookup: &mut Lookup = unsafe { &mut *(m.buf.as_mut_ptr() as *mut Lookup) };
|
||||
let lookup: &mut TestStruct = unsafe { &mut *(m.buf.as_mut_ptr() as *mut TestStruct) };
|
||||
lookup.challenge[0] = lookup.challenge[0] + 1;
|
||||
} else {
|
||||
error!("BENCHTARGET: couldn't convert opcode");
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ fn shell_main() -> ! {
|
|||
|
||||
// actual benchmark
|
||||
// get a scalar message
|
||||
if false {
|
||||
if true {
|
||||
// measured at 1349 iterations per second in this loop
|
||||
count = benchmark_target::test_scalar(target_conn, count).expect("BENCHMARK: couldn't send test message");
|
||||
check_count = check_count + 1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue