Skip to content

Commit eb8f60c

Browse files
committed
add comments
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent f5350c2 commit eb8f60c

File tree

1 file changed

+49
-0
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/planck/pmf/benchmark/c

1 file changed

+49
-0
lines changed

lib/node_modules/@stdlib/stats/base/dists/planck/pmf/benchmark/c/benchmark.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,21 @@
2727
#define ITERATIONS 1000000
2828
#define REPEATS 3
2929

30+
/**
31+
* Prints the TAP version.
32+
*/
33+
3034
static void print_version( void ) {
3135
printf( "TAP version 13\n" );
3236
}
3337

38+
/**
39+
* Prints the TAP summary.
40+
*
41+
* @param total total number of tests
42+
* @param passing total number of passing tests
43+
*/
44+
3445
static void print_summary( int total, int passing ) {
3546
printf( "#\n" );
3647
printf( "1..%d\n", total );
@@ -40,6 +51,12 @@ static void print_summary( int total, int passing ) {
4051
printf( "# ok\n" );
4152
}
4253

54+
/**
55+
* Prints benchmarks results.
56+
*
57+
* @param elapsed elapsed time in seconds
58+
*/
59+
4360
static void print_results( double elapsed ) {
4461
double rate = (double)ITERATIONS / elapsed;
4562
printf( " ---\n" );
@@ -49,21 +66,49 @@ static void print_results( double elapsed ) {
4966
printf( " ...\n" );
5067
}
5168

69+
/**
70+
* Returns a clock time.
71+
*
72+
* @return clock time
73+
*/
74+
5275
static double tic( void ) {
5376
struct timeval now;
5477
gettimeofday( &now, NULL );
5578
return (double)now.tv_sec + (double)now.tv_usec / 1.0e6;
5679
}
5780

81+
/**
82+
* Generates a random integer number on the interval [min,max).
83+
*
84+
* @param min minimum value (inclusive)
85+
* @param max maximum value (exclusive)
86+
* @return random integer
87+
*/
88+
5889
static int random_discrete_uniform( const int min, const int max ) {
5990
return min + rand() % ( max - min + 1 );
6091
}
6192

93+
/**
94+
* Generates a random number on the interval [min,max).
95+
*
96+
* @param min minimum value (inclusive)
97+
* @param max maximum value (exclusive)
98+
* @return random number
99+
*/
100+
62101
static double random_uniform( const double min, const double max ) {
63102
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
64103
return min + ( v * ( max - min ) );
65104
}
66105

106+
/**
107+
* Runs a benchmark.
108+
*
109+
* @return elapsed time in seconds
110+
*/
111+
67112
static double benchmark( void ) {
68113
double elapsed;
69114
int x[100];
@@ -92,6 +137,10 @@ static double benchmark( void ) {
92137
return elapsed;
93138
}
94139

140+
/**
141+
* Main execution sequence.
142+
*/
143+
95144
int main( void ) {
96145
double elapsed;
97146
int i;

0 commit comments

Comments
 (0)