Changed new \usleep command into \sleep with an optional time unit
argument to specify us, ms or s. As per suggestion by Peter E. Jan
This commit is contained in:
parent
0f17da9b3e
commit
9fbcf6625e
@ -1,4 +1,4 @@
|
||||
$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
|
||||
|
||||
@ -231,15 +231,15 @@ o -f option
|
||||
|
||||
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):
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $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
|
||||
@ -727,7 +727,7 @@ top:
|
||||
|
||||
st->listen = 1;
|
||||
}
|
||||
else if (pg_strcasecmp(argv[0], "usleep") == 0)
|
||||
else if (pg_strcasecmp(argv[0], "sleep") == 0)
|
||||
{
|
||||
char *var;
|
||||
int usec;
|
||||
@ -746,6 +746,16 @@ top:
|
||||
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;
|
||||
@ -963,7 +973,7 @@ process_commands(char *buf)
|
||||
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)
|
||||
{
|
||||
@ -971,7 +981,19 @@ process_commands(char *buf)
|
||||
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]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user