@@ -90,7 +90,7 @@ static int pthread_join(pthread_t th, void **thread_return);
90
90
#define LOG_STEP_SECONDS 5 /* seconds between log messages */
91
91
#define DEFAULT_NXACTS 10 /* default nxacts */
92
92
93
- #define MIN_GAUSSIAN_THRESHOLD 2.0 /* minimum threshold for gauss */
93
+ #define MIN_GAUSSIAN_PARAM 2.0 /* minimum parameter for gauss */
94
94
95
95
int nxacts = 0 ; /* number of transactions per client */
96
96
int duration = 0 ; /* duration in seconds */
@@ -488,47 +488,47 @@ getrand(TState *thread, int64 min, int64 max)
488
488
489
489
/*
490
490
* 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 ).
493
493
*/
494
494
static int64
495
- getExponentialRand (TState * thread , int64 min , int64 max , double threshold )
495
+ getExponentialRand (TState * thread , int64 min , int64 max , double parameter )
496
496
{
497
497
double cut ,
498
498
uniform ,
499
499
rand ;
500
500
501
- Assert (threshold > 0.0 );
502
- cut = exp (- threshold );
501
+ Assert (parameter > 0.0 );
502
+ cut = exp (- parameter );
503
503
/* erand in [0, 1), uniform in (0, 1] */
504
504
uniform = 1.0 - pg_erand48 (thread -> random_state );
505
505
506
506
/*
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)
508
508
*/
509
509
Assert ((1.0 - cut ) != 0.0 );
510
- rand = - log (cut + (1.0 - cut ) * uniform ) / threshold ;
510
+ rand = - log (cut + (1.0 - cut ) * uniform ) / parameter ;
511
511
/* return int64 random number within between min and max */
512
512
return min + (int64 ) ((max - min + 1 ) * rand );
513
513
}
514
514
515
515
/* random number generator: gaussian distribution from min to max inclusive */
516
516
static int64
517
- getGaussianRand (TState * thread , int64 min , int64 max , double threshold )
517
+ getGaussianRand (TState * thread , int64 min , int64 max , double parameter )
518
518
{
519
519
double stdev ;
520
520
double rand ;
521
521
522
522
/*
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
525
525
*
526
526
* This loop is executed until the number is in the expected range.
527
527
*
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:
529
529
* sqrt(-2 ln(r)) <= 2 => r >= e^{-2} ~ 0.135, then when taking the
530
530
* 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
532
532
* about e^{-5} * 2 / pi ~ 0.43%.
533
533
*/
534
534
do
@@ -553,10 +553,10 @@ getGaussianRand(TState *thread, int64 min, int64 max, double threshold)
553
553
* over.
554
554
*/
555
555
}
556
- while (stdev < - threshold || stdev >= threshold );
556
+ while (stdev < - parameter || stdev >= parameter );
557
557
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 );
560
560
561
561
/* return int64 random number within between min and max */
562
562
return min + (int64 ) ((max - min + 1 ) * rand );
@@ -1483,7 +1483,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1483
1483
char * var ;
1484
1484
int64 min ,
1485
1485
max ;
1486
- double threshold = 0 ;
1486
+ double parameter = 0 ;
1487
1487
char res [64 ];
1488
1488
1489
1489
if (* argv [2 ] == ':' )
@@ -1554,41 +1554,49 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1554
1554
{
1555
1555
if ((var = getVariable (st , argv [5 ] + 1 )) == NULL )
1556
1556
{
1557
- fprintf (stderr , "%s: invalid threshold number : \"%s\"\n" ,
1557
+ fprintf (stderr , "%s: invalid parameter : \"%s\"\n" ,
1558
1558
argv [0 ], argv [5 ]);
1559
1559
st -> ecnt ++ ;
1560
1560
return true;
1561
1561
}
1562
- threshold = strtod (var , NULL );
1562
+ parameter = strtod (var , NULL );
1563
1563
}
1564
1564
else
1565
- threshold = strtod (argv [5 ], NULL );
1565
+ parameter = strtod (argv [5 ], NULL );
1566
1566
1567
1567
if (pg_strcasecmp (argv [4 ], "gaussian" ) == 0 )
1568
1568
{
1569
- if (threshold < MIN_GAUSSIAN_THRESHOLD )
1569
+ if (parameter < MIN_GAUSSIAN_PARAM )
1570
1570
{
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 ]);
1572
1572
st -> ecnt ++ ;
1573
1573
return true;
1574
1574
}
1575
1575
#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 ));
1577
1579
#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 ));
1579
1582
}
1580
1583
else if (pg_strcasecmp (argv [4 ], "exponential" ) == 0 )
1581
1584
{
1582
- if (threshold <= 0.0 )
1585
+ if (parameter <= 0.0 )
1583
1586
{
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 ]);
1585
1590
st -> ecnt ++ ;
1586
1591
return true;
1587
1592
}
1588
1593
#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 ));
1590
1597
#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 ));
1592
1600
}
1593
1601
}
1594
1602
else /* this means an error somewhere in the parsing phase... */
@@ -2282,8 +2290,9 @@ process_commands(char *buf, const char *source, const int lineno)
2282
2290
if (pg_strcasecmp (my_commands -> argv [0 ], "setrandom" ) == 0 )
2283
2291
{
2284
2292
/*
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
2287
2296
*/
2288
2297
2289
2298
if (my_commands -> argc < 4 )
@@ -2308,7 +2317,7 @@ process_commands(char *buf, const char *source, const int lineno)
2308
2317
if (my_commands -> argc < 6 )
2309
2318
{
2310
2319
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 );
2312
2321
}
2313
2322
else if (my_commands -> argc > 6 )
2314
2323
{
0 commit comments