@@ -100,7 +100,7 @@ static int pthread_join(pthread_t th, void **thread_return);
100
100
#define LOG_STEP_SECONDS 5 /* seconds between log messages */
101
101
#define DEFAULT_NXACTS 10 /* default nxacts */
102
102
103
- #define MIN_GAUSSIAN_THRESHOLD 2.0 /* minimum threshold for gauss */
103
+ #define MIN_GAUSSIAN_PARAM 2.0 /* minimum parameter for gauss */
104
104
105
105
int nxacts = 0 ; /* number of transactions per client */
106
106
int duration = 0 ; /* duration in seconds */
@@ -503,47 +503,47 @@ getrand(TState *thread, int64 min, int64 max)
503
503
504
504
/*
505
505
* 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 ).
508
508
*/
509
509
static int64
510
- getExponentialRand (TState * thread , int64 min , int64 max , double threshold )
510
+ getExponentialRand (TState * thread , int64 min , int64 max , double parameter )
511
511
{
512
512
double cut ,
513
513
uniform ,
514
514
rand ;
515
515
516
- Assert (threshold > 0.0 );
517
- cut = exp (- threshold );
516
+ Assert (parameter > 0.0 );
517
+ cut = exp (- parameter );
518
518
/* erand in [0, 1), uniform in (0, 1] */
519
519
uniform = 1.0 - pg_erand48 (thread -> random_state );
520
520
521
521
/*
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)
523
523
*/
524
524
Assert ((1.0 - cut ) != 0.0 );
525
- rand = - log (cut + (1.0 - cut ) * uniform ) / threshold ;
525
+ rand = - log (cut + (1.0 - cut ) * uniform ) / parameter ;
526
526
/* return int64 random number within between min and max */
527
527
return min + (int64 ) ((max - min + 1 ) * rand );
528
528
}
529
529
530
530
/* random number generator: gaussian distribution from min to max inclusive */
531
531
static int64
532
- getGaussianRand (TState * thread , int64 min , int64 max , double threshold )
532
+ getGaussianRand (TState * thread , int64 min , int64 max , double parameter )
533
533
{
534
534
double stdev ;
535
535
double rand ;
536
536
537
537
/*
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
540
540
*
541
541
* This loop is executed until the number is in the expected range.
542
542
*
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:
544
544
* sqrt(-2 ln(r)) <= 2 => r >= e^{-2} ~ 0.135, then when taking the
545
545
* 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
547
547
* about e^{-5} * 2 / pi ~ 0.43%.
548
548
*/
549
549
do
@@ -568,10 +568,10 @@ getGaussianRand(TState *thread, int64 min, int64 max, double threshold)
568
568
* over.
569
569
*/
570
570
}
571
- while (stdev < - threshold || stdev >= threshold );
571
+ while (stdev < - parameter || stdev >= parameter );
572
572
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 );
575
575
576
576
/* return int64 random number within between min and max */
577
577
return min + (int64 ) ((max - min + 1 ) * rand );
@@ -1498,7 +1498,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1498
1498
char * var ;
1499
1499
int64 min ,
1500
1500
max ;
1501
- double threshold = 0 ;
1501
+ double parameter = 0 ;
1502
1502
char res [64 ];
1503
1503
1504
1504
if (* argv [2 ] == ':' )
@@ -1569,41 +1569,49 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1569
1569
{
1570
1570
if ((var = getVariable (st , argv [5 ] + 1 )) == NULL )
1571
1571
{
1572
- fprintf (stderr , "%s: invalid threshold number : \"%s\"\n" ,
1572
+ fprintf (stderr , "%s: invalid parameter : \"%s\"\n" ,
1573
1573
argv [0 ], argv [5 ]);
1574
1574
st -> ecnt ++ ;
1575
1575
return true;
1576
1576
}
1577
- threshold = strtod (var , NULL );
1577
+ parameter = strtod (var , NULL );
1578
1578
}
1579
1579
else
1580
- threshold = strtod (argv [5 ], NULL );
1580
+ parameter = strtod (argv [5 ], NULL );
1581
1581
1582
1582
if (pg_strcasecmp (argv [4 ], "gaussian" ) == 0 )
1583
1583
{
1584
- if (threshold < MIN_GAUSSIAN_THRESHOLD )
1584
+ if (parameter < MIN_GAUSSIAN_PARAM )
1585
1585
{
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 ]);
1587
1587
st -> ecnt ++ ;
1588
1588
return true;
1589
1589
}
1590
1590
#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 ));
1592
1594
#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 ));
1594
1597
}
1595
1598
else if (pg_strcasecmp (argv [4 ], "exponential" ) == 0 )
1596
1599
{
1597
- if (threshold <= 0.0 )
1600
+ if (parameter <= 0.0 )
1598
1601
{
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 ]);
1600
1605
st -> ecnt ++ ;
1601
1606
return true;
1602
1607
}
1603
1608
#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 ));
1605
1612
#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 ));
1607
1615
}
1608
1616
}
1609
1617
else /* this means an error somewhere in the parsing phase... */
@@ -2297,8 +2305,9 @@ process_commands(char *buf, const char *source, const int lineno)
2297
2305
if (pg_strcasecmp (my_commands -> argv [0 ], "setrandom" ) == 0 )
2298
2306
{
2299
2307
/*
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
2302
2311
*/
2303
2312
2304
2313
if (my_commands -> argc < 4 )
@@ -2323,7 +2332,7 @@ process_commands(char *buf, const char *source, const int lineno)
2323
2332
if (my_commands -> argc < 6 )
2324
2333
{
2325
2334
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 );
2327
2336
}
2328
2337
else if (my_commands -> argc > 6 )
2329
2338
{
0 commit comments