|
1 | 1 | /* |
2 | | - * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.75 2007/12/11 02:31:49 tgl Exp $ |
| 2 | + * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.76 2008/03/10 01:23:04 tgl Exp $ |
3 | 3 | * |
4 | 4 | * pgbench: a simple benchmark program for PostgreSQL |
5 | 5 | * written by Tatsuo Ishii |
@@ -191,11 +191,15 @@ usage(void) |
191 | 191 | fprintf(stderr,"(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor] [-F fillfactor] [-U login][-d][dbname]\n"); |
192 | 192 | } |
193 | 193 |
|
194 | | -/* random number generator */ |
| 194 | +/* random number generator: uniform distribution from min to max inclusive */ |
195 | 195 | staticint |
196 | 196 | getrand(intmin,intmax) |
197 | 197 | { |
198 | | -returnmin+ (int) (((max-min)* (double)random()) /MAX_RANDOM_VALUE+0.5); |
| 198 | +/* |
| 199 | + * Odd coding is so that min and max have approximately the same chance of |
| 200 | + * being selected as do numbers between them. |
| 201 | + */ |
| 202 | +returnmin+ (int) (((max-min+1)* (double)random()) / (MAX_RANDOM_VALUE+1.0)); |
199 | 203 | } |
200 | 204 |
|
201 | 205 | /* call PQexec() and exit() on failure */ |
|