本文整理汇总了C++中Duration::getMax方法的典型用法代码示例。如果您正苦于以下问题:C++ Duration::getMax方法的具体用法?C++ Duration::getMax怎么用?C++ Duration::getMax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Duration
的用法示例。
在下文中一共展示了Duration::getMax方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: delete_random
int COpenTest::delete_random(BonTimer &timer)
{
random_sort(timer.random_source);
timer.start();
int i;
Duration dur;
for(i = 0; i < m_number; i++)
{
dur.start();
if(unlink(m_file_names[i]))
{
fprintf(stderr, "Can't delete file %s\n", m_file_names[i]);
return -1;
}
if(m_sync && m_sync_dir)
{
if(fsync(m_directoryHandles[m_dirIndex[i]]))
{
fprintf(stderr, "Can't sync directory, turning off dir-sync.\n");
m_sync_dir = false;
}
}
dur.stop();
}
if(m_number_directories > 1)
{
char buf[6];
for(i = 0; i < m_number_directories; i++)
{
sprintf(buf, "%05d", i);
if(m_sync)
{
close(m_directoryHandles[i]);
}
if(rmdir(buf))
{
io_error("rmdir");
return -1;
}
}
}
else
{
if(m_sync)
{
close(m_directoryHandles[0]);
}
}
if(chdir("..") || rmdir(m_dirname))
{
io_error("rmdir");
return -1;
}
delete m_dirname;
m_dirname = NULL;
sync();
timer.stop_and_record(DelRand);
timer.add_latency(DelRand, dur.getMax());
return 0;
}
示例2: stat_random
int COpenTest::stat_random(BonTimer &timer)
{
random_sort(timer.random_source);
timer.start();
int i;
Duration dur;
for(i = 0; i < m_number; i++)
{
dur.start();
if(-1 == stat_file(m_file_names[i]))
return -1;
dur.stop();
}
timer.stop_and_record(StatRand);
timer.add_latency(StatRand, dur.getMax());
return 0;
}
示例3: stat_sequential
int COpenTest::stat_sequential(BonTimer &timer)
{
timer.start();
int count = 0;
Duration dur;
for(int i = 0; i < m_number_directories; i++)
{
char buf[6];
if(m_number_directories != 1)
{
sprintf(buf, "%05d", i);
if(chdir(buf))
{
fprintf(stderr, "Can't change to directory %s\n", buf);
return -1;
}
}
DIR *d = opendir(".");
if(!d)
{
fprintf(stderr, "Can't open directory.\n");
if(m_number_directories != 1)
{
if(chdir(".."))
fprintf(stderr, "Can't chdir().\n");
}
return -1;
}
dirent *file_ent;
while(1)
{
dur.start();
file_ent = readdir(d);
if(file_ent == NULL)
break;
if(*m_exit)
{
if(m_number_directories != 1 && chdir(".."))
{
fprintf(stderr, "Can't change to directory ..\n");
return -1;
}
return eCtrl_C;
}
if(file_ent->d_name[0] != '.') // our files do not start with a dot
{
if(-1 == stat_file(file_ent->d_name))
{
if(m_number_directories != 1)
{
if(chdir(".."))
{
fprintf(stderr, "Can't chdir().\n");
return -1;
}
}
dur.stop();
return -1;
}
count++;
dur.stop();
}
}
closedir(d);
if(m_number_directories != 1)
{
if(chdir(".."))
{
fprintf(stderr, "Can't change to directory ..\n");
return -1;
}
}
}
if(count != m_number)
{
fprintf(stderr, "Expected %d files but only got %d\n", m_number, count);
return -1;
}
timer.stop_and_record(StatSeq);
timer.add_latency(StatSeq, dur.getMax());
return 0;
}
示例4: delete_sequential
int COpenTest::delete_sequential(BonTimer &timer)
{
timer.start();
int count = 0;
Duration dur;
for(int i = 0; i < m_number_directories; i++)
{
char buf[6];
if(m_number_directories != 1)
{
sprintf(buf, "%05d", i);
if(chdir(buf))
{
fprintf(stderr, "Can't change to directory %s\n", buf);
return -1;
}
}
DIR *d = opendir(".");
if(!d)
{
fprintf(stderr, "Can't open directory.\n");
if(m_number_directories != 1)
{
if(chdir(".."))
fprintf(stderr, "Can't chdir().\n");
}
return -1;
}
dirent *file_ent;
while(1)
{
dur.start();
file_ent = readdir(d);
if(file_ent == NULL)
break;
if(file_ent->d_name[0] != '.')
{
if(unlink(file_ent->d_name))
{
fprintf(stderr, "Can't delete file %s\n", file_ent->d_name);
return -1;
}
if(m_sync && m_sync_dir)
{
if(fsync(m_directoryHandles[i]))
{
fprintf(stderr, "Can't sync directory, turning off dir-sync.\n");
m_sync_dir = false;
}
}
count++;
}
dur.stop();
}
closedir(d);
if(m_sync)
{
close(m_directoryHandles[i]);
}
if(m_number_directories != 1)
{
if(chdir("..") || rmdir(buf))
{
io_error("rmdir");
return -1;
}
}
}
if(chdir("..") || rmdir(m_dirname))
{
io_error("rmdir");
return -1;
}
delete m_dirname;
m_dirname = NULL;
if(count != m_number)
{
fprintf(stderr, "Expected %d files but only got %d\n", m_number, count);
return -1;
}
sync();
timer.stop_and_record(DelSeq);
timer.add_latency(DelSeq, dur.getMax());
return 0;
}
示例5: create
//.........这里部分代码省略.........
m_min = min_size;
m_size_range = m_max - m_min;
m_dirname = new char[strlen(dirname) + 1];
strcpy(m_dirname, dirname);
if(num_directories >= 100000)
{
fprintf(stderr, "Can't have more than 99,999 directories.\n");
return -1;
}
if(mkdir(dirname, S_IRWXU))
{
fprintf(stderr, "Can't make directory %s\n", dirname);
return -1;
}
if(chdir(dirname))
{
fprintf(stderr, "Can't change to directory %s\n", dirname);
return -1;
}
int i;
if(m_sync)
m_directoryHandles = new FILE_TYPE[num_directories];
if(num_directories > 1)
{
for(i = 0; i < num_directories; i++)
{
sprintf(m_buf, "%05d", i);
if(mkdir(m_buf, S_IRWXU))
{
fprintf(stderr, "Can't make directory %s\n", m_buf);
return -1;
}
if(m_sync)
{
m_directoryHandles[i] = open(m_buf, O_RDONLY);
if(m_directoryHandles[i] == -1)
{
fprintf(stderr, "Can't get directory handle.\n");
return -1;
}
}
}
}
else if(m_sync)
{
m_directoryHandles[0] = open(".", O_RDONLY);
if(m_directoryHandles[0] == -1)
{
fprintf(stderr, "Can't get directory handle.\n");
return -1;
}
}
Duration dur;
timer.start();
for(i = 0; i < m_number; i++)
{
if(*m_exit)
{
if(m_number_directories != 1 && chdir(".."))
{
fprintf(stderr, "Can't change to directory ..\n");
return -1;
}
return eCtrl_C;
}
dur.start();
// m_max < 0 means link or sym-link
if(m_max < 0)
{
if(i == 0)
{
if(create_a_file(m_file_names[0], m_buf, 0, m_dirIndex ? m_dirIndex[0] : 0))
return -1;
}
else
{
// create_a_link() looks at m_max to see what to do
if(create_a_link(m_file_names[0], m_file_names[i], m_dirIndex ? m_dirIndex[i] : 0))
return -1;
}
}
else
{
int size;
if(m_size_range)
size = m_min + (timer.random_source.getNum() % (m_size_range + 1));
else
size = m_max;
if(create_a_file(m_file_names[i], m_buf, size, m_dirIndex ? m_dirIndex[i] : 0))
return -1;
}
dur.stop();
}
sync();
timer.stop_and_record(do_random ? CreateRand : CreateSeq);
timer.add_latency(do_random ? CreateRand : CreateSeq, dur.getMax());
return 0;
}