本文整理汇总了C++中TextStream::flush方法的典型用法代码示例。如果您正苦于以下问题:C++ TextStream::flush方法的具体用法?C++ TextStream::flush怎么用?C++ TextStream::flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextStream
的用法示例。
在下文中一共展示了TextStream::flush方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
try {
ecl::set_priority(ecl::RealTimePriority4);
} catch ( StandardException &e ) {
// dont worry about it.
}
StopWatch stopwatch;
TimeStamp times[22];
unsigned int lines_to_write = 500;// Buffer::buffer_size/10 + 1;
float f = 33.54;
std::cout << std::endl;
std::cout << "***********************************************************" << std::endl;
std::cout << " OFile Write" << std::endl;
std::cout << "***********************************************************" << std::endl;
std::cout << std::endl;
OFile o_file("odude.txt",New);
for ( unsigned int i = 0; i < lines_to_write; ++i ) { // Avoid speedups from caching affecting times.
o_file.write("Heya Dude\n",10);
}
o_file.flush();
stopwatch.restart();
for ( unsigned int i = 0; i < lines_to_write; ++i ) {
o_file.write("Heya Dude\n",10);
}
o_file.flush();
times[0] = stopwatch.split();
std::cout << std::endl;
std::cout << "***********************************************************" << std::endl;
std::cout << " Shared File Write" << std::endl;
std::cout << "***********************************************************" << std::endl;
std::cout << std::endl;
SharedFile s_file("sdude.txt",New);
for ( unsigned int i = 0; i < lines_to_write; ++i ) { // Avoid speedups from caching affecting times.
s_file.write("Heya Dude\n",10);
}
s_file.flush();
stopwatch.restart();
for ( unsigned int i = 0; i < lines_to_write; ++i ) {
s_file.write("Heya Dude\n",10);
}
s_file.flush();
times[1] = stopwatch.split();
std::cout << std::endl;
std::cout << "***********************************************************" << std::endl;
std::cout << " TextStream<OFile>" << std::endl;
std::cout << "***********************************************************" << std::endl;
std::cout << std::endl;
TextStream<OFile> ostream;
ostream.device().open("dude_stream.txt",New);
stopwatch.restart();
for ( unsigned int i = 0; i < lines_to_write; ++i ) {
ostream << "Heya Dude\n";
}
ostream.flush();
stopwatch.restart();
for ( unsigned int i = 0; i < lines_to_write; ++i ) {
ostream << "Heya Dude\n";
}
ostream.flush();
times[2] = stopwatch.split();
stopwatch.restart();
for ( unsigned int i = 0; i < lines_to_write; ++i ) {
ostream << f << "\n";
}
ostream.flush();
stopwatch.restart();
for ( unsigned int i = 0; i < lines_to_write; ++i ) {
ostream << f << "\n";
}
ostream.flush();
times[3] = stopwatch.split();
std::cout << std::endl;
std::cout << "***********************************************************" << std::endl;
std::cout << " std::ofstream" << std::endl;
std::cout << "***********************************************************" << std::endl;
std::cout << std::endl;
std::ofstream cpp_ostream("dude_ofstream.txt");
stopwatch.restart();
for ( unsigned int i = 0; i < lines_to_write; ++i ) {
cpp_ostream << "Heya Dude\n";
}
cpp_ostream.flush();
stopwatch.restart();
for ( unsigned int i = 0; i < lines_to_write; ++i ) {
cpp_ostream << "Heya Dude\n";
}
cpp_ostream.flush();
times[4] = stopwatch.split();
stopwatch.restart();
for ( unsigned int i = 0; i < lines_to_write; ++i ) {
cpp_ostream << f << "\n";
//.........这里部分代码省略.........