Skip to content

Commit

Permalink
Move ts calculation closer to when the bpf prog is actually read from…
Browse files Browse the repository at this point in the history
… libbpf
  • Loading branch information
jfernandez committed Feb 14, 2024
1 parent 1fbe596 commit 194603c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,14 @@ impl App {

let iter = ProgInfoIter::default();
for prog in iter {
let timestamp_ns = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_nanos();

let prog_name = prog.name.to_str().unwrap().to_string();

if prog_name.is_empty() {
continue;
}

let duration_since_epoch = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap();
let timestamp_nanos = duration_since_epoch.as_nanos();

let mut bpf_program = BpfProgram {
id: prog.id.to_string(),
bpf_type: prog.ty.to_string(),
Expand All @@ -102,8 +101,8 @@ impl App {
prev_run_cnt: 0,
run_cnt: prog.run_cnt,
prev_timestamp_ns: 0,
timestamp_ns: timestamp_nanos,
num_cpus: num_cpus
timestamp_ns,
num_cpus
};

if let Some(prev_bpf_program) = map.get(&bpf_program.id) {
Expand Down

0 comments on commit 194603c

Please sign in to comment.