docs: use the stdarg.option entity in the popt.common.samba entity
[Samba/gebeck_regimport.git] / source3 / utils / status_profile.c
blobe01b1652abf940e1ca824d3ae1cf8da858a0a8d8
1 /*
2 * Unix SMB/CIFS implementation.
3 * status reporting
4 * Copyright (C) Andrew Tridgell 1994-1998
5 * Copyright (C) James Peach 2005-2006
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "smbprofile.h"
24 bool status_profile_dump(bool be_verbose);
25 bool status_profile_rates(bool be_verbose);
27 #ifdef WITH_PROFILE
28 static void profile_separator(const char * title)
30 char line[79 + 1];
31 char * end;
33 snprintf(line, sizeof(line), "**** %s ", title);
35 for (end = line + strlen(line); end < &line[sizeof(line) -1]; ++end) {
36 *end = '*';
39 line[sizeof(line) - 1] = '\0';
40 d_printf("%s\n", line);
42 #endif
44 /*******************************************************************
45 dump the elements of the profile structure
46 ******************************************************************/
47 bool status_profile_dump(bool verbose)
49 #ifdef WITH_PROFILE
50 if (!profile_setup(NULL, True)) {
51 fprintf(stderr,"Failed to initialise profile memory\n");
52 return False;
55 d_printf("smb_count: %u\n", profile_p->smb_count);
56 d_printf("uid_changes: %u\n", profile_p->uid_changes);
58 profile_separator("System Calls");
59 d_printf("opendir_count: %u\n", profile_p->syscall_opendir_count);
60 d_printf("opendir_time: %u\n", profile_p->syscall_opendir_time);
61 d_printf("fdopendir_count: %u\n", profile_p->syscall_fdopendir_count);
62 d_printf("fdopendir_time: %u\n", profile_p->syscall_fdopendir_time);
63 d_printf("readdir_count: %u\n", profile_p->syscall_readdir_count);
64 d_printf("readdir_time: %u\n", profile_p->syscall_readdir_time);
65 d_printf("mkdir_count: %u\n", profile_p->syscall_mkdir_count);
66 d_printf("mkdir_time: %u\n", profile_p->syscall_mkdir_time);
67 d_printf("rmdir_count: %u\n", profile_p->syscall_rmdir_count);
68 d_printf("rmdir_time: %u\n", profile_p->syscall_rmdir_time);
69 d_printf("closedir_count: %u\n", profile_p->syscall_closedir_count);
70 d_printf("closedir_time: %u\n", profile_p->syscall_closedir_time);
71 d_printf("open_count: %u\n", profile_p->syscall_open_count);
72 d_printf("open_time: %u\n", profile_p->syscall_open_time);
73 d_printf("close_count: %u\n", profile_p->syscall_close_count);
74 d_printf("close_time: %u\n", profile_p->syscall_close_time);
75 d_printf("read_count: %u\n", profile_p->syscall_read_count);
76 d_printf("read_time: %u\n", profile_p->syscall_read_time);
77 d_printf("read_bytes: %u\n", profile_p->syscall_read_bytes);
78 d_printf("write_count: %u\n", profile_p->syscall_write_count);
79 d_printf("write_time: %u\n", profile_p->syscall_write_time);
80 d_printf("write_bytes: %u\n", profile_p->syscall_write_bytes);
81 d_printf("pread_count: %u\n", profile_p->syscall_pread_count);
82 d_printf("pread_time: %u\n", profile_p->syscall_pread_time);
83 d_printf("pread_bytes: %u\n", profile_p->syscall_pread_bytes);
84 d_printf("pwrite_count: %u\n", profile_p->syscall_pwrite_count);
85 d_printf("pwrite_time: %u\n", profile_p->syscall_pwrite_time);
86 d_printf("pwrite_bytes: %u\n", profile_p->syscall_pwrite_bytes);
87 d_printf("sendfile_count: %u\n", profile_p->syscall_sendfile_count);
88 d_printf("sendfile_time: %u\n", profile_p->syscall_sendfile_time);
89 d_printf("sendfile_bytes: %u\n", profile_p->syscall_sendfile_bytes);
90 d_printf("lseek_count: %u\n", profile_p->syscall_lseek_count);
91 d_printf("lseek_time: %u\n", profile_p->syscall_lseek_time);
92 d_printf("rename_count: %u\n", profile_p->syscall_rename_count);
93 d_printf("rename_time: %u\n", profile_p->syscall_rename_time);
94 d_printf("fsync_count: %u\n", profile_p->syscall_fsync_count);
95 d_printf("fsync_time: %u\n", profile_p->syscall_fsync_time);
96 d_printf("stat_count: %u\n", profile_p->syscall_stat_count);
97 d_printf("stat_time: %u\n", profile_p->syscall_stat_time);
98 d_printf("fstat_count: %u\n", profile_p->syscall_fstat_count);
99 d_printf("fstat_time: %u\n", profile_p->syscall_fstat_time);
100 d_printf("lstat_count: %u\n", profile_p->syscall_lstat_count);
101 d_printf("lstat_time: %u\n", profile_p->syscall_lstat_time);
102 d_printf("unlink_count: %u\n", profile_p->syscall_unlink_count);
103 d_printf("unlink_time: %u\n", profile_p->syscall_unlink_time);
104 d_printf("chmod_count: %u\n", profile_p->syscall_chmod_count);
105 d_printf("chmod_time: %u\n", profile_p->syscall_chmod_time);
106 d_printf("fchmod_count: %u\n", profile_p->syscall_fchmod_count);
107 d_printf("fchmod_time: %u\n", profile_p->syscall_fchmod_time);
108 d_printf("chown_count: %u\n", profile_p->syscall_chown_count);
109 d_printf("chown_time: %u\n", profile_p->syscall_chown_time);
110 d_printf("fchown_count: %u\n", profile_p->syscall_fchown_count);
111 d_printf("fchown_time: %u\n", profile_p->syscall_fchown_time);
112 d_printf("chdir_count: %u\n", profile_p->syscall_chdir_count);
113 d_printf("chdir_time: %u\n", profile_p->syscall_chdir_time);
114 d_printf("getwd_count: %u\n", profile_p->syscall_getwd_count);
115 d_printf("getwd_time: %u\n", profile_p->syscall_getwd_time);
116 d_printf("ntimes_count: %u\n", profile_p->syscall_ntimes_count);
117 d_printf("ntimes_time: %u\n", profile_p->syscall_ntimes_time);
118 d_printf("ftruncate_count: %u\n", profile_p->syscall_ftruncate_count);
119 d_printf("ftruncate_time: %u\n", profile_p->syscall_ftruncate_time);
120 d_printf("fcntl_lock_count: %u\n", profile_p->syscall_fcntl_lock_count);
121 d_printf("fcntl_lock_time: %u\n", profile_p->syscall_fcntl_lock_time);
122 d_printf("readlink_count: %u\n", profile_p->syscall_readlink_count);
123 d_printf("readlink_time: %u\n", profile_p->syscall_readlink_time);
124 d_printf("symlink_count: %u\n", profile_p->syscall_symlink_count);
125 d_printf("symlink_time: %u\n", profile_p->syscall_symlink_time);
127 profile_separator("Stat Cache");
128 d_printf("lookups: %u\n", profile_p->statcache_lookups);
129 d_printf("misses: %u\n", profile_p->statcache_misses);
130 d_printf("hits: %u\n", profile_p->statcache_hits);
132 profile_separator("Write Cache");
133 d_printf("read_hits: %u\n", profile_p->writecache_read_hits);
134 d_printf("abutted_writes: %u\n", profile_p->writecache_abutted_writes);
135 d_printf("total_writes: %u\n", profile_p->writecache_total_writes);
136 d_printf("non_oplock_writes: %u\n", profile_p->writecache_non_oplock_writes);
137 d_printf("direct_writes: %u\n", profile_p->writecache_direct_writes);
138 d_printf("init_writes: %u\n", profile_p->writecache_init_writes);
139 d_printf("flushed_writes[SEEK]: %u\n", profile_p->writecache_flushed_writes[SEEK_FLUSH]);
140 d_printf("flushed_writes[READ]: %u\n", profile_p->writecache_flushed_writes[READ_FLUSH]);
141 d_printf("flushed_writes[WRITE]: %u\n", profile_p->writecache_flushed_writes[WRITE_FLUSH]);
142 d_printf("flushed_writes[READRAW]: %u\n", profile_p->writecache_flushed_writes[READRAW_FLUSH]);
143 d_printf("flushed_writes[OPLOCK_RELEASE]: %u\n", profile_p->writecache_flushed_writes[OPLOCK_RELEASE_FLUSH]);
144 d_printf("flushed_writes[CLOSE]: %u\n", profile_p->writecache_flushed_writes[CLOSE_FLUSH]);
145 d_printf("flushed_writes[SYNC]: %u\n", profile_p->writecache_flushed_writes[SYNC_FLUSH]);
146 d_printf("flushed_writes[SIZECHANGE]: %u\n", profile_p->writecache_flushed_writes[SIZECHANGE_FLUSH]);
147 d_printf("num_perfect_writes: %u\n", profile_p->writecache_num_perfect_writes);
148 d_printf("num_write_caches: %u\n", profile_p->writecache_num_write_caches);
149 d_printf("allocated_write_caches: %u\n", profile_p->writecache_allocated_write_caches);
151 profile_separator("SMB Calls");
152 d_printf("mkdir_count: %u\n", profile_p->SMBmkdir_count);
153 d_printf("mkdir_time: %u\n", profile_p->SMBmkdir_time);
154 d_printf("rmdir_count: %u\n", profile_p->SMBrmdir_count);
155 d_printf("rmdir_time: %u\n", profile_p->SMBrmdir_time);
156 d_printf("open_count: %u\n", profile_p->SMBopen_count);
157 d_printf("open_time: %u\n", profile_p->SMBopen_time);
158 d_printf("create_count: %u\n", profile_p->SMBcreate_count);
159 d_printf("create_time: %u\n", profile_p->SMBcreate_time);
160 d_printf("close_count: %u\n", profile_p->SMBclose_count);
161 d_printf("close_time: %u\n", profile_p->SMBclose_time);
162 d_printf("flush_count: %u\n", profile_p->SMBflush_count);
163 d_printf("flush_time: %u\n", profile_p->SMBflush_time);
164 d_printf("unlink_count: %u\n", profile_p->SMBunlink_count);
165 d_printf("unlink_time: %u\n", profile_p->SMBunlink_time);
166 d_printf("mv_count: %u\n", profile_p->SMBmv_count);
167 d_printf("mv_time: %u\n", profile_p->SMBmv_time);
168 d_printf("getatr_count: %u\n", profile_p->SMBgetatr_count);
169 d_printf("getatr_time: %u\n", profile_p->SMBgetatr_time);
170 d_printf("setatr_count: %u\n", profile_p->SMBsetatr_count);
171 d_printf("setatr_time: %u\n", profile_p->SMBsetatr_time);
172 d_printf("read_count: %u\n", profile_p->SMBread_count);
173 d_printf("read_time: %u\n", profile_p->SMBread_time);
174 d_printf("write_count: %u\n", profile_p->SMBwrite_count);
175 d_printf("write_time: %u\n", profile_p->SMBwrite_time);
176 d_printf("lock_count: %u\n", profile_p->SMBlock_count);
177 d_printf("lock_time: %u\n", profile_p->SMBlock_time);
178 d_printf("unlock_count: %u\n", profile_p->SMBunlock_count);
179 d_printf("unlock_time: %u\n", profile_p->SMBunlock_time);
180 d_printf("ctemp_count: %u\n", profile_p->SMBctemp_count);
181 d_printf("ctemp_time: %u\n", profile_p->SMBctemp_time);
182 d_printf("mknew_count: %u\n", profile_p->SMBmknew_count);
183 d_printf("mknew_time: %u\n", profile_p->SMBmknew_time);
184 d_printf("checkpath_count: %u\n", profile_p->SMBcheckpath_count);
185 d_printf("checkpath_time: %u\n", profile_p->SMBcheckpath_time);
186 d_printf("exit_count: %u\n", profile_p->SMBexit_count);
187 d_printf("exit_time: %u\n", profile_p->SMBexit_time);
188 d_printf("lseek_count: %u\n", profile_p->SMBlseek_count);
189 d_printf("lseek_time: %u\n", profile_p->SMBlseek_time);
190 d_printf("lockread_count: %u\n", profile_p->SMBlockread_count);
191 d_printf("lockread_time: %u\n", profile_p->SMBlockread_time);
192 d_printf("writeunlock_count: %u\n", profile_p->SMBwriteunlock_count);
193 d_printf("writeunlock_time: %u\n", profile_p->SMBwriteunlock_time);
194 d_printf("readbraw_count: %u\n", profile_p->SMBreadbraw_count);
195 d_printf("readbraw_time: %u\n", profile_p->SMBreadbraw_time);
196 d_printf("readBmpx_count: %u\n", profile_p->SMBreadBmpx_count);
197 d_printf("readBmpx_time: %u\n", profile_p->SMBreadBmpx_time);
198 d_printf("readBs_count: %u\n", profile_p->SMBreadBs_count);
199 d_printf("readBs_time: %u\n", profile_p->SMBreadBs_time);
200 d_printf("writebraw_count: %u\n", profile_p->SMBwritebraw_count);
201 d_printf("writebraw_time: %u\n", profile_p->SMBwritebraw_time);
202 d_printf("writeBmpx_count: %u\n", profile_p->SMBwriteBmpx_count);
203 d_printf("writeBmpx_time: %u\n", profile_p->SMBwriteBmpx_time);
204 d_printf("writeBs_count: %u\n", profile_p->SMBwriteBs_count);
205 d_printf("writeBs_time: %u\n", profile_p->SMBwriteBs_time);
206 d_printf("writec_count: %u\n", profile_p->SMBwritec_count);
207 d_printf("writec_time: %u\n", profile_p->SMBwritec_time);
208 d_printf("setattrE_count: %u\n", profile_p->SMBsetattrE_count);
209 d_printf("setattrE_time: %u\n", profile_p->SMBsetattrE_time);
210 d_printf("getattrE_count: %u\n", profile_p->SMBgetattrE_count);
211 d_printf("getattrE_time: %u\n", profile_p->SMBgetattrE_time);
212 d_printf("lockingX_count: %u\n", profile_p->SMBlockingX_count);
213 d_printf("lockingX_time: %u\n", profile_p->SMBlockingX_time);
214 d_printf("trans_count: %u\n", profile_p->SMBtrans_count);
215 d_printf("trans_time: %u\n", profile_p->SMBtrans_time);
216 d_printf("transs_count: %u\n", profile_p->SMBtranss_count);
217 d_printf("transs_time: %u\n", profile_p->SMBtranss_time);
218 d_printf("ioctl_count: %u\n", profile_p->SMBioctl_count);
219 d_printf("ioctl_time: %u\n", profile_p->SMBioctl_time);
220 d_printf("ioctls_count: %u\n", profile_p->SMBioctls_count);
221 d_printf("ioctls_time: %u\n", profile_p->SMBioctls_time);
222 d_printf("copy_count: %u\n", profile_p->SMBcopy_count);
223 d_printf("copy_time: %u\n", profile_p->SMBcopy_time);
224 d_printf("move_count: %u\n", profile_p->SMBmove_count);
225 d_printf("move_time: %u\n", profile_p->SMBmove_time);
226 d_printf("echo_count: %u\n", profile_p->SMBecho_count);
227 d_printf("echo_time: %u\n", profile_p->SMBecho_time);
228 d_printf("writeclose_count: %u\n", profile_p->SMBwriteclose_count);
229 d_printf("writeclose_time: %u\n", profile_p->SMBwriteclose_time);
230 d_printf("openX_count: %u\n", profile_p->SMBopenX_count);
231 d_printf("openX_time: %u\n", profile_p->SMBopenX_time);
232 d_printf("readX_count: %u\n", profile_p->SMBreadX_count);
233 d_printf("readX_time: %u\n", profile_p->SMBreadX_time);
234 d_printf("writeX_count: %u\n", profile_p->SMBwriteX_count);
235 d_printf("writeX_time: %u\n", profile_p->SMBwriteX_time);
236 d_printf("trans2_count: %u\n", profile_p->SMBtrans2_count);
237 d_printf("trans2_time: %u\n", profile_p->SMBtrans2_time);
238 d_printf("transs2_count: %u\n", profile_p->SMBtranss2_count);
239 d_printf("transs2_time: %u\n", profile_p->SMBtranss2_time);
240 d_printf("findclose_count: %u\n", profile_p->SMBfindclose_count);
241 d_printf("findclose_time: %u\n", profile_p->SMBfindclose_time);
242 d_printf("findnclose_count: %u\n", profile_p->SMBfindnclose_count);
243 d_printf("findnclose_time: %u\n", profile_p->SMBfindnclose_time);
244 d_printf("tcon_count: %u\n", profile_p->SMBtcon_count);
245 d_printf("tcon_time: %u\n", profile_p->SMBtcon_time);
246 d_printf("tdis_count: %u\n", profile_p->SMBtdis_count);
247 d_printf("tdis_time: %u\n", profile_p->SMBtdis_time);
248 d_printf("negprot_count: %u\n", profile_p->SMBnegprot_count);
249 d_printf("negprot_time: %u\n", profile_p->SMBnegprot_time);
250 d_printf("sesssetupX_count: %u\n", profile_p->SMBsesssetupX_count);
251 d_printf("sesssetupX_time: %u\n", profile_p->SMBsesssetupX_time);
252 d_printf("ulogoffX_count: %u\n", profile_p->SMBulogoffX_count);
253 d_printf("ulogoffX_time: %u\n", profile_p->SMBulogoffX_time);
254 d_printf("tconX_count: %u\n", profile_p->SMBtconX_count);
255 d_printf("tconX_time: %u\n", profile_p->SMBtconX_time);
256 d_printf("dskattr_count: %u\n", profile_p->SMBdskattr_count);
257 d_printf("dskattr_time: %u\n", profile_p->SMBdskattr_time);
258 d_printf("search_count: %u\n", profile_p->SMBsearch_count);
259 d_printf("search_time: %u\n", profile_p->SMBsearch_time);
260 d_printf("ffirst_count: %u\n", profile_p->SMBffirst_count);
261 d_printf("ffirst_time: %u\n", profile_p->SMBffirst_time);
262 d_printf("funique_count: %u\n", profile_p->SMBfunique_count);
263 d_printf("funique_time: %u\n", profile_p->SMBfunique_time);
264 d_printf("fclose_count: %u\n", profile_p->SMBfclose_count);
265 d_printf("fclose_time: %u\n", profile_p->SMBfclose_time);
266 d_printf("nttrans_count: %u\n", profile_p->SMBnttrans_count);
267 d_printf("nttrans_time: %u\n", profile_p->SMBnttrans_time);
268 d_printf("nttranss_count: %u\n", profile_p->SMBnttranss_count);
269 d_printf("nttranss_time: %u\n", profile_p->SMBnttranss_time);
270 d_printf("ntcreateX_count: %u\n", profile_p->SMBntcreateX_count);
271 d_printf("ntcreateX_time: %u\n", profile_p->SMBntcreateX_time);
272 d_printf("ntcancel_count: %u\n", profile_p->SMBntcancel_count);
273 d_printf("ntcancel_time: %u\n", profile_p->SMBntcancel_time);
274 d_printf("splopen_count: %u\n", profile_p->SMBsplopen_count);
275 d_printf("splopen_time: %u\n", profile_p->SMBsplopen_time);
276 d_printf("splwr_count: %u\n", profile_p->SMBsplwr_count);
277 d_printf("splwr_time: %u\n", profile_p->SMBsplwr_time);
278 d_printf("splclose_count: %u\n", profile_p->SMBsplclose_count);
279 d_printf("splclose_time: %u\n", profile_p->SMBsplclose_time);
280 d_printf("splretq_count: %u\n", profile_p->SMBsplretq_count);
281 d_printf("splretq_time: %u\n", profile_p->SMBsplretq_time);
282 d_printf("sends_count: %u\n", profile_p->SMBsends_count);
283 d_printf("sends_time: %u\n", profile_p->SMBsends_time);
284 d_printf("sendb_count: %u\n", profile_p->SMBsendb_count);
285 d_printf("sendb_time: %u\n", profile_p->SMBsendb_time);
286 d_printf("fwdname_count: %u\n", profile_p->SMBfwdname_count);
287 d_printf("fwdname_time: %u\n", profile_p->SMBfwdname_time);
288 d_printf("cancelf_count: %u\n", profile_p->SMBcancelf_count);
289 d_printf("cancelf_time: %u\n", profile_p->SMBcancelf_time);
290 d_printf("getmac_count: %u\n", profile_p->SMBgetmac_count);
291 d_printf("getmac_time: %u\n", profile_p->SMBgetmac_time);
292 d_printf("sendstrt_count: %u\n", profile_p->SMBsendstrt_count);
293 d_printf("sendstrt_time: %u\n", profile_p->SMBsendstrt_time);
294 d_printf("sendend_count: %u\n", profile_p->SMBsendend_count);
295 d_printf("sendend_time: %u\n", profile_p->SMBsendend_time);
296 d_printf("sendtxt_count: %u\n", profile_p->SMBsendtxt_count);
297 d_printf("sendtxt_time: %u\n", profile_p->SMBsendtxt_time);
298 d_printf("invalid_count: %u\n", profile_p->SMBinvalid_count);
299 d_printf("invalid_time: %u\n", profile_p->SMBinvalid_time);
301 profile_separator("Pathworks Calls");
302 d_printf("setdir_count: %u\n", profile_p->pathworks_setdir_count);
303 d_printf("setdir_time: %u\n", profile_p->pathworks_setdir_time);
305 profile_separator("Trans2 Calls");
306 d_printf("open_count: %u\n", profile_p->Trans2_open_count);
307 d_printf("open_time: %u\n", profile_p->Trans2_open_time);
308 d_printf("findfirst_count: %u\n", profile_p->Trans2_findfirst_count);
309 d_printf("findfirst_time: %u\n", profile_p->Trans2_findfirst_time);
310 d_printf("findnext_count: %u\n", profile_p->Trans2_findnext_count);
311 d_printf("findnext_time: %u\n", profile_p->Trans2_findnext_time);
312 d_printf("qfsinfo_count: %u\n", profile_p->Trans2_qfsinfo_count);
313 d_printf("qfsinfo_time: %u\n", profile_p->Trans2_qfsinfo_time);
314 d_printf("setfsinfo_count: %u\n", profile_p->Trans2_setfsinfo_count);
315 d_printf("setfsinfo_time: %u\n", profile_p->Trans2_setfsinfo_time);
316 d_printf("qpathinfo_count: %u\n", profile_p->Trans2_qpathinfo_count);
317 d_printf("qpathinfo_time: %u\n", profile_p->Trans2_qpathinfo_time);
318 d_printf("setpathinfo_count: %u\n", profile_p->Trans2_setpathinfo_count);
319 d_printf("setpathinfo_time: %u\n", profile_p->Trans2_setpathinfo_time);
320 d_printf("qfileinfo_count: %u\n", profile_p->Trans2_qfileinfo_count);
321 d_printf("qfileinfo_time: %u\n", profile_p->Trans2_qfileinfo_time);
322 d_printf("setfileinfo_count: %u\n", profile_p->Trans2_setfileinfo_count);
323 d_printf("setfileinfo_time: %u\n", profile_p->Trans2_setfileinfo_time);
324 d_printf("fsctl_count: %u\n", profile_p->Trans2_fsctl_count);
325 d_printf("fsctl_time: %u\n", profile_p->Trans2_fsctl_time);
326 d_printf("ioctl_count: %u\n", profile_p->Trans2_ioctl_count);
327 d_printf("ioctl_time: %u\n", profile_p->Trans2_ioctl_time);
328 d_printf("findnotifyfirst_count: %u\n", profile_p->Trans2_findnotifyfirst_count);
329 d_printf("findnotifyfirst_time: %u\n", profile_p->Trans2_findnotifyfirst_time);
330 d_printf("findnotifynext_count: %u\n", profile_p->Trans2_findnotifynext_count);
331 d_printf("findnotifynext_time: %u\n", profile_p->Trans2_findnotifynext_time);
332 d_printf("mkdir_count: %u\n", profile_p->Trans2_mkdir_count);
333 d_printf("mkdir_time: %u\n", profile_p->Trans2_mkdir_time);
334 d_printf("session_setup_count: %u\n", profile_p->Trans2_session_setup_count);
335 d_printf("session_setup_time: %u\n", profile_p->Trans2_session_setup_time);
336 d_printf("get_dfs_referral_count: %u\n", profile_p->Trans2_get_dfs_referral_count);
337 d_printf("get_dfs_referral_time: %u\n", profile_p->Trans2_get_dfs_referral_time);
338 d_printf("report_dfs_inconsistancy_count: %u\n", profile_p->Trans2_report_dfs_inconsistancy_count);
339 d_printf("report_dfs_inconsistancy_time: %u\n", profile_p->Trans2_report_dfs_inconsistancy_time);
341 profile_separator("NT Transact Calls");
342 d_printf("create_count: %u\n", profile_p->NT_transact_create_count);
343 d_printf("create_time: %u\n", profile_p->NT_transact_create_time);
344 d_printf("ioctl_count: %u\n", profile_p->NT_transact_ioctl_count);
345 d_printf("ioctl_time: %u\n", profile_p->NT_transact_ioctl_time);
346 d_printf("set_security_desc_count: %u\n", profile_p->NT_transact_set_security_desc_count);
347 d_printf("set_security_desc_time: %u\n", profile_p->NT_transact_set_security_desc_time);
348 d_printf("notify_change_count: %u\n", profile_p->NT_transact_notify_change_count);
349 d_printf("notify_change_time: %u\n", profile_p->NT_transact_notify_change_time);
350 d_printf("rename_count: %u\n", profile_p->NT_transact_rename_count);
351 d_printf("rename_time: %u\n", profile_p->NT_transact_rename_time);
352 d_printf("query_security_desc_count: %u\n", profile_p->NT_transact_query_security_desc_count);
353 d_printf("query_security_desc_time: %u\n", profile_p->NT_transact_query_security_desc_time);
355 profile_separator("ACL Calls");
356 d_printf("get_nt_acl_count: %u\n", profile_p->get_nt_acl_count);
357 d_printf("get_nt_acl_time: %u\n", profile_p->get_nt_acl_time);
358 d_printf("fget_nt_acl_count: %u\n", profile_p->fget_nt_acl_count);
359 d_printf("fget_nt_acl_time: %u\n", profile_p->fget_nt_acl_time);
360 d_printf("fset_nt_acl_count: %u\n", profile_p->fset_nt_acl_count);
361 d_printf("fset_nt_acl_time: %u\n", profile_p->fset_nt_acl_time);
362 d_printf("chmod_acl_count: %u\n", profile_p->chmod_acl_count);
363 d_printf("chmod_acl_time: %u\n", profile_p->chmod_acl_time);
364 d_printf("fchmod_acl_count: %u\n", profile_p->fchmod_acl_count);
365 d_printf("fchmod_acl_time: %u\n", profile_p->fchmod_acl_time);
367 profile_separator("NMBD Calls");
368 d_printf("name_release_count: %u\n", profile_p->name_release_count);
369 d_printf("name_release_time: %u\n", profile_p->name_release_time);
370 d_printf("name_refresh_count: %u\n", profile_p->name_refresh_count);
371 d_printf("name_refresh_time: %u\n", profile_p->name_refresh_time);
372 d_printf("name_registration_count: %u\n", profile_p->name_registration_count);
373 d_printf("name_registration_time: %u\n", profile_p->name_registration_time);
374 d_printf("node_status_count: %u\n", profile_p->node_status_count);
375 d_printf("node_status_time: %u\n", profile_p->node_status_time);
376 d_printf("name_query_count: %u\n", profile_p->name_query_count);
377 d_printf("name_query_time: %u\n", profile_p->name_query_time);
378 d_printf("host_announce_count: %u\n", profile_p->host_announce_count);
379 d_printf("host_announce_time: %u\n", profile_p->host_announce_time);
380 d_printf("workgroup_announce_count: %u\n", profile_p->workgroup_announce_count);
381 d_printf("workgroup_announce_time: %u\n", profile_p->workgroup_announce_time);
382 d_printf("local_master_announce_count: %u\n", profile_p->local_master_announce_count);
383 d_printf("local_master_announce_time: %u\n", profile_p->local_master_announce_time);
384 d_printf("master_browser_announce_count: %u\n", profile_p->master_browser_announce_count);
385 d_printf("master_browser_announce_time: %u\n", profile_p->master_browser_announce_time);
386 d_printf("lm_host_announce_count: %u\n", profile_p->lm_host_announce_count);
387 d_printf("lm_host_announce_time: %u\n", profile_p->lm_host_announce_time);
388 d_printf("get_backup_list_count: %u\n", profile_p->get_backup_list_count);
389 d_printf("get_backup_list_time: %u\n", profile_p->get_backup_list_time);
390 d_printf("reset_browser_count: %u\n", profile_p->reset_browser_count);
391 d_printf("reset_browser_time: %u\n", profile_p->reset_browser_time);
392 d_printf("announce_request_count: %u\n", profile_p->announce_request_count);
393 d_printf("announce_request_time: %u\n", profile_p->announce_request_time);
394 d_printf("lm_announce_request_count: %u\n", profile_p->lm_announce_request_count);
395 d_printf("lm_announce_request_time: %u\n", profile_p->lm_announce_request_time);
396 d_printf("domain_logon_count: %u\n", profile_p->domain_logon_count);
397 d_printf("domain_logon_time: %u\n", profile_p->domain_logon_time);
398 d_printf("sync_browse_lists_count: %u\n", profile_p->sync_browse_lists_count);
399 d_printf("sync_browse_lists_time: %u\n", profile_p->sync_browse_lists_time);
400 d_printf("run_elections_count: %u\n", profile_p->run_elections_count);
401 d_printf("run_elections_time: %u\n", profile_p->run_elections_time);
402 d_printf("election_count: %u\n", profile_p->election_count);
403 d_printf("election_time: %u\n", profile_p->election_time);
404 profile_separator("SMB2 Calls");
405 d_printf("smb2_negprot_count: %u\n", profile_p->smb2_negprot_count);
406 d_printf("smb2_negprot_time: %u\n", profile_p->smb2_negprot_time);
407 d_printf("smb2_sesssetup_count: %u\n", profile_p->smb2_sesssetup_count);
408 d_printf("smb2_sesssetup_time: %u\n", profile_p->smb2_sesssetup_time);
409 d_printf("smb2_logoff_count: %u\n", profile_p->smb2_logoff_count);
410 d_printf("smb2_logoff_time: %u\n", profile_p->smb2_logoff_time);
411 d_printf("smb2_tcon_count: %u\n", profile_p->smb2_tcon_count);
412 d_printf("smb2_tcon_time: %u\n", profile_p->smb2_tcon_time);
413 d_printf("smb2_tdis_count: %u\n", profile_p->smb2_tdis_count);
414 d_printf("smb2_tdis_time: %u\n", profile_p->smb2_tdis_time);
415 d_printf("smb2_create_count: %u\n", profile_p->smb2_create_count);
416 d_printf("smb2_create_time: %u\n", profile_p->smb2_create_time);
417 d_printf("smb2_close_count: %u\n", profile_p->smb2_close_count);
418 d_printf("smb2_close_time: %u\n", profile_p->smb2_close_time);
419 d_printf("smb2_flush_count: %u\n", profile_p->smb2_flush_count);
420 d_printf("smb2_flush_time: %u\n", profile_p->smb2_flush_time);
421 d_printf("smb2_read_count: %u\n", profile_p->smb2_read_count);
422 d_printf("smb2_read_time: %u\n", profile_p->smb2_read_time);
423 d_printf("smb2_write_count: %u\n", profile_p->smb2_write_count);
424 d_printf("smb2_write_time: %u\n", profile_p->smb2_write_time);
425 d_printf("smb2_lock_count: %u\n", profile_p->smb2_lock_count);
426 d_printf("smb2_lock_time: %u\n", profile_p->smb2_lock_time);
427 d_printf("smb2_ioctl_count: %u\n", profile_p->smb2_ioctl_count);
428 d_printf("smb2_ioctl_time: %u\n", profile_p->smb2_ioctl_time);
429 d_printf("smb2_cancel_count: %u\n", profile_p->smb2_cancel_count);
430 d_printf("smb2_cancel_time: %u\n", profile_p->smb2_cancel_time);
431 d_printf("smb2_keepalive_count: %u\n", profile_p->smb2_keepalive_count);
432 d_printf("smb2_keepalive_time: %u\n", profile_p->smb2_keepalive_time);
433 d_printf("smb2_find_count: %u\n", profile_p->smb2_find_count);
434 d_printf("smb2_find_time: %u\n", profile_p->smb2_find_time);
435 d_printf("smb2_notify_count: %u\n", profile_p->smb2_notify_count);
436 d_printf("smb2_notify_time: %u\n", profile_p->smb2_notify_time);
437 d_printf("smb2_getinfo_count: %u\n", profile_p->smb2_getinfo_count);
438 d_printf("smb2_getinfo_time: %u\n", profile_p->smb2_getinfo_time);
439 d_printf("smb2_setinfo_count: %u\n", profile_p->smb2_setinfo_count);
440 d_printf("smb2_setinfo_time: %u\n", profile_p->smb2_setinfo_time);
441 d_printf("smb2_break_count: %u\n", profile_p->smb2_break_count);
442 d_printf("smb2_break_time: %u\n", profile_p->smb2_break_time);
444 #else /* WITH_PROFILE */
446 fprintf(stderr, "Profile data unavailable\n");
447 #endif /* WITH_PROFILE */
449 return True;
452 #ifdef WITH_PROFILE
454 /* Convert microseconds to milliseconds. */
455 #define usec_to_msec(s) ((s) / 1000)
456 /* Convert microseconds to seconds. */
457 #define usec_to_sec(s) ((s) / 1000000)
458 /* One second in microseconds. */
459 #define one_second_usec (1000000)
461 #define sample_interval_usec one_second_usec
463 #define percent_time(used, period) ((double)(used) / (double)(period) * 100.0 )
465 static int print_count_samples(
466 const struct profile_stats * const current,
467 const struct profile_stats * const last,
468 uint64_t delta_usec)
470 int i;
471 int count = 0;
472 unsigned step;
473 uint64_t spent;
474 int delta_sec;
475 const char * name;
476 char buf[40];
478 if (delta_usec == 0) {
479 return 0;
482 buf[0] = '\0';
483 delta_sec = usec_to_sec(delta_usec);
485 for (i = 0; i < PR_VALUE_MAX; ++i) {
486 step = current->count[i] - last->count[i];
487 spent = current->time[i] - last->time[i];
489 if (step) {
490 ++count;
492 name = profile_value_name(i);
494 if (buf[0] == '\0') {
495 snprintf(buf, sizeof(buf),
496 "%s %d/sec (%.2f%%)",
497 name, step / delta_sec,
498 percent_time(spent, delta_usec));
499 } else {
500 printf("%-40s %s %d/sec (%.2f%%)\n",
501 buf, name, step / delta_sec,
502 percent_time(spent, delta_usec));
503 buf[0] = '\0';
508 return count;
511 static struct profile_stats sample_data[2];
512 static uint64_t sample_time[2];
514 bool status_profile_rates(bool verbose)
516 uint64_t remain_usec;
517 uint64_t next_usec;
518 uint64_t delta_usec;
520 int last = 0;
521 int current = 1;
522 int tmp;
524 if (verbose) {
525 fprintf(stderr, "Sampling stats at %d sec intervals\n",
526 usec_to_sec(sample_interval_usec));
529 if (!profile_setup(NULL, True)) {
530 fprintf(stderr,"Failed to initialise profile memory\n");
531 return False;
534 memcpy(&sample_data[last], profile_p, sizeof(*profile_p));
535 for (;;) {
536 sample_time[current] = profile_timestamp();
537 next_usec = sample_time[current] + sample_interval_usec;
539 /* Take a sample. */
540 memcpy(&sample_data[current], profile_p, sizeof(*profile_p));
542 /* Rate convert some values and print results. */
543 delta_usec = sample_time[current] - sample_time[last];
545 if (print_count_samples(&sample_data[current],
546 &sample_data[last], delta_usec)) {
547 printf("\n");
550 /* Swap sampling buffers. */
551 tmp = last;
552 last = current;
553 current = tmp;
555 /* Delay until next sample time. */
556 remain_usec = next_usec - profile_timestamp();
557 if (remain_usec > sample_interval_usec) {
558 fprintf(stderr, "eek! falling behind sampling rate!\n");
559 } else {
560 if (verbose) {
561 fprintf(stderr,
562 "delaying for %lu msec\n",
563 (unsigned long )usec_to_msec(remain_usec));
566 usleep(remain_usec);
571 return True;
574 #else /* WITH_PROFILE */
576 bool status_profile_rates(bool verbose)
578 fprintf(stderr, "Profile data unavailable\n");
579 return False;
582 #endif /* WITH_PROFILE */