]>
git.saurik.com Git - apple/xnu.git/blob - tools/tests/libMicro/tattle.c
4 * The contents of this file are subject to the terms
5 * of the Common Development and Distribution License
6 * (the "License"). You may not use this file except
7 * in compliance with the License.
9 * You can obtain a copy of the license at
10 * src/OPENSOLARIS.LICENSE
11 * or http://www.opensolaris.org/os/licensing.
12 * See the License for the specific language governing
13 * permissions and limitations under the License.
15 * When distributing Covered Code, include this CDDL
16 * HEADER in each file and include the License file at
17 * usr/src/OPENSOLARIS.LICENSE. If applicable,
18 * add the following below this CDDL HEADER, with the
19 * fields enclosed by brackets "[]" replaced with your
20 * own identifying information: Portions Copyright [yyyy]
21 * [name of copyright owner]
27 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
44 #define ENABLE_RDTSC 1
49 * dummy so we can link w/ libmicro
54 benchmark(void *tsd
, result_t
*res
)
78 while (*e
== ' ' && e
> o
)
85 main(int argc
, char *argv
[])
89 if (strlen(compiler_version
) > 30)
90 compiler_version
[30] = 0;
92 cleanup(compiler_version
);
93 cleanup(extra_compiler_flags
);
95 while ((c
= getopt(argc
, argv
, "vcfrsVTR")) != -1) {
98 (void) printf("%s\n", LIBMICRO_VERSION
);
101 (void) printf("%s\n", compiler_version
);
104 (void) printf("%s\n", CC
);
107 if (strlen(extra_compiler_flags
) == 0)
108 (void) printf("[none]\n");
110 (void) printf("%s\n", extra_compiler_flags
);
114 (void) printf("%d\n", sizeof (long));
119 (void) printf("%lld nsecs\n", get_nsecs_resolution());
127 long long start_nsecs
;
131 gettimeofday(&s
, NULL
);
132 start_nsecs
= rdtsc();
134 gettimeofday(&f
, NULL
);
135 elapsed_usecs
= (f
.tv_sec
- s
.tv_sec
) *
136 1000000 + (f
.tv_usec
- s
.tv_usec
);
137 if (elapsed_usecs
> 1000000)
141 (void) printf("LIBMICRO_HZ=%lld\n",
142 (long long)elapsed_usecs
*
143 (end_nsecs
- start_nsecs
) / 1000000LL);