1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

0023880: Integration of grid "ncl" into the new testing system

Function perf_sprint_all_meters added in OSD_PerfMeter.h to allow printing to string buffer rather than stdout. Macro PERF_PRINT_ALL converted to functional form.

Command dperf added in DRAW to print and conditionally reset all meters.
Description of these tools is added in Debug Hints.

Modified output of command QANTestNCollectionPerformance.
Added test case perf/ncollection/A1

Modified ratio of performance to check all platforms

Small correction of test-case for Windows platform
This commit is contained in:
abv
2015-01-29 13:09:07 +03:00
committed by bugmaster
parent 76eeac70cf
commit 618617fe06
9 changed files with 245 additions and 113 deletions

View File

@@ -89,8 +89,16 @@ DEFINE_SEQUENCE(QANCollection_SequencePerf,QANCollection_BaseColPerf,ItemType)
DEFINE_HSEQUENCE(QANCollection_HSequencePerf,QANCollection_SequencePerf)
IMPLEMENT_HSEQUENCE(QANCollection_HSequencePerf)
static void printAllMeters (Draw_Interpretor& theDI)
{
char buffer[25600];
perf_sprint_all_meters (buffer, 25600 - 1, 1);
theDI << buffer;
}
// ===================== Test perform of Array1 type ==========================
static void CompArray1 (const Standard_Integer theRep,
static void CompArray1 (Draw_Interpretor& theDI,
const Standard_Integer theRep,
const Standard_Integer theSize)
{
Standard_Integer i,j;
@@ -169,11 +177,12 @@ static void CompArray1 (const Standard_Integer theRep,
////////////////////////////////aTOper.Stop();
PERF_STOP_METER("TCollection_Array1 operator=")
}
PERF_PRINT_ALL
printAllMeters(theDI);
}
// ===================== Test perform of Array2 type ==========================
static void CompArray2 (const Standard_Integer theRep,
static void CompArray2 (Draw_Interpretor& theDI,
const Standard_Integer theRep,
const Standard_Integer theSize)
{
Standard_Integer i,j,k;
@@ -256,11 +265,12 @@ static void CompArray2 (const Standard_Integer theRep,
////////////////////////////////aTOper.Stop();
PERF_STOP_METER("TCollection_Array2 operator=")
}
PERF_PRINT_ALL
printAllMeters(theDI);
}
// ===================== Test perform of List type ==========================
static void CompList (const Standard_Integer theRep,
static void CompList (Draw_Interpretor& theDI,
const Standard_Integer theRep,
const Standard_Integer theSize)
{
Standard_Integer i,j;
@@ -327,11 +337,12 @@ static void CompList (const Standard_Integer theRep,
////////////////////////////////aTClea.Stop();
PERF_STOP_METER("TCollection_List clearing")
}
PERF_PRINT_ALL
printAllMeters(theDI);
}
// ===================== Test perform of Sequence type ==========================
static void CompSequence (const Standard_Integer theRep,
static void CompSequence (Draw_Interpretor& theDI,
const Standard_Integer theRep,
const Standard_Integer theSize)
{
Standard_Integer i,j;
@@ -420,11 +431,12 @@ static void CompSequence (const Standard_Integer theRep,
////////////////////////////////aTClea.Stop();
PERF_STOP_METER("TCollection_Sequence clearing")
}
PERF_PRINT_ALL
printAllMeters(theDI);
}
// ===================== Test perform of Map type ==========================
static void CompMap (const Standard_Integer theRep,
static void CompMap (Draw_Interpretor& theDI,
const Standard_Integer theRep,
const Standard_Integer theSize)
{
Standard_Integer i,j;
@@ -513,11 +525,12 @@ static void CompMap (const Standard_Integer theRep,
////////////////////////////////aTClea.Stop();
PERF_STOP_METER("TCollection_Map clearing")
}
PERF_PRINT_ALL
printAllMeters(theDI);
}
// ===================== Test perform of DataMap type ==========================
static void CompDataMap (const Standard_Integer theRep,
static void CompDataMap (Draw_Interpretor& theDI,
const Standard_Integer theRep,
const Standard_Integer theSize)
{
Standard_Integer i,j;
@@ -608,11 +621,12 @@ static void CompDataMap (const Standard_Integer theRep,
////////////////////////////////aTClea.Stop();
PERF_STOP_METER("TCollection_DataMap clearing")
}
PERF_PRINT_ALL
printAllMeters(theDI);
}
// ===================== Test perform of DoubleMap type ==========================
static void CompDoubleMap (const Standard_Integer theRep,
static void CompDoubleMap (Draw_Interpretor& theDI,
const Standard_Integer theRep,
const Standard_Integer theSize)
{
Standard_Integer i,j;
@@ -718,14 +732,15 @@ static void CompDoubleMap (const Standard_Integer theRep,
////////////////////////////////aTClea.Stop();
PERF_STOP_METER("TCollection_DoubleMap clearing")
}
PERF_PRINT_ALL
printAllMeters(theDI);
if (iFail1 || iFail2)
cout << "Warning : N map failed " << iFail1 << " times, T map - " <<
iFail2 << endl;
}
// ===================== Test perform of IndexedMap type ==========================
static void CompIndexedMap (const Standard_Integer theRep,
static void CompIndexedMap (Draw_Interpretor& theDI,
const Standard_Integer theRep,
const Standard_Integer theSize)
{
Standard_Integer i,j;
@@ -815,11 +830,12 @@ static void CompIndexedMap (const Standard_Integer theRep,
////////////////////////////////aTClea.Stop();
PERF_STOP_METER("TCollection_IndexedMap clearing")
}
PERF_PRINT_ALL
printAllMeters(theDI);
}
// ===================== Test perform of IndexedDataMap type ==========================
static void CompIndexedDataMap (const Standard_Integer theRep,
static void CompIndexedDataMap (Draw_Interpretor& theDI,
const Standard_Integer theRep,
const Standard_Integer theSize)
{
Standard_Integer i,j;
@@ -911,11 +927,13 @@ static void CompIndexedDataMap (const Standard_Integer theRep,
////////////////////////////////aTClea.Stop();
PERF_STOP_METER("TCollection_IndexedDataMap clearing")
}
PERF_PRINT_ALL
printAllMeters(theDI);
}
// ===================== Test perform of SparseArray type ==========================
static void CompSparseArray (const Standard_Integer theRep, const Standard_Integer theSize)
static void CompSparseArray (Draw_Interpretor& theDI,
const Standard_Integer theRep,
const Standard_Integer theSize)
{
Standard_Integer i,j;
for (i=0; i<theRep; i++)
@@ -968,7 +986,7 @@ static void CompSparseArray (const Standard_Integer theRep, const Standard_Integ
}
PERF_PRINT_ALL
printAllMeters(theDI);
}
//=======================================================================
@@ -1005,7 +1023,7 @@ static Standard_Integer QANColPerfArray1(Draw_Interpretor& di, Standard_Integer
if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
return 1;
}
CompArray1(Repeat,Size);
CompArray1 (di, Repeat, Size);
return 0;
}
@@ -1019,7 +1037,7 @@ static Standard_Integer QANColPerfArray2(Draw_Interpretor& di, Standard_Integer
if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
return 1;
}
CompArray2(Repeat,Size);
CompArray2 (di, Repeat, Size);
return 0;
}
@@ -1033,7 +1051,7 @@ static Standard_Integer QANColPerfList(Draw_Interpretor& di, Standard_Integer ar
if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
return 1;
}
CompList(Repeat,Size);
CompList (di, Repeat, Size);
return 0;
}
@@ -1047,7 +1065,7 @@ static Standard_Integer QANColPerfSequence(Draw_Interpretor& di, Standard_Intege
if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
return 1;
}
CompSequence(Repeat,Size);
CompSequence (di, Repeat, Size);
return 0;
}
@@ -1061,7 +1079,7 @@ static Standard_Integer QANColPerfMap(Draw_Interpretor& di, Standard_Integer arg
if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
return 1;
}
CompMap(Repeat,Size);
CompMap (di, Repeat, Size);
return 0;
}
@@ -1075,7 +1093,7 @@ static Standard_Integer QANColPerfDataMap(Draw_Interpretor& di, Standard_Integer
if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
return 1;
}
CompDataMap(Repeat,Size);
CompDataMap (di, Repeat, Size);
return 0;
}
@@ -1089,7 +1107,7 @@ static Standard_Integer QANColPerfDoubleMap(Draw_Interpretor& di, Standard_Integ
if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
return 1;
}
CompDoubleMap(Repeat,Size);
CompDoubleMap (di, Repeat, Size);
return 0;
}
@@ -1103,7 +1121,7 @@ static Standard_Integer QANColPerfIndexedMap(Draw_Interpretor& di, Standard_Inte
if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
return 1;
}
CompIndexedMap(Repeat,Size);
CompIndexedMap (di, Repeat, Size);
return 0;
}
@@ -1117,7 +1135,7 @@ static Standard_Integer QANColPerfIndexedDataMap(Draw_Interpretor& di, Standard_
if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
return 1;
}
CompIndexedDataMap(Repeat,Size);
CompIndexedDataMap (di, Repeat, Size);
return 0;
}
@@ -1131,7 +1149,7 @@ static Standard_Integer QANColCheckSparseArray(Draw_Interpretor& di, Standard_In
if ( CheckArguments(di, argc, argv, Repeat, Size) ) {
return 1;
}
CompSparseArray(Repeat,Size);
CompSparseArray (di, Repeat, Size);
return 0;
}

View File

@@ -30,9 +30,11 @@ typedef NCollection_Sequence<gp_Pnt> MySequence;
const Standard_Integer REPEAT = 100;
void printAllMeters ()
static void printAllMeters (Draw_Interpretor& theDI)
{
PERF_PRINT_ALL
char buffer[25600];
perf_sprint_all_meters (buffer, 25600 - 1, 1);
theDI << buffer;
}
static void createArray (TColgp_Array1OfPnt& anArrPnt)
@@ -132,7 +134,7 @@ static void assignArray (MyArray1& aDest, const MyArray1& aSrc)
}
}
static void checkArray (const Standard_Boolean isNewColl)
static void checkArray (Draw_Interpretor& theDI, const Standard_Boolean isNewColl)
{
if (isNewColl) {
MyArray1 anArrPnt (1, 100000), anArrPnt1 (1, 100000);
@@ -144,10 +146,11 @@ static void checkArray (const Standard_Boolean isNewColl)
createArray (anArrPnt);
assignArray (anArrPnt1, anArrPnt);
}
printAllMeters ();
printAllMeters (theDI);
}
static void checkSequence (const Standard_Boolean isNewColl,
static void checkSequence (Draw_Interpretor& theDI,
const Standard_Boolean isNewColl,
const Standard_Boolean isIncr)
{
if (isNewColl) {
@@ -165,7 +168,7 @@ static void checkSequence (const Standard_Boolean isNewColl,
createSequence (aSeqPnt);
assignSequence (aSeqPnt1, aSeqPnt);
}
printAllMeters ();
printAllMeters (theDI);
}
//=======================================================================
@@ -183,7 +186,7 @@ static Standard_Integer QANColCheckArray1(Draw_Interpretor& di, Standard_Integer
if (argc > 1) {
if (strcmp (argv[1], "-n") == 0) isNewColl = Standard_True;
}
checkArray (isNewColl);
checkArray (di, isNewColl);
return 0;
}
@@ -207,7 +210,7 @@ static Standard_Integer QANColCheckSequence(Draw_Interpretor& di, Standard_Integ
isIncr = Standard_True;
}
}
checkSequence (isNewColl, isIncr);
checkSequence (di, isNewColl, isIncr);
return 0;
}

View File

@@ -947,7 +947,7 @@ static Standard_Integer QANTestStlIterators (
//purpose :
//=======================================================================
template<class CollectionType, class StlType>
void TestPerformanceRandomIterator()
void TestPerformanceRandomIterator(Draw_Interpretor& di)
{
OSD_Timer aTimer;
@@ -986,12 +986,12 @@ void TestPerformanceRandomIterator()
Standard_Real aOccTime = aTimer.ElapsedTime();
std::cout << aSize << "\t" << aStlTime << "\t" <<
aOccTime << "\t" << aOccTime / aStlTime << std::endl;
di << aSize << "\t" << aStlTime << "\t" <<
aOccTime << "\t" << aOccTime / aStlTime << "\n";
// check that result is the same
if ( ! std::equal (aVector->begin(), aVector->end(), aCollec->begin()) )
std::cout << "Error: sequences are not the same at the end!" << std::endl;
di << "Error: sequences are not the same at the end!" << "\n";
delete aVector;
delete aCollec;
@@ -1003,7 +1003,7 @@ void TestPerformanceRandomIterator()
//purpose :
//=======================================================================
template<class CollectionType, class StlType>
void TestPerformanceForwardIterator()
void TestPerformanceForwardIterator(Draw_Interpretor& di)
{
OSD_Timer aTimer;
@@ -1038,12 +1038,12 @@ void TestPerformanceForwardIterator()
Standard_Real aOccTime = aTimer.ElapsedTime();
std::cout << aSize << "\t" << aStlTime << "\t" <<
aOccTime << "\t" << aOccTime / aStlTime << std::endl;
di << aSize << "\t" << aStlTime << "\t" <<
aOccTime << "\t" << aOccTime / aStlTime << "\n";
// check that result is the same
if ( ! std::equal (aVector->begin(), aVector->end(), aCollec->begin()) )
std::cout << "Error: sequences are not the same at the end!" << std::endl;
di << "Error: sequences are not the same at the end!" << "\n";
delete aVector;
delete aCollec;
@@ -1055,7 +1055,7 @@ void TestPerformanceForwardIterator()
//purpose :
//=======================================================================
template<class CollectionType, class StlType>
void TestPerformanceBidirIterator()
void TestPerformanceBidirIterator(Draw_Interpretor& di)
{
OSD_Timer aTimer;
@@ -1090,12 +1090,12 @@ void TestPerformanceBidirIterator()
Standard_Real aOccTime = aTimer.ElapsedTime();
std::cout << aSize << "\t" << aStlTime << "\t" <<
aOccTime << "\t" << aOccTime / aStlTime << std::endl;
di << aSize << "\t" << aStlTime << "\t" <<
aOccTime << "\t" << aOccTime / aStlTime << "\n";
// check that result is the same
if ( ! std::equal (aVector->begin(), aVector->end(), aCollec->begin()) )
std::cout << "Error: sequences are not the same at the end!" << std::endl;
di << "Error: sequences are not the same at the end!" << "\n";
delete aVector;
delete aCollec;
@@ -1107,7 +1107,7 @@ void TestPerformanceBidirIterator()
//purpose :
//=======================================================================
template<class CollectionType, class T>
void TestPerformanceMapAccess()
void TestPerformanceMapAccess(Draw_Interpretor& di)
{
OSD_Timer aTimer;
@@ -1166,8 +1166,8 @@ void TestPerformanceMapAccess()
if (aResult)
{
std::cout << aSize << "\t" << aStlTime << "\t" <<
aOccTime << "\t" << (aStlTime > 1e-16 ? aOccTime / aStlTime : -1) << std::endl;
di << aSize << "\t" << aStlTime << "\t" <<
aOccTime << "\t" << (aStlTime > 1e-16 ? aOccTime / aStlTime : -1) << "\n";
}
delete aCollec;
@@ -1178,42 +1178,37 @@ void TestPerformanceMapAccess()
//function : QANTestNCollectionPerformance
//purpose :
//=======================================================================
static Standard_Integer QANTestNCollectionPerformance (
Draw_Interpretor& /*theInterpretor*/, Standard_Integer, const char**)
static Standard_Integer QANTestNCollectionPerformance (Draw_Interpretor& di, Standard_Integer, const char**)
{
std::cout.precision (8);
di << "Testing performance (Size | STL time | OCCT time | STL/OCCT boost)" << "\n";
std::cout << "Testing performance (Size | STL time | OCCT time | STL/OCCT boost)\n";
di << "\n" << "std::vector vs NCollection_Array1 (sort):" << "\n\n";
TestPerformanceRandomIterator<NCollection_Array1<double>, std::vector<double> >(di);
di << "\n" << "std::vector vs NCollection_Vector (sort):" << "\n\n";
TestPerformanceRandomIterator<NCollection_Vector<double>, std::vector<double> >(di);
di << "\n" << "std::vector vs NCollection_Array1 (replace):" << "\n\n";
TestPerformanceForwardIterator<NCollection_Array1<double>, std::vector<double> >(di);
di << "\n" << "std::vector vs NCollection_Vector (replace):" << "\n\n";
TestPerformanceForwardIterator<NCollection_Vector<double>, std::vector<double> >(di);
std::cout << std::endl << "std::vector vs NCollection_Array1 (sort):\n" << std::endl;
TestPerformanceRandomIterator<NCollection_Array1<double>, std::vector<double> >();
di << "\n" << "std::list vs NCollection_List (replace):" << "\n\n";
TestPerformanceForwardIterator<NCollection_List<double>, std::list<double> >(di);
std::cout << std::endl << "std::vector vs NCollection_Vector (sort):\n" << std::endl;
TestPerformanceRandomIterator<NCollection_Vector<double>, std::vector<double> >();
di << "\n" << "std::list vs NCollection_Sequence (replace):" << "\n\n";
TestPerformanceForwardIterator<NCollection_Sequence<double>, std::list<double> >(di);
std::cout << std::endl << "std::vector vs NCollection_Array1 (replace):\n" << std::endl;
TestPerformanceForwardIterator<NCollection_Array1<double>, std::vector<double> >();
di << "\n" << "std::list vs NCollection_Sequence (reverse):" << "\n\n";
TestPerformanceBidirIterator<NCollection_Sequence<double>, std::list<double> >(di);
std::cout << std::endl << "std::vector vs NCollection_Vector (replace):\n" << std::endl;
TestPerformanceForwardIterator<NCollection_Vector<double>, std::vector<double> >();
std::cout << std::endl << "std::list vs NCollection_List (replace):\n" << std::endl;
TestPerformanceForwardIterator<NCollection_List<double>, std::list<double> >();
std::cout << std::endl << "std::list vs NCollection_Sequence (replace):\n" << std::endl;
TestPerformanceForwardIterator<NCollection_Sequence<double>, std::list<double> >();
std::cout << std::endl << "std::list vs NCollection_Sequence (reverse):\n" << std::endl;
TestPerformanceBidirIterator<NCollection_Sequence<double>, std::list<double> >();
std::cout << std::endl << "std::set vs NCollection_Map (search):\n" << std::endl;
TestPerformanceMapAccess<NCollection_Map<int>, int>();
std::cout << std::endl << "std::set vs NCollection_IndexedMap (search):\n" << std::endl;
TestPerformanceMapAccess<NCollection_IndexedMap<int>, int>();
std::cout.unsetf (std::ios::floatfield);
di << "\n" << "std::set vs NCollection_Map (search):" << "\n\n";
TestPerformanceMapAccess<NCollection_Map<int>, int>(di);
di << "\n" << "std::set vs NCollection_IndexedMap (search):" << "\n\n";
TestPerformanceMapAccess<NCollection_IndexedMap<int>, int>(di);
return 0;
}