@@ -100,7 +100,7 @@ static int pthread_join(pthread_t th, void **thread_return);
100100#define LOG_STEP_SECONDS 5 /* seconds between log messages */
101101#define DEFAULT_NXACTS 10 /* default nxacts */
102102
103- #define MIN_GAUSSIAN_THRESHOLD 2.0 /* minimum threshold for gauss */
103+ #define MIN_GAUSSIAN_PARAM 2.0 /* minimum parameter for gauss */
104104
105105int nxacts = 0 ; /* number of transactions per client */
106106int duration = 0 ; /* duration in seconds */
@@ -503,47 +503,47 @@ getrand(TState *thread, int64 min, int64 max)
503503
504504/*
505505 * random number generator: exponential distribution from min to max inclusive.
506- * the threshold is so that the density of probability for the last cut-off max
507- * value is exp(-threshold ).
506+ * the parameter is so that the density of probability for the last cut-off max
507+ * value is exp(-parameter ).
508508 */
509509static int64
510- getExponentialRand (TState * thread , int64 min , int64 max , double threshold )
510+ getExponentialRand (TState * thread , int64 min , int64 max , double parameter )
511511{
512512 double cut ,
513513 uniform ,
514514 rand ;
515515
516- Assert (threshold > 0.0 );
517- cut = exp (- threshold );
516+ Assert (parameter > 0.0 );
517+ cut = exp (- parameter );
518518 /* erand in [0, 1), uniform in (0, 1] */
519519 uniform = 1.0 - pg_erand48 (thread -> random_state );
520520
521521 /*
522- * inner expresion in (cut, 1] (if threshold > 0), rand in [0, 1)
522+ * inner expresion in (cut, 1] (if parameter > 0), rand in [0, 1)
523523 */
524524 Assert ((1.0 - cut ) != 0.0 );
525- rand = - log (cut + (1.0 - cut ) * uniform ) / threshold ;
525+ rand = - log (cut + (1.0 - cut ) * uniform ) / parameter ;
526526 /* return int64 random number within between min and max */
527527 return min + (int64 ) ((max - min + 1 ) * rand );
528528}
529529
530530/* random number generator: gaussian distribution from min to max inclusive */
531531static int64
532- getGaussianRand (TState * thread , int64 min , int64 max , double threshold )
532+ getGaussianRand (TState * thread , int64 min , int64 max , double parameter )
533533{
534534 double stdev ;
535535 double rand ;
536536
537537 /*
538- * Get user specified random number from this loop, with -threshold <
539- * stdev <= threshold
538+ * Get user specified random number from this loop,
539+ * with -parameter < stdev <= parameter
540540 *
541541 * This loop is executed until the number is in the expected range.
542542 *
543- * As the minimum threshold is 2.0, the probability of looping is low:
543+ * As the minimum parameter is 2.0, the probability of looping is low:
544544 * sqrt(-2 ln(r)) <= 2 => r >= e^{-2} ~ 0.135, then when taking the
545545 * average sinus multiplier as 2/pi, we have a 8.6% looping probability in
546- * the worst case. For a 5.0 threshold value , the looping probability is
546+ * the worst case. For a parameter value of 5.0, the looping probability is
547547 * about e^{-5} * 2 / pi ~ 0.43%.
548548 */
549549 do
@@ -568,10 +568,10 @@ getGaussianRand(TState *thread, int64 min, int64 max, double threshold)
568568 * over.
569569 */
570570 }
571- while (stdev < - threshold || stdev >= threshold );
571+ while (stdev < - parameter || stdev >= parameter );
572572
573- /* stdev is in [-threshold, threshold ), normalization to [0,1) */
574- rand = (stdev + threshold ) / (threshold * 2.0 );
573+ /* stdev is in [-parameter, parameter ), normalization to [0,1) */
574+ rand = (stdev + parameter ) / (parameter * 2.0 );
575575
576576 /* return int64 random number within between min and max */
577577 return min + (int64 ) ((max - min + 1 ) * rand );
@@ -1498,7 +1498,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
14981498 char * var ;
14991499 int64 min ,
15001500 max ;
1501- double threshold = 0 ;
1501+ double parameter = 0 ;
15021502 char res [64 ];
15031503
15041504 if (* argv [2 ] == ':' )
@@ -1569,41 +1569,49 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
15691569 {
15701570 if ((var = getVariable (st , argv [5 ] + 1 )) == NULL )
15711571 {
1572- fprintf (stderr , "%s: invalid threshold number : \"%s\"\n" ,
1572+ fprintf (stderr , "%s: invalid parameter : \"%s\"\n" ,
15731573 argv [0 ], argv [5 ]);
15741574 st -> ecnt ++ ;
15751575 return true;
15761576 }
1577- threshold = strtod (var , NULL );
1577+ parameter = strtod (var , NULL );
15781578 }
15791579 else
1580- threshold = strtod (argv [5 ], NULL );
1580+ parameter = strtod (argv [5 ], NULL );
15811581
15821582 if (pg_strcasecmp (argv [4 ], "gaussian" ) == 0 )
15831583 {
1584- if (threshold < MIN_GAUSSIAN_THRESHOLD )
1584+ if (parameter < MIN_GAUSSIAN_PARAM )
15851585 {
1586- fprintf (stderr , "gaussian threshold must be at least %f (not \"%s\")\n" , MIN_GAUSSIAN_THRESHOLD , argv [5 ]);
1586+ fprintf (stderr , "gaussian parameter must be at least %f (not \"%s\")\n" , MIN_GAUSSIAN_PARAM , argv [5 ]);
15871587 st -> ecnt ++ ;
15881588 return true;
15891589 }
15901590#ifdef DEBUG
1591- printf ("min: " INT64_FORMAT " max: " INT64_FORMAT " random: " INT64_FORMAT "\n" , min , max , getGaussianRand (thread , min , max , threshold ));
1591+ printf ("min: " INT64_FORMAT " max: " INT64_FORMAT " random: " INT64_FORMAT "\n" ,
1592+ min , max ,
1593+ getGaussianRand (thread , min , max , parameter ));
15921594#endif
1593- snprintf (res , sizeof (res ), INT64_FORMAT , getGaussianRand (thread , min , max , threshold ));
1595+ snprintf (res , sizeof (res ), INT64_FORMAT ,
1596+ getGaussianRand (thread , min , max , parameter ));
15941597 }
15951598 else if (pg_strcasecmp (argv [4 ], "exponential" ) == 0 )
15961599 {
1597- if (threshold <= 0.0 )
1600+ if (parameter <= 0.0 )
15981601 {
1599- fprintf (stderr , "exponential threshold must be greater than zero (not \"%s\")\n" , argv [5 ]);
1602+ fprintf (stderr ,
1603+ "exponential parameter must be greater than zero (not \"%s\")\n" ,
1604+ argv [5 ]);
16001605 st -> ecnt ++ ;
16011606 return true;
16021607 }
16031608#ifdef DEBUG
1604- printf ("min: " INT64_FORMAT " max: " INT64_FORMAT " random: " INT64_FORMAT "\n" , min , max , getExponentialRand (thread , min , max , threshold ));
1609+ printf ("min: " INT64_FORMAT " max: " INT64_FORMAT " random: " INT64_FORMAT "\n" ,
1610+ min , max ,
1611+ getExponentialRand (thread , min , max , parameter ));
16051612#endif
1606- snprintf (res , sizeof (res ), INT64_FORMAT , getExponentialRand (thread , min , max , threshold ));
1613+ snprintf (res , sizeof (res ), INT64_FORMAT ,
1614+ getExponentialRand (thread , min , max , parameter ));
16071615 }
16081616 }
16091617 else /* this means an error somewhere in the parsing phase... */
@@ -2297,8 +2305,9 @@ process_commands(char *buf, const char *source, const int lineno)
22972305 if (pg_strcasecmp (my_commands -> argv [0 ], "setrandom" ) == 0 )
22982306 {
22992307 /*
2300- * parsing: \setrandom variable min max [uniform] \setrandom
2301- * variable min max (gaussian|exponential) threshold
2308+ * parsing:
2309+ * \setrandom variable min max [uniform]
2310+ * \setrandom variable min max (gaussian|exponential) parameter
23022311 */
23032312
23042313 if (my_commands -> argc < 4 )
@@ -2323,7 +2332,7 @@ process_commands(char *buf, const char *source, const int lineno)
23232332 if (my_commands -> argc < 6 )
23242333 {
23252334 syntax_error (source , lineno , my_commands -> line , my_commands -> argv [0 ],
2326- "missing threshold argument " , my_commands -> argv [4 ], -1 );
2335+ "missing parameter " , my_commands -> argv [4 ], -1 );
23272336 }
23282337 else if (my_commands -> argc > 6 )
23292338 {
0 commit comments