-
Notifications
You must be signed in to change notification settings - Fork 142
/
perf_dupdrop.c
33 lines (26 loc) · 935 Bytes
/
perf_dupdrop.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* Ideal DUP DROP * 1000 assuming perfect inlining.
$Id: perf_dupdrop.c,v 1.1 2007-10-10 13:01:05 rich Exp $
*/
#include <stdio.h>
#include <stdlib.h>
#define DUP \
asm volatile ("mov (%%esp),%%eax\n" \
"\tpush %%eax" \
: : : "eax")
#define DROP \
asm volatile ("pop %%eax" \
: : : "eax")
#define DUPDROP DUP; DROP;
#define DUPDROP10 DUPDROP DUPDROP DUPDROP DUPDROP DUPDROP DUPDROP DUPDROP DUPDROP DUPDROP DUPDROP
#define DUPDROP100 DUPDROP10 DUPDROP10 DUPDROP10 DUPDROP10 DUPDROP10 DUPDROP10 DUPDROP10 DUPDROP10 DUPDROP10 DUPDROP10
#define DUPDROP1000 DUPDROP100 DUPDROP100 DUPDROP100 DUPDROP100 DUPDROP100 DUPDROP100 DUPDROP100 DUPDROP100 DUPDROP100 DUPDROP100
int
main (int argc, char *argv[])
{
unsigned long long start_time, end_time;
asm volatile ("rdtsc" : "=A" (start_time));
DUPDROP1000
asm volatile ("rdtsc" : "=A" (end_time));
printf ("%llu\n", end_time - start_time);
exit (0);
}