1 /* Copyright (c) 2003-2005 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
23 // Class used for measuring time and priting the results
25 // Currently measures time in milliseconds
38 NDB_TICKS
elapsedTime();
39 void printTransactionStatistics(const char* text
,
42 void printTestTimer(int numLoops
,
44 void printTotalTime(void);
50 inline NdbTimer::NdbTimer(){
54 inline void NdbTimer::doReset(void){
59 inline void NdbTimer::doStart(void){
60 startTime
= NdbTick_CurrentMillisecond();
63 inline void NdbTimer::doStop(void){
64 stopTime
= NdbTick_CurrentMillisecond();
67 inline NDB_TICKS
NdbTimer::elapsedTime(void){
68 return (stopTime
- startTime
);
71 inline void NdbTimer::printTransactionStatistics(const char* text
,
75 // Convert to Uint32 in order to be able to print it to screen
76 Uint32 lapTime
= (Uint32
)elapsedTime();
77 ndbout_c("%i transactions, %i %s total time = %d ms\nAverage %f ms/transaction, %f ms/%s.\n%f transactions/second, %f %ss/second.\n",
78 numTransactions
, numTransactions
*numOperations
, text
, lapTime
,
79 ((double)lapTime
/numTransactions
), ((double)lapTime
/(numTransactions
*numOperations
)), text
,
80 1000.0/((double)lapTime
/numOperations
), 1000.0/((double)lapTime
/(numTransactions
*numOperations
)), text
);
85 inline void NdbTimer::printTestTimer(int numLoops
,
87 // Convert to Uint32 in order to be able to print it to screen
88 Uint32 lapTime
= (Uint32
)elapsedTime();
89 ndbout_c("%i loop * %i records, total time = %d ms\nAverage %f ms/loop, %f ms/record.\n%f looop/second, %f records/second.\n",
90 numLoops
, numRecords
, lapTime
,
91 ((double)lapTime
/numLoops
), ((double)lapTime
/(numLoops
*numRecords
)),
92 1000.0/((double)lapTime
/numLoops
), 1000.0/((double)lapTime
/(numLoops
*numRecords
)));
96 inline void NdbTimer::printTotalTime(void){
97 // Convert to Uint32 in order to be able to print it to screen
98 Uint32 lapTime
= (Uint32
)elapsedTime();
99 Uint32 secTime
= lapTime
/1000;
100 ndbout_c("Total time : %d seconds (%d ms)\n", secTime
, lapTime
);