本文整理汇总了C++中SimpleTimer::getElapsedTime方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleTimer::getElapsedTime方法的具体用法?C++ SimpleTimer::getElapsedTime怎么用?C++ SimpleTimer::getElapsedTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleTimer
的用法示例。
在下文中一共展示了SimpleTimer::getElapsedTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
SelSorter dateObjectI1;
MrgSorter dateObjectM1;
QkSorter dateObjectQ1;
DateType dateValue;
SimpleTimer timer;
char tempString[ SMALL_STR_LEN ], insTime[ SMALL_STR_LEN ];
char qkTime[ SMALL_STR_LEN ], mrgTime[ SMALL_STR_LEN ];
bool qSortGood = false, mSortGood = false, iSortGood = false;
// load dates ////////////////////////////////////////////////////////////
cout << endl << "Enter list of dates: " << endl;
while( getALine( cin, tempString ) )
{
dateObjectI1.add( tempString );
}
// assign dates to other objects /////////////////////////////////////////
dateObjectM1 = dateObjectI1;
dateObjectQ1 = dateObjectM1;
// display lists, unsorted ///////////////////////////////////////////////
displayList( dateObjectI1, 'S', UNSORTED );
displayList( dateObjectM1, 'M', UNSORTED );
displayList( dateObjectQ1, 'Q', UNSORTED );
// Selection sort operation //////////////////////////////////////////////
timer.start();
if( dateObjectI1.sort() )
{
timer.stop();
timer.getElapsedTime( insTime );
displayList( dateObjectI1, 'S', SORTED );
iSortGood = true;
}
// stop timer in case of failure
timer.stop();
// Merge sort operation //////////////////////////////////////////////////
timer.start();
if( dateObjectM1.sort() )
{
timer.stop();
timer.getElapsedTime( mrgTime );
displayList( dateObjectM1, 'M', SORTED );
mSortGood = true;
}
// stop timer in case of failure
timer.stop();
// Quick sort operation //////////////////////////////////////////////////
timer.start();
if( dateObjectQ1.sort() )
{
timer.stop();
timer.getElapsedTime( qkTime );
displayList( dateObjectQ1, 'Q', SORTED );
qSortGood = true;
}
// stop timer in case of failure
timer.stop();
// Results displayed /////////////////////////////////////////////////////
if( iSortGood )
{
cout << "Elapsed Time for Selection Sort: "
<< insTime << " seconds." << endl;
}
else
{
cout << "ERROR: Failure of Selection sort due to bad input"
<< endl << endl;
}
if( mSortGood )
{
cout << endl << "Elapsed Time for Merge Sort: "
<< mrgTime << " seconds." << endl;
}
else
{
cout << "ERROR: Failure of merge sort due to bad input"
<< endl << endl;
}
if( qSortGood )
{
cout << endl << "Elapsed Time for Quick Sort: "
//.........这里部分代码省略.........