/* Copyright (C) by Andrew Tridgell 1999, 2001 Copyright (C) 2001 by Martin Pool This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* TODO: We could try allowing for different flavours of synchronous operation: data sync and so on. Linux apparently doesn't make any distinction, however, and for practical purposes it probably doesn't matter. On NFSv4 it might be interesting, since the client can choose what kind it wants for each OPEN operation. */ #include "dbench.h" int sync_open = 0, sync_dirs = 0; char *tcp_options = TCP_OPTIONS; static int timelimit = 600, warmup; static const char *directory = "."; static char *loadfile = DATADIR "/client.txt"; static struct timeval tv_start; static struct timeval tv_end; #if HAVE_EA_SUPPORT int ea_enable=0; #endif static FILE *open_loadfile(void) { FILE *f; if ((f = fopen(loadfile, "rt")) != NULL) return f; fprintf(stderr, "dbench: error opening '%s': %s\n", loadfile, strerror(errno)); return NULL; } static struct child_struct *children; static void sigcont(int sig) { (void)sig; } static void sig_alarm(int sig) { double total_bytes = 0; int total_lines = 0; int i; int nprocs = children[0].nprocs; int in_warmup = 0; double t; static int in_cleanup; (void)sig; for (i=0;i0 && t > warmup) { tv_start = timeval_current(); warmup = 0; for (i=0;i timelimit) { for (i=0;i\n" \ "options:\n" \ " -v show version\n" \ " -t timelimit run time in seconds (default 600)\n" \ " -D directory base directory to run in\n" \ " -c loadfile set location of the loadfile\n" \ " -s synchronous file IO\n" \ " -S synchronous directories (mkdir, unlink...)\n" \ " -x enable EA support\n" \ " -T options set socket options for tbench\n"); exit(1); } static int process_opts(int argc, char **argv, int *nprocs) { int c; extern int sync_open; extern char *server; while ((c = getopt(argc, argv, "vc:sST:t:xD:")) != -1) switch (c) { case 'c': loadfile = optarg; break; case 's': sync_open = 1; break; case 'S': sync_dirs = 1; break; case 'T': tcp_options = optarg; break; case 't': timelimit = atoi(optarg); break; case 'D': directory = optarg; break; case 'v': exit(0); break; case 'x': #if HAVE_EA_SUPPORT ea_enable = 1; #else printf("EA suppport not compiled in\n"); exit(1); #endif break; case '?': if (isprint (optopt)) fprintf (stderr, "Unknown option `-%c'.\n", optopt); else fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt); return 0; default: abort (); } if (!argv[optind]) return 0; *nprocs = atoi(argv[optind++]); if (argv[optind]) server = argv[optind++]; return 1; } int main(int argc, char *argv[]) { int nprocs; double total_bytes = 0; double t; int i; printf("dbench version %s - Copyright Andrew Tridgell 1999-2004\n\n", VERSION); if (!process_opts(argc, argv, &nprocs)) show_usage(); warmup = timelimit / 5; printf("Running for %d seconds with load '%s' and minimum warmup %d secs\n", timelimit, loadfile, warmup); create_procs(nprocs, child_run); for (i=0;i