Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9fbcf66

Browse files
Jan WieckJan Wieck
Jan Wieck
authored and
Jan Wieck
committed
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
1 parent0f17da9 commit9fbcf66

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

‎contrib/pgbench/README.pgbench

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$PostgreSQL: pgsql/contrib/pgbench/README.pgbench,v 1.19 2007/07/0613:36:55 wieck Exp $
1+
$PostgreSQL: pgsql/contrib/pgbench/README.pgbench,v 1.20 2007/07/0620:17:02 wieck Exp $
22

33
pgbench README
44

@@ -231,15 +231,15 @@ o -f option
231231

232232
Variables can also be defined by using -D option.
233233

234-
\usleep usec
234+
\sleep num [us|ms|s]
235235

236-
causes script execution to sleep for the specified durationin
237-
microseconds.
236+
causes script execution to sleep for the specified durationof
237+
microseconds (us), milliseconds (ms) or the default seconds (s).
238238

239239
example:
240240

241-
\setrandomusec 1000000 3000000
242-
\usleep :usec
241+
\setrandommillisec 1000 2500
242+
\sleep :millisec ms
243243

244244
Example, TPC-B like benchmark can be defined as follows(scaling
245245
factor = 1):

‎contrib/pgbench/pgbench.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.67 2007/07/0613:36:55 wieck Exp $
2+
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.68 2007/07/0620:17:02 wieck Exp $
33
*
44
* pgbench: a simple benchmark program for PostgreSQL
55
* written by Tatsuo Ishii
@@ -727,7 +727,7 @@ doCustom(CState * state, int n, int debug)
727727

728728
st->listen=1;
729729
}
730-
elseif (pg_strcasecmp(argv[0],"usleep")==0)
730+
elseif (pg_strcasecmp(argv[0],"sleep")==0)
731731
{
732732
char*var;
733733
intusec;
@@ -746,6 +746,16 @@ doCustom(CState * state, int n, int debug)
746746
else
747747
usec=atoi(argv[1]);
748748

749+
if (argc>2)
750+
{
751+
if (pg_strcasecmp(argv[2],"ms")==0)
752+
usec *=1000;
753+
elseif (pg_strcasecmp(argv[2],"s")==0)
754+
usec *=1000000;
755+
}
756+
else
757+
usec *=1000000;
758+
749759
gettimeofday(&now,NULL);
750760
st->until.tv_sec=now.tv_sec+ (now.tv_usec+usec) /1000000;
751761
st->until.tv_usec= (now.tv_usec+usec) %1000000;
@@ -963,15 +973,27 @@ process_commands(char *buf)
963973
fprintf(stderr,"%s: extra argument \"%s\" ignored\n",
964974
my_commands->argv[0],my_commands->argv[j]);
965975
}
966-
elseif (pg_strcasecmp(my_commands->argv[0],"usleep")==0)
976+
elseif (pg_strcasecmp(my_commands->argv[0],"sleep")==0)
967977
{
968978
if (my_commands->argc<2)
969979
{
970980
fprintf(stderr,"%s: missing argument\n",my_commands->argv[0]);
971981
returnNULL;
972982
}
973983

974-
for (j=2;j<my_commands->argc;j++)
984+
if (my_commands->argc >=3)
985+
{
986+
if (pg_strcasecmp(my_commands->argv[2],"us")!=0&&
987+
pg_strcasecmp(my_commands->argv[2],"ms")!=0&&
988+
pg_strcasecmp(my_commands->argv[2],"s"))
989+
{
990+
fprintf(stderr,"%s: unknown time unit '%s' - must be us, ms or s\n",
991+
my_commands->argv[0],my_commands->argv[2]);
992+
returnNULL;
993+
}
994+
}
995+
996+
for (j=3;j<my_commands->argc;j++)
975997
fprintf(stderr,"%s: extra argument \"%s\" ignored\n",
976998
my_commands->argv[0],my_commands->argv[j]);
977999
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp