@@ -90,7 +90,7 @@ static int pthread_join(pthread_t th, void **thread_return);
9090#define LOG_STEP_SECONDS 5 /* seconds between log messages */
9191#define DEFAULT_NXACTS 10 /* default nxacts */
9292
93- #define MIN_GAUSSIAN_THRESHOLD 2.0 /* minimum threshold for gauss */
93+ #define MIN_GAUSSIAN_PARAM 2.0 /* minimum parameter for gauss */
9494
9595int nxacts = 0 ; /* number of transactions per client */
9696int duration = 0 ; /* duration in seconds */
@@ -488,47 +488,47 @@ getrand(TState *thread, int64 min, int64 max)
488488
489489/*
490490 * random number generator: exponential distribution from min to max inclusive.
491- * the threshold is so that the density of probability for the last cut-off max
492- * value is exp(-threshold ).
491+ * the parameter is so that the density of probability for the last cut-off max
492+ * value is exp(-parameter ).
493493 */
494494static int64
495- getExponentialRand (TState * thread , int64 min , int64 max , double threshold )
495+ getExponentialRand (TState * thread , int64 min , int64 max , double parameter )
496496{
497497 double cut ,
498498 uniform ,
499499 rand ;
500500
501- Assert (threshold > 0.0 );
502- cut = exp (- threshold );
501+ Assert (parameter > 0.0 );
502+ cut = exp (- parameter );
503503 /* erand in [0, 1), uniform in (0, 1] */
504504 uniform = 1.0 - pg_erand48 (thread -> random_state );
505505
506506 /*
507- * inner expresion in (cut, 1] (if threshold > 0), rand in [0, 1)
507+ * inner expresion in (cut, 1] (if parameter > 0), rand in [0, 1)
508508 */
509509 Assert ((1.0 - cut ) != 0.0 );
510- rand = - log (cut + (1.0 - cut ) * uniform ) / threshold ;
510+ rand = - log (cut + (1.0 - cut ) * uniform ) / parameter ;
511511 /* return int64 random number within between min and max */
512512 return min + (int64 ) ((max - min + 1 ) * rand );
513513}
514514
515515/* random number generator: gaussian distribution from min to max inclusive */
516516static int64
517- getGaussianRand (TState * thread , int64 min , int64 max , double threshold )
517+ getGaussianRand (TState * thread , int64 min , int64 max , double parameter )
518518{
519519 double stdev ;
520520 double rand ;
521521
522522 /*
523- * Get user specified random number from this loop, with -threshold <
524- * stdev <= threshold
523+ * Get user specified random number from this loop,
524+ * with -parameter < stdev <= parameter
525525 *
526526 * This loop is executed until the number is in the expected range.
527527 *
528- * As the minimum threshold is 2.0, the probability of looping is low:
528+ * As the minimum parameter is 2.0, the probability of looping is low:
529529 * sqrt(-2 ln(r)) <= 2 => r >= e^{-2} ~ 0.135, then when taking the
530530 * average sinus multiplier as 2/pi, we have a 8.6% looping probability in
531- * the worst case. For a 5.0 threshold value , the looping probability is
531+ * the worst case. For a parameter value of 5.0, the looping probability is
532532 * about e^{-5} * 2 / pi ~ 0.43%.
533533 */
534534 do
@@ -553,10 +553,10 @@ getGaussianRand(TState *thread, int64 min, int64 max, double threshold)
553553 * over.
554554 */
555555 }
556- while (stdev < - threshold || stdev >= threshold );
556+ while (stdev < - parameter || stdev >= parameter );
557557
558- /* stdev is in [-threshold, threshold ), normalization to [0,1) */
559- rand = (stdev + threshold ) / (threshold * 2.0 );
558+ /* stdev is in [-parameter, parameter ), normalization to [0,1) */
559+ rand = (stdev + parameter ) / (parameter * 2.0 );
560560
561561 /* return int64 random number within between min and max */
562562 return min + (int64 ) ((max - min + 1 ) * rand );
@@ -1483,7 +1483,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
14831483 char * var ;
14841484 int64 min ,
14851485 max ;
1486- double threshold = 0 ;
1486+ double parameter = 0 ;
14871487 char res [64 ];
14881488
14891489 if (* argv [2 ] == ':' )
@@ -1554,41 +1554,49 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
15541554 {
15551555 if ((var = getVariable (st , argv [5 ] + 1 )) == NULL )
15561556 {
1557- fprintf (stderr , "%s: invalid threshold number : \"%s\"\n" ,
1557+ fprintf (stderr , "%s: invalid parameter : \"%s\"\n" ,
15581558 argv [0 ], argv [5 ]);
15591559 st -> ecnt ++ ;
15601560 return true;
15611561 }
1562- threshold = strtod (var , NULL );
1562+ parameter = strtod (var , NULL );
15631563 }
15641564 else
1565- threshold = strtod (argv [5 ], NULL );
1565+ parameter = strtod (argv [5 ], NULL );
15661566
15671567 if (pg_strcasecmp (argv [4 ], "gaussian" ) == 0 )
15681568 {
1569- if (threshold < MIN_GAUSSIAN_THRESHOLD )
1569+ if (parameter < MIN_GAUSSIAN_PARAM )
15701570 {
1571- fprintf (stderr , "gaussian threshold must be at least %f (not \"%s\")\n" , MIN_GAUSSIAN_THRESHOLD , argv [5 ]);
1571+ fprintf (stderr , "gaussian parameter must be at least %f (not \"%s\")\n" , MIN_GAUSSIAN_PARAM , argv [5 ]);
15721572 st -> ecnt ++ ;
15731573 return true;
15741574 }
15751575#ifdef DEBUG
1576- printf ("min: " INT64_FORMAT " max: " INT64_FORMAT " random: " INT64_FORMAT "\n" , min , max , getGaussianRand (thread , min , max , threshold ));
1576+ printf ("min: " INT64_FORMAT " max: " INT64_FORMAT " random: " INT64_FORMAT "\n" ,
1577+ min , max ,
1578+ getGaussianRand (thread , min , max , parameter ));
15771579#endif
1578- snprintf (res , sizeof (res ), INT64_FORMAT , getGaussianRand (thread , min , max , threshold ));
1580+ snprintf (res , sizeof (res ), INT64_FORMAT ,
1581+ getGaussianRand (thread , min , max , parameter ));
15791582 }
15801583 else if (pg_strcasecmp (argv [4 ], "exponential" ) == 0 )
15811584 {
1582- if (threshold <= 0.0 )
1585+ if (parameter <= 0.0 )
15831586 {
1584- fprintf (stderr , "exponential threshold must be greater than zero (not \"%s\")\n" , argv [5 ]);
1587+ fprintf (stderr ,
1588+ "exponential parameter must be greater than zero (not \"%s\")\n" ,
1589+ argv [5 ]);
15851590 st -> ecnt ++ ;
15861591 return true;
15871592 }
15881593#ifdef DEBUG
1589- printf ("min: " INT64_FORMAT " max: " INT64_FORMAT " random: " INT64_FORMAT "\n" , min , max , getExponentialRand (thread , min , max , threshold ));
1594+ printf ("min: " INT64_FORMAT " max: " INT64_FORMAT " random: " INT64_FORMAT "\n" ,
1595+ min , max ,
1596+ getExponentialRand (thread , min , max , parameter ));
15901597#endif
1591- snprintf (res , sizeof (res ), INT64_FORMAT , getExponentialRand (thread , min , max , threshold ));
1598+ snprintf (res , sizeof (res ), INT64_FORMAT ,
1599+ getExponentialRand (thread , min , max , parameter ));
15921600 }
15931601 }
15941602 else /* this means an error somewhere in the parsing phase... */
@@ -2282,8 +2290,9 @@ process_commands(char *buf, const char *source, const int lineno)
22822290 if (pg_strcasecmp (my_commands -> argv [0 ], "setrandom" ) == 0 )
22832291 {
22842292 /*
2285- * parsing: \setrandom variable min max [uniform] \setrandom
2286- * variable min max (gaussian|exponential) threshold
2293+ * parsing:
2294+ * \setrandom variable min max [uniform]
2295+ * \setrandom variable min max (gaussian|exponential) parameter
22872296 */
22882297
22892298 if (my_commands -> argc < 4 )
@@ -2308,7 +2317,7 @@ process_commands(char *buf, const char *source, const int lineno)
23082317 if (my_commands -> argc < 6 )
23092318 {
23102319 syntax_error (source , lineno , my_commands -> line , my_commands -> argv [0 ],
2311- "missing threshold argument " , my_commands -> argv [4 ], -1 );
2320+ "missing parameter " , my_commands -> argv [4 ], -1 );
23122321 }
23132322 else if (my_commands -> argc > 6 )
23142323 {
0 commit comments