Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ext/stackprof/stackprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <pthread.h>

#define BUF_SIZE 2048
#define MICROSECONDS_IN_SECOND 1000000

typedef struct {
size_t total_samples;
Expand Down Expand Up @@ -497,7 +498,7 @@ stackprof_record_sample()
struct timeval diff;
gettimeofday(&t, NULL);
timersub(&t, &_stackprof.last_sample_at, &diff);
timestamp_delta = (1000 * diff.tv_sec) + diff.tv_usec;
timestamp_delta = (MICROSECONDS_IN_SECOND * diff.tv_sec) + diff.tv_usec;
}
num = rb_profile_frames(0, sizeof(_stackprof.frames_buffer) / sizeof(VALUE), _stackprof.frames_buffer, _stackprof.lines_buffer);
stackprof_record_sample_for_stack(num, timestamp_delta);
Expand All @@ -516,7 +517,7 @@ stackprof_record_gc_samples()

// We don't know when the GC samples were actually marked, so let's
// assume that they were marked at a perfectly regular interval.
delta_to_first_unrecorded_gc_sample = (1000 * diff.tv_sec + diff.tv_usec) - (_stackprof.unrecorded_gc_samples - 1) * NUM2LONG(_stackprof.interval);
delta_to_first_unrecorded_gc_sample = (MICROSECONDS_IN_SECOND * diff.tv_sec + diff.tv_usec) - (_stackprof.unrecorded_gc_samples - 1) * NUM2LONG(_stackprof.interval);
if (delta_to_first_unrecorded_gc_sample < 0) {
delta_to_first_unrecorded_gc_sample = 0;
}
Expand Down