Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
klee_tutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Edvin Åkerfeldt
klee_tutorial
Commits
73d4b319
Commit
73d4b319
authored
4 years ago
by
Edvin Åkerfeldt
Browse files
Options
Downloads
Patches
Plain Diff
Started implementation of the cli stuff
parent
ef19c8cd
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
srp_analysis/Cargo.toml
+6
-0
6 additions, 0 deletions
srp_analysis/Cargo.toml
srp_analysis/src/common.rs
+3
-2
3 additions, 2 deletions
srp_analysis/src/common.rs
srp_analysis/src/main.rs
+122
-1
122 additions, 1 deletion
srp_analysis/src/main.rs
with
131 additions
and
3 deletions
srp_analysis/Cargo.toml
+
6
−
0
View file @
73d4b319
...
@@ -7,3 +7,9 @@ edition = "2018"
...
@@ -7,3 +7,9 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[dependencies]
serde
=
{
version
=
"1.0"
,
features
=
[
"derive"
]
}
serde_json
=
"1.0"
structopt
=
{
version
=
"0.3"
,
features
=
[
"paw"
]
}
paw
=
"1.0"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
srp_analysis/src/common.rs
+
3
−
2
View file @
73d4b319
use
std
::
collections
::{
HashMap
,
HashSet
};
use
std
::
collections
::{
HashMap
,
HashSet
};
use
serde
::{
Serialize
,
Deserialize
};
// common data structures
// common data structures
#[derive(Debug)]
#[derive(
Serialize,
Deserialize,
Debug)]
pub
struct
Task
{
pub
struct
Task
{
pub
id
:
String
,
pub
id
:
String
,
pub
prio
:
u8
,
pub
prio
:
u8
,
...
@@ -18,7 +19,7 @@ impl Task {
...
@@ -18,7 +19,7 @@ impl Task {
}
}
//#[derive(Debug, Clone)]
//#[derive(Debug, Clone)]
#[derive(Debug,
Clone)]
#[derive(
Serialize,
Deserialize,
Debug,
Clone)]
pub
struct
Trace
{
pub
struct
Trace
{
pub
id
:
String
,
pub
id
:
String
,
pub
start
:
u32
,
pub
start
:
u32
,
...
...
This diff is collapsed.
Click to expand it.
srp_analysis/src/main.rs
+
122
−
1
View file @
73d4b319
mod
common
;
pub
mod
common
;
pub
mod
aux
;
use
std
::
path
::
PathBuf
;
use
structopt
::
StructOpt
;
use
common
::
*
;
use
common
::
*
;
use
aux
::
*
;
/// A basic example
#[derive(StructOpt,
Debug)]
#[structopt(name
=
"srp_analysis"
,
about
=
"asdasdasdasd"
)]
struct
Opt
{
// A flag, true if used in the command line. Note doc comment will
// be used for the help message of the flag. The name of the
// argument will be, by default, based on the name of the field.
/// Use approximation
#[structopt(name
=
"approximate"
,
long)]
approx_bp
:
bool
,
/// Generate an example file
#[structopt(long)]
//
generate
:
bool
,
/// Output file for generated example
#[structopt(short,
long,
parse(from_os_str))]
output
:
Option
<
PathBuf
>
,
/// Output file for generated example
#[structopt(short,
long,
parse(from_os_str),
required_unless
=
"generate"
)]
input
:
Option
<
PathBuf
>
,
}
// The number of occurrences of the `v/verbose` flag
/// Verbose mode (-v, -vv, -vvv, etc.)
//#[structopt(short, long, parse(from_occurrences))]
//verbose: u8,
/// Set speed
//#[structopt(short, long, default_value = "42")]
//speed: f64,
// the long option will be translated by default to kebab case,
// i.e. `--nb-cars`.
/// Number of cars
//#[structopt(short = "c", long)]
//nb_cars: Option<i32>,
/// admin_level to consider
//#[structopt(short, long)]
//level: Vec<String>,
/// Files to process
//#[structopt(name = "FILE", parse(from_os_str))]
//files: Vec<PathBuf>,
fn
main
()
{
fn
main
()
{
let
t1
=
Task
{
let
t1
=
Task
{
...
@@ -67,10 +126,72 @@ fn main() {
...
@@ -67,10 +126,72 @@ fn main() {
// builds a vector of tasks t1, t2, t3
// builds a vector of tasks t1, t2, t3
let
tasks
:
Tasks
=
vec!
[
t1
,
t2
,
t3
];
let
tasks
:
Tasks
=
vec!
[
t1
,
t2
,
t3
];
// Example for running
// cargo run -- --generate_example -o hej.json
// cargo run -- -i hej.json --approximate
// cargo run -- --help
let
opt
=
Opt
::
from_args
();
//println!("{:?}", opt);
if
opt
.generate
{
// Convert the Point to a JSON string.
let
serialized
=
serde_json
::
to_string
(
&
tasks
)
.unwrap
();
// Prints serialized = {"x":1,"y":2}
if
let
Some
(
output_file
)
=
opt
.output
{
println!
(
"Saving example file to: {:?}"
,
output_file
);
}
else
{
println!
(
"{}"
,
serialized
);
}
// Convert the JSON string back to a Point.
//let deserialized: [Task; 3] = serde_json::from_str(&serialized).unwrap();
// Prints deserialized = Point { x: 1, y: 2 }
//println!("deserialized = {:?}", deserialized);
return
;
}
//let input_file = opt.input.unwrap(); // Let it panic, if it has reached this stage we've fucked up our StructOpt config
println!
(
"tasks {:?}"
,
&
tasks
);
println!
(
"tasks {:?}"
,
&
tasks
);
// println!("tot_util {}", tot_util(&tasks));
// println!("tot_util {}", tot_util(&tasks));
let
(
ip
,
tr
)
=
pre_analysis
(
&
tasks
);
let
(
ip
,
tr
)
=
pre_analysis
(
&
tasks
);
println!
(
"ip: {:?}"
,
ip
);
println!
(
"ip: {:?}"
,
ip
);
println!
(
"tr: {:?}"
,
tr
);
println!
(
"tr: {:?}"
,
tr
);
let
_approximate_bp
=
false
;
println!
(
"=== Running analysis ==="
);
for
t
in
tasks
.iter
()
{
println!
(
"-> {:?}"
,
&
t
.id
);
println!
(
":: Response time (safe approx) = {:?}"
,
response_time
(
&
t
,
&
tasks
,
true
)
.unwrap
());
println!
(
":: Preemption time (safe approx) = {:?}"
,
preemption_time
(
&
t
,
&
tasks
,
true
)
.unwrap
());
match
response_time
(
&
t
,
&
tasks
,
false
)
{
Ok
(
re
)
=>
println!
(
":: Response time (realistic) = {:?}"
,
re
),
Err
(
_
)
=>
println!
(
":: Response time (realistic) = INCONC"
)
}
match
preemption_time
(
&
t
,
&
tasks
,
false
)
{
Ok
(
re
)
=>
println!
(
":: Preemption time (realistic) = {:?}"
,
re
),
Err
(
_
)
=>
println!
(
":: Preemption time (realistic) = INCONC"
)
}
println!
(
":: Blocking time = {:?}"
,
blocking_time
(
&
t
,
&
tasks
));
println!
(
":: WCET = {:?}"
,
t
.get_wcet
());
println!
(
""
);
}
println!
(
"{:?}"
,
times_as_vec
(
&
tasks
,
false
));
let
l
=
total_cpu_load
(
&
tasks
);
if
l
<=
1.0
{
println!
(
"Loadfactor: {:?} - OK"
,
l
)
}
else
{
println!
(
"Loadfactor: {:?} - FAILED"
,
l
)
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment