\e$BBg$-$5$,\e(B 10\e$BK|\e(B x [\e$B%9%1!<%j%s%0%U%!%/%?!<\e(B]\e$B$K$J$j$^$9!%\e(B
\e$B%G%U%)%k%H$N%9%1!<%j%s%0%U%!%/%?!<$O\e(B 1 \e$B$G$9!%\e(B
-f \e$B%*%W%7%g%s$G;XDj$7$?%U%!%$%k$+$i%9%1!<%j%s%0%U%!%/\e(B
- \e$B%?!<$r;2>H$9$k$K$O\e(B tps \e$B$H$$$&JQ?tL>$r;HMQ$7$^$9!%\e(B
+ \e$B%?!<$r;2>H$9$k$K$O\e(B scale \e$B$H$$$&JQ?tL>$r;HMQ$7$^$9!%\e(B
-D varname=value
\e$BJQ?t$K1i;;$N7k2L$r@_Dj$9$k$K$O!$\e(B\set \e$B%a%?%3%^%s%I$r;HMQ$7$F0J\e(B
\e$B2<$N$h$&$K5-=R$7$^$9!%\e(B
- \set ntellers 10 * :tps
+ \set ntellers 10 * :tp
\e$B$3$l$O!$JQ?t\e(B ntellers \e$B$K%9%1!<%j%s%0%U%!%/%?!<\e(B (-s \e$B%*%W%7%g%s\e(B
\e$B$G;XDj$7$?\e(B) \e$B$r\e(B 10 \e$BG\$7$?7k2L$r@_Dj$7$^$9!%\e(B
\e$B%6%/%7%g%s$NFbMF$r%U%!%$%k$K5-=R$7!$\e(B-f \e$B%*%W%7%g%s$K$h$C$F$=$N%U%!%$%k\e(B
\e$B$r;XDj$7$F\e(B pgbench \e$B$r<B9T$7$^$9!%\e(B
-\set nbranches :tps
-\set ntellers 10 * :tps
-\set naccounts 100000 * :tps
+\set nbranches :scale
+\set ntellers 10 * :scale
+\set naccounts 100000 * :scale
\setrandom aid 1 :naccounts
\setrandom bid 1 :nbranches
\setrandom tid 1 :ntellers
\e$B"#2~DjMzNr\e(B
+2006/09/13
+ * \e$BJQ?t\e(Btps\e$B$OJ6$i$o$7$$$N$G\e(Bscale\e$B$KJQ99!%%G%U%)%k%H%7%J%j%*$N;~$K!$\e(B
+ \e$B%G%U%)%k%H$N%9%1!<%j%s%0%U%!%/%?$r\e(Bbranches\e$B$+$i<h$C$F$3$J$$%P%0$r=$@5!%\e(B
+
2006/07/26
* \e$B:4F#$5$s$N%Q%C%A$rE,MQ!%0J2<$N5!G=DI2C!%\e(BPostgreSQL 8.2\e$B$K<h$j\e(B
\e$B9~$^$l$^$9!%\e(B
/*
- * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.53 2006/08/15 13:05:30 ishii Exp $
+ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.54 2006/09/13 00:39:19 ishii Exp $
*
* pgbench: a simple benchmark program for PostgreSQL
* written by Tatsuo Ishii
int nxacts = 10; /* default number of transactions per clients */
/*
- * scaling factor. for example, tps = 10 will make 1000000 tuples of
+ * scaling factor. for example, scale = 10 will make 1000000 tuples of
* accounts table.
*/
-int tps = 1;
+int scale = 1;
/*
* end of configurable parameters
/* default scenario */
static char *tpc_b = {
- "\\set nbranches :tps\n"
- "\\set ntellers 10 * :tps\n"
- "\\set naccounts 100000 * :tps\n"
+ "\\set nbranches :scale\n"
+ "\\set ntellers 10 * :scale\n"
+ "\\set naccounts 100000 * :scale\n"
"\\setrandom aid 1 :naccounts\n"
"\\setrandom bid 1 :nbranches\n"
"\\setrandom tid 1 :ntellers\n"
/* -N case */
static char *simple_update = {
- "\\set nbranches :tps\n"
- "\\set ntellers 10 * :tps\n"
- "\\set naccounts 100000 * :tps\n"
+ "\\set nbranches :scale\n"
+ "\\set ntellers 10 * :scale\n"
+ "\\set naccounts 100000 * :scale\n"
"\\setrandom aid 1 :naccounts\n"
"\\setrandom bid 1 :nbranches\n"
"\\setrandom tid 1 :ntellers\n"
/* -S case */
static char *select_only = {
- "\\set naccounts 100000 * :tps\n"
+ "\\set naccounts 100000 * :scale\n"
"\\setrandom aid 1 :naccounts\n"
"SELECT abalance FROM accounts WHERE aid = :aid;\n"
};
}
else
{
- if ((value = strdup(value)) == NULL)
+ char *val;
+
+ if ((val = strdup(value)) == NULL)
return false;
+
free(var->value);
- var->value = value;
+ var->value = val;
}
return true;
}
PQclear(res);
- for (i = 0; i < nbranches * tps; i++)
+ for (i = 0; i < nbranches * scale; i++)
{
snprintf(sql, 256, "insert into branches(bid,bbalance) values(%d,0)", i + 1);
res = PQexec(con, sql);
PQclear(res);
}
- for (i = 0; i < ntellers * tps; i++)
+ for (i = 0; i < ntellers * scale; i++)
{
snprintf(sql, 256, "insert into tellers(tid,bid,tbalance) values (%d,%d,0)"
,i + 1, i / ntellers + 1);
* occupy accounts table with some data
*/
fprintf(stderr, "creating tables...\n");
- for (i = 0; i < naccounts * tps; i++)
+ for (i = 0; i < naccounts * scale; i++)
{
int j = i + 1;
s = "Custom query";
printf("transaction type: %s\n", s);
- printf("scaling factor: %d\n", tps);
+ printf("scaling factor: %d\n", scale);
printf("number of clients: %d\n", nclients);
printf("number of transactions per client: %d\n", nxacts);
printf("number of transactions actually processed: %d/%d\n", normal_xacts, nxacts * nclients);
PGresult *res;
char *env;
+ char val[64];
+
if ((env = getenv("PGHOST")) != NULL && *env != '\0')
pghost = env;
if ((env = getenv("PGPORT")) != NULL && *env != '\0')
is_connect = 1;
break;
case 's':
- tps = atoi(optarg);
- if (tps <= 0)
+ scale = atoi(optarg);
+ if (scale <= 0)
{
- fprintf(stderr, "invalid scaling factor: %d\n", tps);
+ fprintf(stderr, "invalid scaling factor: %d\n", scale);
exit(1);
}
break;
remains = nclients;
- if (getVariable(&state[0], "tps") == NULL)
+ if (getVariable(&state[0], "scale") == NULL)
{
- char val[64];
-
- snprintf(val, sizeof(val), "%d", tps);
- if (putVariable(&state[0], "tps", val) == false)
+ snprintf(val, sizeof(val), "%d", scale);
+ if (putVariable(&state[0], "scale", val) == false)
{
fprintf(stderr, "Couldn't allocate memory for variable\n");
exit(1);
fprintf(stderr, "%s", PQerrorMessage(con));
exit(1);
}
- tps = atoi(PQgetvalue(res, 0, 0));
- if (tps < 0)
+ scale = atoi(PQgetvalue(res, 0, 0));
+ if (scale < 0)
{
- fprintf(stderr, "count(*) from branches invalid (%d)\n", tps);
+ fprintf(stderr, "count(*) from branches invalid (%d)\n", scale);
exit(1);
}
PQclear(res);
+
+ snprintf(val, sizeof(val), "%d", scale);
+ if (putVariable(&state[0], "scale", val) == false)
+ {
+ fprintf(stderr, "Couldn't allocate memory for variable\n");
+ exit(1);
+ }
}
if (!is_no_vacuum)