本文整理汇总了C++中Benchmark::getSecs方法的典型用法代码示例。如果您正苦于以下问题:C++ Benchmark::getSecs方法的具体用法?C++ Benchmark::getSecs怎么用?C++ Benchmark::getSecs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Benchmark
的用法示例。
在下文中一共展示了Benchmark::getSecs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
double read(const char * filename, std::streampos size, int n_files, int blocksize)
{
if (debug) printf("\n%d files: ", n_files);
FILE * files[n_files];
// Open files, and set pos
for (int i = 0; i<n_files; ++i)
{
files[i] = fopen ( filename, "rb" );
long int pos = (size/n_files)*i;
fseek ( files[i], pos, SEEK_SET );
if (debug) printf("%lld, ", (unsigned long long) pos);
}
if (debug) printf("\n");
// Read size/n_files bytes from all files
Benchmark t; t.start();
uint32_t * buffer = (uint32_t *) malloc(blocksize);
// Every slice is 250' / number of files big
for (uint32_t i=0; i<(size/n_files); i+=blocksize)
{
// should be unrolled?
for (int j = 0; j<n_files; ++j)
{
// size_t res =
fread(buffer, 1, blocksize, files[j] );
/*
for (uint32_t z=0; z<blocksize/sizeof(int); ++z)
{
if (buffer[z] == 0)
printf("Read first byte\n");
if (buffer[z] == 249999999)
printf("Read last byte\n");
// fprintf(stderr, "Reading %d \n", buffer[z]);
}
//*/
}
}
t.stop();
// Close all files
free(buffer);
for (int i = 0; i<n_files; ++i)
fclose(files[i]);
return t.getSecs();
}
示例2: random_read
double random_read(const char * filename, std::streampos size, int blocksize)
{
FILE * file;
file = fopen ( filename, "rb" );
if (debug) printf("\n");
// Read size/n_files bytes from all files
Benchmark t; t.start();
uint32_t * buffer = (uint32_t *) malloc(blocksize);
// Every slice is 250' / number of files big
// for (uint32_t i=0; i<size; i+=blocksize)
for (uint32_t i=0; i<=249999999; ++i)
{
long int pos = rand() % size;
fseek ( file, pos, SEEK_SET );
// size_t res =
fread(buffer, 1, blocksize, file );
/*
for (uint32_t z=0; z<blocksize/sizeof(int); ++z)
{
if (buffer[z] == 0)
printf("Read first byte\n");
if (buffer[z] == 249999999)
printf("Read last byte\n");
// fprintf(stderr, "Reading %d \n", buffer[z]);
}
//*/
}
t.stop();
// Close all files
free(buffer);
fclose(file);
return t.getSecs();
}