-$PostgreSQL: pgsql/contrib/pgbench/README.pgbench,v 1.19 2007/07/06 13:36:55 wieck Exp $
+$PostgreSQL: pgsql/contrib/pgbench/README.pgbench,v 1.20 2007/07/06 20:17:02 wieck Exp $
pgbench README
Variables can also be defined by using -D option.
- \usleep usec
+ \sleep num [us|ms|s]
- causes script execution to sleep for the specified duration in
- microseconds.
+ causes script execution to sleep for the specified duration of
+ microseconds (us), milliseconds (ms) or the default seconds (s).
example:
- \setrandom usec 1000000 3000000
- \usleep :usec
+ \setrandom millisec 1000 2500
+ \sleep :millisec ms
Example, TPC-B like benchmark can be defined as follows(scaling
factor = 1):
/*
- * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.67 2007/07/06 13:36:55 wieck Exp $
+ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.68 2007/07/06 20:17:02 wieck Exp $
*
* pgbench: a simple benchmark program for PostgreSQL
* written by Tatsuo Ishii
st->listen = 1;
}
- else if (pg_strcasecmp(argv[0], "usleep") == 0)
+ else if (pg_strcasecmp(argv[0], "sleep") == 0)
{
char *var;
int usec;
else
usec = atoi(argv[1]);
+ if (argc > 2)
+ {
+ if (pg_strcasecmp(argv[2], "ms") == 0)
+ usec *= 1000;
+ else if (pg_strcasecmp(argv[2], "s") == 0)
+ usec *= 1000000;
+ }
+ else
+ usec *= 1000000;
+
gettimeofday(&now, NULL);
st->until.tv_sec = now.tv_sec + (now.tv_usec + usec) / 1000000;
st->until.tv_usec = (now.tv_usec + usec) % 1000000;
fprintf(stderr, "%s: extra argument \"%s\" ignored\n",
my_commands->argv[0], my_commands->argv[j]);
}
- else if (pg_strcasecmp(my_commands->argv[0], "usleep") == 0)
+ else if (pg_strcasecmp(my_commands->argv[0], "sleep") == 0)
{
if (my_commands->argc < 2)
{
return NULL;
}
- for (j = 2; j < my_commands->argc; j++)
+ if (my_commands->argc >= 3)
+ {
+ if (pg_strcasecmp(my_commands->argv[2], "us") != 0 &&
+ pg_strcasecmp(my_commands->argv[2], "ms") != 0 &&
+ pg_strcasecmp(my_commands->argv[2], "s"))
+ {
+ fprintf(stderr, "%s: unknown time unit '%s' - must be us, ms or s\n",
+ my_commands->argv[0], my_commands->argv[2]);
+ return NULL;
+ }
+ }
+
+ for (j = 3; j < my_commands->argc; j++)
fprintf(stderr, "%s: extra argument \"%s\" ignored\n",
my_commands->argv[0], my_commands->argv[j]);
}