🎈 perf(clock_gettime): COARSE to reduce overhead

This commit is contained in:
yangwei
2024-08-01 03:00:27 +08:00
committed by luwenpeng
parent 2ff76d6598
commit a7837d6c93
3 changed files with 5 additions and 5 deletions

View File

@@ -37,7 +37,7 @@ static inline void calc_packet_fingerprint(struct fingerprint *finger)
{
#define RANGE(rand, start, end) (start + rand % (end - start + 1)) // [start, end]
struct timespec time;
clock_gettime(CLOCK_MONOTONIC, &time);
clock_gettime(CLOCK_MONOTONIC_COARSE, &time);
uint64_t random = 0x013579ABCDEF ^ time.tv_nsec;
finger->ip_id = (uint16_t)(RANGE(random, 32767, 65535));
finger->ip_ttl = (uint8_t)(RANGE(random, 48, 120));