Skip to content

Commit

Permalink
Add feature Use std::chrono instead of clock_gettime
Browse files Browse the repository at this point in the history
  • Loading branch information
NobinPegasus committed Apr 19, 2024
1 parent a5e4aa4 commit a370968
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions daemon/user/bpf_tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static int handle_event_rb(void *ctx, void *data, size_t data_sz)
}

// Function to get current time in nanoseconds using std::chrono
long long getCurrentTimeInNanoseconds() {
long long get_current_time_ns() {
auto now = std::chrono::steady_clock::now();
auto ns = std::chrono::time_point_cast<std::chrono::nanoseconds>(now);
return ns.time_since_epoch().count();
Expand Down Expand Up @@ -93,11 +93,11 @@ static int process_exec_maps(bpf_event_handler *handler, bpf_tracer_bpf *obj,
if (res != 0) {
continue;
}
// struct timespec ts;

long long current_nanoseconds;
long start_time_ms;
// Get current time in nanoseconds
current_nanoseconds = getCurrentTimeInNanoseconds();
current_nanoseconds = get_current_time_ns();

start_time_ms =
(current_nanoseconds - e.exec_data.time_ns) / 1000000;
Expand Down

0 comments on commit a370968

Please sign in to comment.