xref: /kvm-unit-tests/x86/tsc.c (revision a322d4c597bb7a4de7985e7b51b80504f7e4fdda)
1 #include "libcflat.h"
2 #include "processor.h"
3 
4 void test_wrtsc(u64 t1)
5 {
6 	u64 t2;
7 
8 	wrtsc(t1);
9 	t2 = rdtsc();
10 	printf("rdtsc after wrtsc(%lld): %lld\n", t1, t2);
11 }
12 
13 int main()
14 {
15 	u64 t1, t2;
16 
17 	t1 = rdtsc();
18 	t2 = rdtsc();
19 	printf("rdtsc latency %lld\n", (unsigned)(t2 - t1));
20 
21 	test_wrtsc(0);
22 	test_wrtsc(100000000000ull);
23 	return 0;
24 }
25