Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- union ticks
- {
- uint64_t t64;
- struct s32
- {
- uint32_t th,tl;
- } t32;
- };
- void step1(int LSpy) {
- union ticks start, end;
- int long unsigned i;
- int a = 1;
- int long unsigned liter = 10000;
- uint64_t max_result = 0;
- for (i = 0; i < liter * 10; ++i) {
- if ((i % LSpy) == 0) {
- a = 0;
- }
- }
- uint64_t result = 0;
- for (i = 0; i < liter; ++i) {
- asm("rdtsc\n\t":"=a"(start.t32.th),"=d"(start.t32.tl));
- if ((i % LSpy) == 0) {
- a = 0;
- asm("rdtsc\n\t":"=a"(end.t32.th),"=d"(end.t32.tl));
- result = end.t64-start.t64;
- }
- else a=1;
- }
- printf("%d %lu\n", LSpy, result);
- }
- int main() {
- int testsAmount = 512;
- for (int i = 1; i <= testsAmount; ++i) {
- step1(i);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement