1/*
2 * Copyright (c) 2006 Apple Inc.  All Rights Reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29
30/*
31 *	Order of Execution
32 *
33 *	benchmark_init
34 *
35 *	benchmark_optswitch
36 *
37 *		benchmark_initrun
38 *
39 *			benchmark_initworker
40 *				benchmark_initbatch
41 *					benchmark
42 *				benchmark_finibatch
43 *				benchmark_initbatch
44 *					benchmark
45 *				benchmark_finibatch, etc.
46 *			benchmark_finiworker
47 *
48 *		benchmark_result
49 *
50 *		benchmark_finirun
51 *
52 *	benchmark_fini
53 */
54
55
56
57#ifdef	__sun
58#pragma ident	"@(#)socket.c	1.3	05/08/04 Apple Inc."
59#endif
60
61
62
63#include <unistd.h>
64#include <stdlib.h>
65#include <stdio.h>
66
67#include "../libmicro.h"
68
69/*
70 *	Your state variables should live in the tsd_t struct below
71 */
72typedef struct {
73	int fd;
74	char* file;
75} tsd_t;
76
77/*ARGSUSED*/
78int
79benchmark_initbatch(void *tsd)
80{
81	return (0);
82}
83
84int
85benchmark_finirun()
86{
87	return (0);
88}
89
90int
91benchmark_init()
92{
93	/*
94	 *	the lm_optstr must be defined here or no options for you
95	 *
96	 * 	...and the framework will throw an error
97	 *
98	 */
99	(void) sprintf(lm_optstr, "t:");
100	/*
101	 *	working hypothesis:
102	 *
103	 * 	tsd_t is the struct that we can pass around our
104	 *	state info in
105	 *
106	 *	 will allocate the space we need for this
107	 *	structure throughout the rest of the framework
108	 */
109	lm_tsdsize = sizeof (tsd_t);
110
111	(void) sprintf(lm_usage,
112	    "       [-t int (default 1)]\n"
113	    "notes: measures nothing\n");
114	return (0);
115}
116
117int
118benchmark_fini()
119{
120	(void) fprintf(stderr, "benchmark_fini\n");
121	return (0);
122}
123
124int
125benchmark_finibatch(void *tsd)
126{
127	return (0);
128}
129
130char *
131benchmark_result()
132{
133	static char		result = '\0';
134	(void) fprintf(stderr, "null_call (getppid)\n");
135	return (&result);
136}
137
138int
139benchmark_finiworker(void *tsd)
140{
141	return (0);
142}
143
144int
145benchmark_optswitch(int opt, char *optarg)
146{
147	return (0);
148}
149
150int
151benchmark_initworker(void *tsd)
152{
153	/*
154	 *	initialize your state variables here first
155	 */
156	return (0);
157}
158
159int
160benchmark_initrun()
161{
162	return (0);
163}
164
165int
166benchmark(void *tsd, result_t *res)
167{
168	/*
169	 *	initialize your state variables here last
170	 *
171	 * 	and realize that you are paying for your initialization here
172	 *	and it is really a bad idea
173	 */
174	int			i;
175
176	for (i = 0; i < lm_optB; i++) {
177		/*
178		 *	just to show that ts really contains state
179		 */
180		getppid();
181	}
182	res->re_count = i;
183
184	return (0);
185}
186