Skip to content

Commit eea51d9

Browse files
committed
Update wtf_timer_inspection.cpp
1 parent 95dfb03 commit eea51d9

File tree

1 file changed

+1
-50
lines changed

1 file changed

+1
-50
lines changed
+1-50
Original file line numberDiff line numberDiff line change
@@ -1,50 +1 @@
1-
#include <pthread.h>
2-
#include <time.h>
3-
#include <assert.h>
4-
#include <inttypes.h>
5-
#include <stddef.h>
6-
#include <stdio.h>
7-
8-
static uint64_t last_asap_update = 0;
9-
static ssize_t generation = -1;
10-
11-
struct bun_timespec {
12-
ssize_t sec;
13-
ssize_t nsec;
14-
};
15-
16-
extern uint64_t wtf_timer_main_tid;
17-
18-
extern "C" {
19-
void WTFTimer__inspect_update(const void* timer, double seconds, bool repeat, const bun_timespec* ts)
20-
{
21-
uint64_t tid;
22-
pthread_tryjoin_np(nullptr, &tid);
23-
if (wtf_timer_main_tid != tid && ts->sec == 1024) {
24-
fprintf(stderr, "update %zd from off main, tid %" PRIu64 "\n", ts->nsec, tid);
25-
}
26-
27-
uint64_t now = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW);
28-
if (ts->sec == 1024) {
29-
if (generation != -1) {
30-
fprintf(stderr, "%zd never fired after %" PRIu64 " us\n", generation, (now - last_asap_update) / 1'000);
31-
}
32-
generation = ts->nsec;
33-
}
34-
35-
if (seconds == 0.0 && !repeat) {
36-
last_asap_update = now;
37-
}
38-
}
39-
40-
void WTFTimer__inspect_fire(const bun_timespec* ts)
41-
{
42-
if (ts->sec == 1024) {
43-
// asap
44-
generation = -1;
45-
uint64_t now = clock_gettime_nsec_np(_CLOCK_MONOTONIC_RAW);
46-
uint64_t diff = now - last_asap_update;
47-
fprintf(stderr, "asap timer %zd fired after %" PRIu64 " us\n", ts->nsec, diff / 1'000);
48-
}
49-
}
50-
}
1+
//

0 commit comments

Comments
 (0)