]>
git.saurik.com Git - apple/xnu.git/blob - tools/tests/libMicro/memset.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 static long long opts
= DEFS
;
48 static char *optas
= "4k";
59 lm_tsdsize
= sizeof (tsd_t
);
61 (void) sprintf(lm_optstr
, "a:us:");
63 (void) sprintf(lm_usage
,
64 " [-s buffer-size (default %d)]\n"
65 " [-a alignment (force buffer alignment)]\n"
66 " [-u (try to always use uncached memory)]"
67 "notes: measures memset()\n",
70 (void) sprintf(lm_header
, "%8s%16s", "size", "alignment");
76 benchmark_optswitch(int opt
, char *optarg
)
83 opts
= sizetoll(optarg
);
86 opta
= sizetoll(optarg
);
99 benchmark_initworker(void *tsd
)
101 tsd_t
*ts
= (tsd_t
*)tsd
;
106 ts
->ts_size
= 1024 * 1024 * 64;
107 ts
->ts_offset
= opta
;
109 ts
->ts_size
= opta
+ opts
;
110 ts
->ts_offset
= opta
;
113 if ((ts
->ts_buff
= (char *)valloc(ts
->ts_size
)) == NULL
)
116 for (i
= 0; i
< ts
->ts_size
; i
++)
123 benchmark(void *tsd
, result_t
*res
)
126 tsd_t
*ts
= (tsd_t
*)tsd
;
130 char *buf
= ts
->ts_buff
+ ts
->ts_offset
;
131 char *end
= ts
->ts_buff
+ ts
->ts_size
;
132 int offset
= ts
->ts_offset
;
136 for (i
= 0; i
< lm_optB
; i
++) {
137 (void) memset(buf
, 0, opts
);
138 tmp
= (((unsigned long)buf
+ opts
+ 4095) & ~4095) + offset
;
140 if (buf
+ opts
> end
)
141 buf
= ts
->ts_buff
+ offset
;
144 char *buf
= ts
->ts_buff
+ ts
->ts_offset
;
146 for (i
= 0; i
< lm_optB
; i
+= 10) {
147 (void) memset(buf
, 0, opts
);
148 (void) memset(buf
, 0, opts
);
149 (void) memset(buf
, 0, opts
);
150 (void) memset(buf
, 0, opts
);
151 (void) memset(buf
, 0, opts
);
152 (void) memset(buf
, 0, opts
);
153 (void) memset(buf
, 0, opts
);
154 (void) memset(buf
, 0, opts
);
155 (void) memset(buf
, 0, opts
);
156 (void) memset(buf
, 0, opts
);
167 static char result
[256];
169 (void) sprintf(result
, "%8lld%12s", opts
, optas
);