Index

lognestmonster / c5334b7

A general-purpose single-header C logging library and parser for event-based logs. (Incomplete)

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
20901 Dec 2020 11:43c5334b7UpdateJosh Stockin1160G

Blob @ lognestmonster / tests / rdtsc.c

text/plain323 bytesdownload raw
1#include <stdint.h>
2#include <stdio.h>
3
4uint64_t rdtsc(){
5 uint32_t lo,hi;
6 __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
7 return ((uint64_t)hi << 32) | lo;
8}
9
10int main() {
11 for (int i = 0; i < 100; i++) {
12 uint64_t a = rdtsc();
13 printf("%lu ticks\n", rdtsc() - a);
14 }
15 return 0;
16}
17