Alien-Libjio
view release on metacpan or search on metacpan
libjio/tests/performance/random.c view on Meta::CPAN
secs = tv2.tv_sec - tv1.tv_sec;
usecs = tv2.tv_usec - tv1.tv_usec;
if (usecs < 0) {
secs -= 1;
usecs = 1000000 + usecs;
}
seconds = secs + (usecs / 1000000.0);
mb_per_sec = mb / seconds;
printf("%lu %zd %zd %f %f\n", tid, mb, blocksize, seconds, mb_per_sec);
free(buf);
return NULL;
}
int main(int argc, char **argv)
{
int nthreads;
unsigned long i;
pthread_t *threads;
struct jfsck_result ckres;
if (argc != 4) {
help();
return 1;
}
mb = atoi(argv[1]);
blocksize = atoi(argv[2]) * 1024;
nthreads = atoi(argv[3]);
towrite = mb * 1024 * 1024;
threads = malloc(sizeof(pthread_t) * nthreads);
if (threads == NULL) {
perror("malloc()");
return 1;
}
fs = jopen(FILENAME, O_RDWR | O_CREAT | O_TRUNC, 0600, 0);
if (fs == NULL) {
perror("jopen()");
return 1;
}
jtruncate(fs, towrite * nthreads);
for (i = 0; i < nthreads; i++) {
pthread_create(threads + i, NULL, &worker, (void *) i);
}
for (i = 0; i < nthreads; i++) {
pthread_join(*(threads + i), NULL);
}
jclose(fs);
jfsck(FILENAME, NULL, &ckres, 0);
if (ckres.total != 0) {
fprintf(stderr, "There were %d errors during the test\n",
ckres.total);
fprintf(stderr, "jfsck() was used to fix them, but that ");
fprintf(stderr, "shouldn't happen.\n");
return 1;
}
return 0;
}
( run in 1.963 second using v1.01-cache-2.11-cpan-5735350b133 )