Permalink
Browse files

Eliminate an integer division in trace_return().

  • Loading branch information...
bolinfest committed Sep 21, 2018
1 parent 5b7968a commit afa0e91e17939be80def67b224e761f5288d2d82
Showing with 3 additions and 2 deletions.
  1. +2 −1 opensnoop/opensnoop.c
  2. +1 −1 opensnoop/opensnoop.py
View
@@ -265,6 +265,7 @@ void printHeader() {
}
long long initialTimestamp = 0;
const float NANOS_PER_SECOND = 1000000000;
void perf_reader_raw_callback(void *cb_cookie, void *raw, int raw_size) {
struct data_t *event = (struct data_t *)raw;
if (opt_failed && event->ret >= 0) {
@@ -290,7 +291,7 @@ void perf_reader_raw_callback(void *cb_cookie, void *raw, int raw_size) {
}
long long delta = event->ts - initialTimestamp;
printf("%-14.9f", ((float) delta) / 1000000);
printf("%-14.9f", delta / NANOS_PER_SECOND);
}
int pid = event->id >> 32;
View
@@ -65,7 +65,7 @@
bpf_probe_read(&data.comm, sizeof(data.comm), valp->comm);
bpf_probe_read(&data.fname, sizeof(data.fname), (void *)valp->fname);
data.id = valp->id;
data.ts = tsp / 1000;
data.ts = tsp;
data.ret = PT_REGS_RC(ctx);
events.perf_submit(ctx, &data, sizeof(data));

0 comments on commit afa0e91

Please sign in to comment.