1 /*
2 * cld1.c
3 *
4 * $DragonFly: src/test/sysperf/cld1.c,v 1.1 2008/05/09 15:49:42 dillon Exp $
5 */
6
7 #include "blib.h"
8
9 static __attribute__ ((noinline)) void dummy_with_cld(void);
10 static __attribute__ ((noinline)) void dummy_without_cld(void);
11
12 int
main(int ac,char ** av)13 main(int ac, char **av)
14 {
15 long long count = 0;
16 long long max;
17 char c;
18 int j;
19
20 printf("timing the cld instruction\n");
21
22 start_timing();
23 while (stop_timing(0, NULL) == 0) {
24 for (j = 0; j < 100; ++j)
25 getuid();
26 count += 100;
27 }
28 max = count;
29 start_timing();
30 for (count = 0; count < max; count += 100) {
31 for (j = 0; j < 100; ++j)
32 dummy_without_cld();
33 }
34 stop_timing(count, "dummy() - without cld");
35
36 start_timing();
37 for (count = 0; count < max; count += 100) {
38 for (j = 0; j < 100; ++j)
39 dummy_with_cld();
40 }
41 stop_timing(count, "dummy() - with cld");
42 return(0);
43 }
44
45 static
46 __attribute__ ((noinline))
47 void
dummy_with_cld(void)48 dummy_with_cld(void)
49 {
50 volatile int i, j, k;
51
52 i = 0;
53 j = 0;
54 k = 0;
55 __asm __volatile("cld"::);
56 }
57
58 static
59 __attribute__ ((noinline))
60 void
dummy_without_cld(void)61 dummy_without_cld(void)
62 {
63 volatile int i, j, k;
64
65 i = 0;
66 j = 0;
67 k = 0;
68 }
69