Skip to content

Instantly share code, notes, and snippets.

@stevengj
Created March 29, 2017 01:07
Show Gist options
  • Save stevengj/7e80a713bf3f42ce865f658e5f2795fc to your computer and use it in GitHub Desktop.
Save stevengj/7e80a713bf3f42ce865f658e5f2795fc to your computer and use it in GitHub Desktop.
sobol benchmark code
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include "sobol.hpp"
int main(int argc, char **argv)
{
int ndim = atoi(argv[1]);
int i, N = atoi(argv[2]);
int seed = 0;
float x[1111];
struct timeval tstart, tend;
printf("benchmarking 32-bit %d-dim sobol: %d terms\n", ndim, N);
i4_sobol(ndim, &seed, x);
gettimeofday(&tstart, NULL);
for (i = 0; i < N; ++i) {
i4_sobol(ndim, &seed, x);
}
gettimeofday(&tend, NULL);
printf("elapsed time = %g seconds\n",
(tend.tv_sec - tstart.tv_sec) + 1e-6*(tend.tv_usec - tstart.tv_usec));
printf("after %d iterations, got: [", N);
for (i = 0; i < ndim; ++i) {
if (i > 0) printf(", ");
printf("%g", x[i]);
}
printf("]\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment