]>
git.saurik.com Git - apple/xnu.git/blob - tools/tests/libMicro/writev.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.
39 #define IOV_MAX UIO_MAXIOV
50 #define DEFF "/dev/null"
54 static char *optf
= DEFF
;
55 static int opts
= DEFS
;
56 static int optv
= DEFV
;
61 lm_tsdsize
= sizeof (tsd_t
);
63 (void) sprintf(lm_optstr
, "f:s:v:");
65 (void) sprintf(lm_usage
,
66 " [-f file-to-write (default %s)]\n"
67 " [-s buffer-size (default %d)]\n"
68 " [-v vector-size (default %d)]\n"
69 "notes: measures writev()\n"
71 " SSIZE_MAX is %ld\n",
72 DEFF
, DEFS
, DEFV
, IOV_MAX
, SSIZE_MAX
);
74 (void) sprintf(lm_header
, "%8s %4s", "size", "vec");
82 benchmark_optswitch(int opt
, char *optarg
)
89 opts
= sizetoint(optarg
);
101 benchmark_initbatch(void *tsd
)
103 tsd_t
*ts
= (tsd_t
*)tsd
;
107 if (ts
->ts_once
++ == 0) {
108 ts
->ts_fd
= open(optf
, O_WRONLY
);
109 if (ts
->ts_fd
== -1) {
112 ts
->ts_iov
= (struct iovec
*)malloc(
113 optv
* sizeof (struct iovec
));
114 for (i
= 0; i
< optv
; i
++) {
115 ts
->ts_iov
[i
].iov_base
= malloc(opts
);
116 ts
->ts_iov
[i
].iov_len
= opts
;
120 (void) lseek(ts
->ts_fd
, 0, SEEK_SET
);
126 benchmark(void *tsd
, result_t
*res
)
128 tsd_t
*ts
= (tsd_t
*)tsd
;
131 for (i
= 0; i
< lm_optB
; i
++) {
132 if (writev(ts
->ts_fd
, ts
->ts_iov
, optv
) != opts
* optv
) {
144 static char result
[256];
146 (void) sprintf(result
, "%8d %4d", opts
, optv
);