extract worst response from trace
This commit is contained in:
parent
cc61262037
commit
2098e3fb0e
17
state2gantt/Cargo.lock
generated
17
state2gantt/Cargo.lock
generated
@ -76,9 +76,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.7"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b"
|
||||
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
@ -305,9 +305,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.7"
|
||||
version = "4.5.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f"
|
||||
checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@ -315,9 +315,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.7"
|
||||
version = "4.5.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f"
|
||||
checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@ -327,9 +327,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.5"
|
||||
version = "4.5.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6"
|
||||
checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
@ -1580,6 +1580,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
name = "state2gantt"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"fret",
|
||||
"rand",
|
||||
"ron",
|
||||
|
@ -12,3 +12,4 @@ serde = { version = "1.0", default-features = false, features = ["alloc"] } # se
|
||||
# petgraph = { version="0.6.0", features = ["serde-1"] }
|
||||
ron = "0.7" # write serialized data - including hashmaps
|
||||
rand = "0.5"
|
||||
clap = "4.5.17"
|
||||
|
@ -2,6 +2,6 @@
|
||||
if [ -z "$1" ]; then exit 1; fi
|
||||
OFILE_A="$(dirname "$1")/$(basename -s .trace.ron "$1")_a.csv"
|
||||
OFILE_B="$(dirname "$1")/$(basename -s .trace.ron "$1")_b.csv"
|
||||
~/code/FRET/state2gantt/target/debug/state2gantt $1 "$OFILE_A" "$OFILE_B"
|
||||
~/code/FRET/state2gantt/target/debug/state2gantt -i $1 -a "$OFILE_A" -r "$OFILE_B"
|
||||
# ~/code/FRET/state2gantt/plot.r "$OFILE_A" html
|
||||
~/code/FRET/state2gantt/plot_response.r "$OFILE_A" "$OFILE_B" html
|
@ -1,20 +1,87 @@
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::{env,fs};
|
||||
use fret::systemstate::RefinedFreeRTOSSystemState;
|
||||
use fret::systemstate::{ExecInterval, ReducedFreeRTOSSystemState};
|
||||
use std::io::Write;
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Config {
|
||||
/// Input Trace
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
input_trace: PathBuf,
|
||||
|
||||
/// Output for activations
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
activation: Option<PathBuf>,
|
||||
|
||||
/// Output for Release-Response intervals
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
response: Option<PathBuf>,
|
||||
|
||||
/// Focussed Task
|
||||
#[arg(short, long, value_name = "TASK")]
|
||||
task: Option<String>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args : Vec<String> = env::args().collect();
|
||||
// let args : Vec<String> = env::args().collect();
|
||||
let conf = Config::parse();
|
||||
|
||||
let path_a = PathBuf::from(args[1].clone());
|
||||
let raw_a = fs::read(path_a).expect("Can not read dumped traces b");
|
||||
// let path_b = PathBuf::from(args[2].clone());
|
||||
let input_path = conf.input_trace;
|
||||
let raw_input = fs::read(input_path).expect("Can not read dumped traces");
|
||||
|
||||
let trace : Vec<RefinedFreeRTOSSystemState> = ron::from_str(&String::from_utf8_lossy(&raw_a)).expect("Can not parse HashMap");
|
||||
let activation_path = conf.activation;
|
||||
let instance_path = conf.response;
|
||||
|
||||
println!("start,end,name");
|
||||
for s in trace {
|
||||
if s.current_task.task_name == "Tmr Svc" {continue;}
|
||||
println!("{},{},{}",s.start_tick,s.end_tick,s.current_task.task_name);
|
||||
let mut activation_file = activation_path.map(|x| std::fs::OpenOptions::new()
|
||||
.read(false)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.append(false)
|
||||
.open(x).expect("Could not create file"));
|
||||
|
||||
let mut level_per_task : HashMap<&String, u32> = HashMap::new();
|
||||
|
||||
|
||||
let trace : (Vec<ExecInterval>, HashMap<u64, ReducedFreeRTOSSystemState>, Vec<(u64, u64, String)>) = ron::from_str(&String::from_utf8_lossy(&raw_input)).expect("Can not parse HashMap");
|
||||
for s in &trace.0 {
|
||||
if s.level == 0 {
|
||||
level_per_task.insert(&trace.1[&s.start_state].current_task.task_name,trace.1[&s.start_state].current_task.priority);
|
||||
}
|
||||
}
|
||||
|
||||
let limits = conf.task.as_ref().map(|task| trace.2.iter().filter_map(move |x| if &x.2 == task {Some(x)} else {None}).max_by_key(|x| x.1-x.0)).flatten().map(|x| x.0..x.1);
|
||||
if let Some(limits) = &limits {
|
||||
println!("Limits: {} - {}",limits.start,limits.end);
|
||||
}
|
||||
|
||||
activation_file.as_mut().map(|x| writeln!(x,"start,end,prio,name").expect("Could not write to file"));
|
||||
for s in trace.0 {
|
||||
if limits.as_ref().map(|x| !x.contains(&s.start_tick) && !x.contains(&s.end_tick) ).unwrap_or(false) {
|
||||
continue;
|
||||
}
|
||||
if s.level == 0 {
|
||||
activation_file.as_mut().map(|x| writeln!(x,"{},{},{},{}",s.start_tick,s.end_tick,trace.1[&s.start_state].current_task.priority,trace.1[&s.start_state].current_task.task_name).expect("Could not write to file"));
|
||||
} else {
|
||||
activation_file.as_mut().map(|x| writeln!(x,"{},{},-{},{}",s.start_tick,s.end_tick,s.level,s.start_capture.1).expect("Could not write to file"));
|
||||
}
|
||||
}
|
||||
|
||||
let instance_file = instance_path.map(|x| std::fs::OpenOptions::new()
|
||||
.read(false)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.append(false)
|
||||
.open(x).expect("Could not create file"));
|
||||
|
||||
if let Some(mut file) = instance_file {
|
||||
writeln!(file,"start,end,prio,name").expect("Could not write to file");
|
||||
for s in trace.2 {
|
||||
if limits.as_ref().map(|x| !x.contains(&s.0) && !x.contains(&s.1) ).unwrap_or(false) {
|
||||
continue;
|
||||
}
|
||||
writeln!(file,"{},{},{},{}",s.0,s.1,level_per_task[&s.2],s.2).expect("Could not write to file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user