home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-11-19 | 3.9 KB | 174 lines | [TEXT/MPS ] |
- /*
- File: TestTimings.cp
-
- Contains: Implementation of class TTestTimings
-
- Copyright: © 1992-1994 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #ifndef __TESTTIMINGS__
- #include "TestTimings.h"
- #endif
- #ifndef __MISCTESTS__
- #include "MiscTests.h"
- #endif
-
- class THelper : public TSimpleDynamic
- {
- public:
- THelper();
- ~_CDECL THelper();
- };
-
- THelper::THelper()
- {}
-
- THelper::~THelper()
- {}
-
- TTestTimings::TTestTimings()
- {}
-
- TTestTimings::~TTestTimings()
- {}
-
- void TTestTimings::InitTest(BooleanParm, BooleanParm, int, char**)
- {}
-
- void TTestTimings::EndTest(BooleanParm, BooleanParm)
- {}
-
- void StandardFunction(void*)
- {}
-
- void TTestTimings::RunTestIteration(BooleanParm, BooleanParm)
- {
- Boolean ok = true;
- unsigned long elapsed;
- size_t idx;
- unsigned long overhead;
-
- {
- TStopwatch watch;
- for (idx = 0; idx < 10000; ++idx)
- {
- }
- elapsed = (&watch)->ElapsedMicroseconds();
- unsigned long msec = elapsed/10000;
- unsigned long rest = ((elapsed % 10000))/10;
- Printf("### INFO: Loop overhead = %lu.%03lu Microseconds call\n",
- msec, rest);
- overhead = elapsed;
- }
- {
- TStopwatch watch;
- for (idx = 0; idx < 10000; ++idx)
- {
- StandardFunction(&watch);
- }
- elapsed = (&watch)->ElapsedMicroseconds() - overhead;
- unsigned long msec = elapsed/10000;
- unsigned long rest = ((elapsed % 10000))/10;
- Printf("### INFO: It took %lu.%03lu Microseconds per normal \"C\" Function call\n",
- msec, rest);
- }
- {
- TStopwatch watch;
- for (idx = 0; idx < 10000; ++idx)
- {
- THelper test;
- }
- elapsed = (&watch)->ElapsedMicroseconds() - overhead;
- unsigned long msec = elapsed/10000;
- unsigned long rest = ((elapsed % 10000))/10;
- Printf("### INFO: It took %lu.%03lu Microseconds per normal constructor/destructor pair\n",
- msec, rest);
- }
- {
- {
- TTimings foo;
- }
- TStopwatch watch;
- for (idx = 0; idx < 10000; ++idx)
- {
- TTimings test;
- }
- elapsed = (&watch)->ElapsedMicroseconds() - overhead;
- unsigned long msec = elapsed/10000;
- unsigned long rest = ((elapsed % 10000))/10;
- Printf("### INFO: It took %lu.%03lu Microseconds per shared constructor/destructor pair in \"thrash\" mode\n",
- msec, rest);
- }
- {
- TTimings foo;
- TStopwatch watch;
- for (idx = 0; idx < 10000; ++idx)
- {
- TTimings test;
- }
- elapsed = (&watch)->ElapsedMicroseconds() - overhead;
- unsigned long msec = elapsed/10000;
- unsigned long rest = ((elapsed % 10000))/10;
- Printf("### INFO: It took %lu.%03lu Microseconds per shared constructor/destructor pair\n",
- msec, rest);
- }
- {
- TTimings foo;
- (&foo)->VirtualFunc();
- TStopwatch watch;
- for (idx = 0; idx < 10000; ++idx)
- {
- (&foo)->VirtualFunc();
- }
- elapsed = (&watch)->ElapsedMicroseconds() - overhead;
- unsigned long msec = elapsed/10000;
- unsigned long rest = ((elapsed % 10000))/10;
- Printf("### INFO: It took %lu.%03lu Microseconds per virtual function call\n",
- msec, rest);
- }
- {
- TTimings foo;
- foo.VirtualFunc();
- TStopwatch watch;
- for (idx = 0; idx < 10000; ++idx)
- {
- foo.VirtualFunc();
- }
- elapsed = (&watch)->ElapsedMicroseconds() - overhead;
- unsigned long msec = elapsed/10000;
- unsigned long rest = ((elapsed % 10000))/10;
- Printf("### INFO: It took %lu.%03lu Microseconds per virtual function stub call\n",
- msec, rest);
- }
- {
- TTimings foo;
- foo.StaticFunc(&foo);
- TStopwatch watch;
- for (idx = 0; idx < 10000; ++idx)
- {
- foo.StaticFunc(&watch);
- }
- elapsed = (&watch)->ElapsedMicroseconds() - overhead;
- unsigned long msec = elapsed/10000;
- unsigned long rest = ((elapsed % 10000))/10;
- Printf("### INFO: It took %lu.%03lu Microseconds per static function stub call\n",
- msec, rest);
- }
- {
- TTimings foo;
- foo.Method();
- TStopwatch watch;
- for (idx = 0; idx < 10000; ++idx)
- {
- foo.Method();
- }
- elapsed = (&watch)->ElapsedMicroseconds() - overhead;
- unsigned long msec = elapsed/10000;
- unsigned long rest = ((elapsed % 10000))/10;
- Printf("### INFO: It took %lu.%03lu Microseconds per method stub call\n",
- msec, rest);
- }
-
- }
-