31 #include <ndb_global.h>
34 #include <NdbTest.hpp>
36 #include <NdbThread.h>
39 #include <NdbTimer.hpp>
47 #define NDB_MAXTHREADS 256
55 #define MAXATTRSIZE 8000
56 #define START_TIMER NdbTimer timer; timer.doStart();
57 #define STOP_TIMER timer.doStop();
58 #define START_TIMER_TOP NdbTimer timer_top; timer_top.doStart();
59 #define STOP_TIMER_TOP timer_top.doStop();
61 void* ThreadExec(
void*);
69 static NdbThread* threadLife[NDB_MAXTHREADS];
70 static unsigned int tNoOfThreads;
71 static unsigned int tNoOfOpsPerExecute;
72 static unsigned int tNoOfRecords;
73 static unsigned int tNoOfOperations;
74 static int ThreadReady[NDB_MAXTHREADS];
75 static int ThreadStart[NDB_MAXTHREADS];
77 NDB_COMMAND(benchronja,
"benchronja",
"benchronja",
"benchronja", 65535){
89 tNoOfOpsPerExecute = 1;
90 tNoOfOperations = 100000;
95 if (strcmp(argv[i],
"-t") == 0){
96 tNoOfThreads = atoi(argv[i+1]);
97 if ((tNoOfThreads < 1) || (tNoOfThreads > NDB_MAXTHREADS))
goto error_input;
98 }
else if (strcmp(argv[i],
"-o") == 0){
99 tNoOfOperations = atoi(argv[i+1]);
100 if (tNoOfOperations < 1)
goto error_input;
101 }
else if (strcmp(argv[i],
"-r") == 0){
102 tNoOfRecords = atoi(argv[i+1]);
103 if ((tNoOfRecords < 1) || (tNoOfRecords > 1000000000))
goto error_input;
104 }
else if (strcmp(argv[i],
"-p") == 0){
105 nTest = atoi(argv[i+1]) ;
106 if (0 > nTest || 18 < nTest)
goto error_input ;
107 }
else if (strcmp(argv[i],
"-c") == 0){
108 tNoOfOpsPerExecute = atoi(argv[i+1]);
109 if ((tNoOfOpsPerExecute < 1) || (tNoOfOpsPerExecute > 1024))
goto error_input;
117 ndbout <<
"Initialisation started. " << endl;
118 pMyNdb =
new Ndb(
"TEST_DB") ;
120 ndbout <<
"Initialisation completed. " << endl;
122 ndbout << endl <<
"Execute Ronja Benchmark" << endl;
123 ndbout <<
" NdbAPI node with id = " << pMyNdb->
getNodeId() << endl;
124 ndbout <<
" " << tNoOfThreads <<
" thread(s) " << endl;
125 ndbout <<
" " << tNoOfOperations <<
" transaction(s) per thread and round " << endl;
128 ndbout <<
"Benchmark failed - NDB is not ready" << endl;
130 return NDBT_ProgramExit(NDBT_FAILED);
133 NdbThread_SetConcurrencyLevel(2 + tNoOfThreads);
135 for (i = 0; i < tNoOfThreads ; i++) {
140 for (i = 0; i < tNoOfThreads ; i++) {
141 tabThread[
i].ThreadNo =
i;
142 tabThread[
i].NdbRef = NULL;
143 tabThread[
i].NoOfOps = tNoOfOperations;
144 threadLife[
i] = NdbThread_Create(ThreadExec,
145 (
void**)&tabThread[i],
148 NDB_THREAD_PRIO_LOW);
153 NdbSleep_MilliSleep(10);
155 for (i = 0; i < tNoOfThreads ; i++)
156 if (!ThreadReady[i]) cont = 1;
159 ndbout <<
"All threads started" << endl;
166 ndbout << endl <<
"What to do next:" << endl;
167 ndbout <<
"1 \t=> Perform lookups in short table" << endl;
168 ndbout <<
"2 \t=> Perform lookups in long table" << endl;
169 ndbout <<
"3 \t=> Perform updates in short table" << endl;
170 ndbout <<
"4 \t=> Perform updates in long table" << endl;
171 ndbout <<
"5 \t=> Perform 50% lookups/50% updates in short table" << endl;
172 ndbout <<
"6 \t=> Perform 50% lookups/50% updates in long table" << endl;
173 ndbout <<
"7 \t=> Perform 80% lookups/20% updates in short table" << endl;
174 ndbout <<
"8 \t=> Perform 80% lookups/20% updates in long table" << endl;
175 ndbout <<
"9 \t=> Perform 25% lookups short/25% lookups long/25% updates short/25% updates long" << endl;
176 ndbout <<
"10\t=> Test bug with replicated interpreted updates, short table" << endl;
177 ndbout <<
"11\t=> Test interpreter functions, short table" << endl;
178 ndbout <<
"12\t=> Test bug with replicated interpreted updates, long table" << endl;
179 ndbout <<
"13\t=> Test interpreter functions, long table" << endl;
180 ndbout <<
"14\t=> Perform lookups in short table, no guess of TC" << endl;
181 ndbout <<
"15\t=> Perform lookups in long table, no guess of TC" << endl;
182 ndbout <<
"16\t=> Perform updates in short table, no guess of TC" << endl;
183 ndbout <<
"17\t=> Perform updates in long table, no guess of TC" << endl;
184 ndbout <<
"18\t=> Multi record updates of transactions" << endl;
185 ndbout <<
"All other responses will exit" << endl;
186 ndbout <<
"_____________________________" << endl << endl ;
190 inp[inp_i] = (char) fgetc(stdin);
191 if (inp[inp_i] ==
'\n' || inp[inp_i] == EOF) {
197 }
while (inp[inp_i - 1] !=
'\n' && inp[inp_i - 1] != EOF);
201 if ((tmp > 18) || (tmp <= 0))
break;
203 ndbout <<
"Starting test " << tmp <<
"..." << endl;
205 for (i = 0; i < tNoOfThreads ; i++){ ThreadStart[
i] = tmp; }
209 NdbSleep_MilliSleep(10);
211 for (i = 0; i < tNoOfThreads ; i++){
212 if (!ThreadReady[i]) cont = 1;
220 ndbout <<
"Executing all 18 available tests..." << endl << endl;
221 for (
int count = 1; count < nTest; count++){
222 ndbout <<
"Test " << count << endl ;
223 ndbout <<
"------" << endl << endl ;
224 for (i = 0; i < tNoOfThreads ; i++) { ThreadStart[
i] = count ; }
227 NdbSleep_MilliSleep(10);
229 for (i = 0; i < tNoOfThreads ; i++){
230 if (!ThreadReady[i]) cont = 1;
235 ndbout << endl <<
"Executing test " << nTest << endl << endl;
236 for (i = 0; i < tNoOfThreads ; i++) { ThreadStart[
i] = nTest ; }
239 NdbSleep_MilliSleep(10);
241 for (i = 0; i < tNoOfThreads ; i++){
242 if (!ThreadReady[i]) cont = 1;
248 ndbout <<
"--------------------------------------------------" << endl;
250 for (i = 0; i < tNoOfThreads ; i++) ThreadReady[i] = 0;
252 for (i = 0; i < tNoOfThreads ; i++) ThreadStart[i] = 999;
257 NdbSleep_MilliSleep(1);
259 for (i = 0; i < tNoOfThreads ; i++){
260 if (ThreadReady[i] == 0) cont = 1;
265 ndbout << endl <<
"Ronja Benchmark completed" << endl;
266 return NDBT_ProgramExit(NDBT_OK) ;
269 ndbout << endl <<
" Ivalid parameter(s)" << endl;
270 ndbout <<
" Usage: benchronja [-t threads][-r rec] [-o ops] [-c ops_per_exec] [-p test], where:" << endl;
271 ndbout <<
" threads - the number of threads to start; default: 1" << endl;
272 ndbout <<
" rec - the number of records in the tables; default: 500" << endl;
273 ndbout <<
" ops - the number of operations per transaction; default: 100000" << endl;
274 ndbout <<
" ops_per_exec - the number of operations per execution; default: 1" << endl ;
275 ndbout <<
" test - the number of test to execute; 19 executes all available tests; default: 0"<< endl ;
276 ndbout <<
" which enters a loop expecting manual input of test number to execute." << endl << endl ;
278 return NDBT_ProgramExit(NDBT_WRONGARGS) ;
292 int ret = aCon->
execute(Rollback);
297 void updateNoCommit(
NdbConnection* aCon, Uint32* flip,
unsigned int key)
304 theOperation->
equal((Uint32)0, key);
305 theOperation->
setValue((Uint32)1, (
char*)flip);
306 int ret = aCon->
execute(NoCommit);
310 void updateNoCommitFail(
NdbConnection* aCon,
unsigned int key)
317 theOperation->
equal((Uint32)0, key);
318 theOperation->
setValue((Uint32)1, (
char*)flip);
319 int ret = aCon->
execute(NoCommit);
323 void deleteNoCommit(
NdbConnection* aCon, Uint32* flip,
unsigned int key)
330 theOperation->
equal((Uint32)0, key);
331 int ret = aCon->
execute(NoCommit);
335 void insertNoCommit(
NdbConnection* aCon, Uint32* flip,
unsigned int key)
338 Uint32 placeholder[100];
343 theOperation->
equal((Uint32)0, key);
344 theOperation->
setValue((Uint32)1, (
char*)flip);
345 theOperation->
setValue((Uint32)2, (
char*)&placeholder[0]);
346 theOperation->
setValue((Uint32)3, (
char*)&placeholder[0]);
347 int ret = aCon->
execute(NoCommit);
351 void writeNoCommit(
NdbConnection* aCon, Uint32* flip,
unsigned int key)
354 Uint32 placeholder[100];
359 theOperation->
equal((Uint32)0, key);
360 theOperation->
setValue((Uint32)1, (
char*)flip);
361 theOperation->
setValue((Uint32)2, (
char*)&placeholder[0]);
362 theOperation->
setValue((Uint32)3, (
char*)&placeholder[0]);
363 int ret = aCon->
execute(NoCommit);
367 void readNoCommit(
NdbConnection* aCon, Uint32* flip, Uint32 key,
int expected_ret)
374 theOperation->
equal((Uint32)0, key);
375 theOperation->
getValue((Uint32)1, (
char*)&readFlip);
376 int ret = aCon->
execute(NoCommit);
377 assert (ret == expected_ret);
379 assert (*flip == readFlip);
382 void readDirtyNoCommit(
NdbConnection* aCon, Uint32* flip, Uint32 key,
int expected_ret)
389 theOperation->
equal((Uint32)0, key);
390 theOperation->
getValue((Uint32)1, (
char*)&readFlip);
391 int ret = aCon->
execute(NoCommit);
392 assert (ret == expected_ret);
394 assert (*flip == readFlip);
397 void readVerify(
Ndb* aNdb, Uint32* flip, Uint32 key,
int expected_ret)
401 readNoCommit(theTransaction, flip, key, expected_ret);
402 commitTrans(aNdb, theTransaction);
405 void readDirty(
Ndb* aNdb, Uint32* flip, Uint32 key,
int expected_ret)
414 theOperation->
equal((Uint32)0, key);
415 theOperation->
getValue((Uint32)1, (
char*)&readFlip);
416 int ret = theTransaction->
execute(Commit);
417 assert (ret == expected_ret);
419 assert (*flip == readFlip);
423 int multiRecordTest(
Ndb* aNdb,
unsigned int key)
428 ndbout <<
"0" << endl;
432 updateNoCommit(theTransaction, &flip, key);
434 readNoCommit(theTransaction, &flip, key, 0);
436 updateNoCommit(theTransaction, &flip, key);
438 readNoCommit(theTransaction, &flip, key, 0);
440 commitTrans(aNdb, theTransaction);
442 ndbout <<
"1 " << endl;
444 readVerify(aNdb, &flip, key, 0);
445 readDirty(aNdb, &flip, key, 0);
447 ndbout <<
"1.1 " << endl;
451 deleteNoCommit(theTransaction, &flip, key);
453 readNoCommit(theTransaction, &flip, key, -1);
454 readDirty(aNdb, &save_flip, key, 0);
455 readDirtyNoCommit(theTransaction, &flip, key, -1);
456 ndbout <<
"1.2 " << endl;
458 insertNoCommit(theTransaction, &flip, key);
460 readNoCommit(theTransaction, &flip, key, 0);
461 readDirtyNoCommit(theTransaction, &flip, key, 0);
462 readDirty(aNdb, &save_flip, key, 0);
463 ndbout <<
"1.3 " << endl;
465 updateNoCommit(theTransaction, &flip, key);
467 readNoCommit(theTransaction, &flip, key, 0);
468 readDirtyNoCommit(theTransaction, &flip, key, 0);
469 readDirty(aNdb, &save_flip, key, 0);
470 ndbout <<
"1.4 " << endl;
472 commitTrans(aNdb, theTransaction);
474 ndbout <<
"2 " << endl;
476 readDirty(aNdb, &flip, key, 0);
477 readVerify(aNdb, &flip, key, 0);
482 deleteNoCommit(theTransaction, &flip, key);
484 readDirty(aNdb, &save_flip, key, 0);
485 readDirtyNoCommit(theTransaction, &flip, key, -1);
486 readNoCommit(theTransaction, &flip, key, -1);
488 insertNoCommit(theTransaction, &flip, key);
490 readNoCommit(theTransaction, &flip, key, 0);
492 updateNoCommit(theTransaction, &flip, key);
494 readNoCommit(theTransaction, &flip, key, 0);
495 readDirty(aNdb, &save_flip, key, 0);
496 readDirtyNoCommit(theTransaction, &flip, key, 0);
498 deleteNoCommit(theTransaction, &flip, key);
500 readNoCommit(theTransaction, &flip, key, -1);
501 readDirty(aNdb, &save_flip, key, 0);
502 readDirtyNoCommit(theTransaction, &flip, key, -1);
504 rollbackTrans(aNdb, theTransaction);
506 ndbout <<
"3 " << endl;
509 readDirty(aNdb, &save_flip, key, 0);
510 readVerify(aNdb, &flip, key, 0);
514 updateNoCommit(theTransaction, &flip, key);
516 readDirty(aNdb, &save_flip, key, 0);
517 readDirtyNoCommit(theTransaction, &flip, key, 0);
518 readNoCommit(theTransaction, &flip, key, 0);
520 deleteNoCommit(theTransaction, &flip, key);
522 readNoCommit(theTransaction, &flip, key, -1);
523 readDirtyNoCommit(theTransaction, &flip, key, -1);
524 readDirty(aNdb, &save_flip, key, 0);
526 insertNoCommit(theTransaction, &flip, key);
528 readNoCommit(theTransaction, &flip, key, 0);
529 readDirtyNoCommit(theTransaction, &flip, key, 0);
530 readDirty(aNdb, &save_flip, key, 0);
532 updateNoCommit(theTransaction, &flip, key);
534 readNoCommit(theTransaction, &flip, key, 0);
535 readDirtyNoCommit(theTransaction, &flip, key, 0);
536 readDirty(aNdb, &save_flip, key, 0);
538 deleteNoCommit(theTransaction, &flip, key);
540 readDirty(aNdb, &save_flip, key, 0);
541 readNoCommit(theTransaction, &flip, key, -1);
542 readDirtyNoCommit(theTransaction, &flip, key, -1);
544 commitTrans(aNdb, theTransaction);
546 ndbout <<
"4 " << endl;
548 readVerify(aNdb, &flip, key, -1);
552 insertNoCommit(theTransaction, &flip, key);
554 readDirty(aNdb, &save_flip, key, -1);
555 readNoCommit(theTransaction, &flip, key, 0);
556 readDirtyNoCommit(theTransaction, &flip, key, 0);
558 deleteNoCommit(theTransaction, &flip, key);
560 readDirty(aNdb, &save_flip, key, -1);
561 readNoCommit(theTransaction, &flip, key, -1);
562 readDirtyNoCommit(theTransaction, &flip, key, -1);
564 insertNoCommit(theTransaction, &flip, key);
566 readDirty(aNdb, &save_flip, key, -1);
567 readNoCommit(theTransaction, &flip, key, 0);
568 readDirtyNoCommit(theTransaction, &flip, key, 0);
570 updateNoCommit(theTransaction, &flip, key);
572 readDirty(aNdb, &save_flip, key, -1);
573 readNoCommit(theTransaction, &flip, key, 0);
574 readDirtyNoCommit(theTransaction, &flip, key, 0);
576 deleteNoCommit(theTransaction, &flip, key);
578 readDirty(aNdb, &save_flip, key, -1);
579 readNoCommit(theTransaction, &flip, key, -1);
580 readDirtyNoCommit(theTransaction, &flip, key, -1);
582 commitTrans(aNdb, theTransaction);
584 ndbout <<
"5 " << endl;
586 readDirty(aNdb, &flip, key, -1);
587 readVerify(aNdb, &flip, key, -1);
591 insertNoCommit(theTransaction, &flip, key);
593 readDirty(aNdb, &flip, key, -1);
594 readDirtyNoCommit(theTransaction, &flip, key, 0);
596 commitTrans(aNdb, theTransaction);
597 readDirty(aNdb, &flip, key, 0);
599 ndbout <<
"6 " << endl;
603 deleteNoCommit(theTransaction, &flip, key);
604 updateNoCommitFail(theTransaction, key);
605 rollbackTrans(aNdb, theTransaction);
609 int lookup(
Ndb* aNdb,
unsigned int key,
unsigned int long_short,
int guess){
611 int placeholder[500];
612 unsigned int flip, count;
616 if ( !aNdb )
return -1 ;
619 theTransaction = aNdb->
startTransaction((Uint32)0, (
const char*)&key, (Uint32)4);
623 for (i = 0; i < tNoOfOpsPerExecute; i++) {
628 if (theOperation == NULL) {
629 ndbout <<
"Table missing" << endl;
634 theOperation->
equal((Uint32)0, key);
635 theOperation->
getValue((Uint32)1, (
char*)&flip);
636 theOperation->
getValue((Uint32)2, (
char*)&count);
637 if (theOperation->
getValue((Uint32)3, (
char*)&placeholder[0]) == NULL) {
638 ndbout <<
"Error in definition phase = " << theTransaction->
getNdbError() << endl;
643 ret_value = theTransaction->
execute(Commit);
645 ndbout <<
"Error in lookup:" << theTransaction->
getNdbError() << endl;
650 int update(
Ndb* aNdb,
unsigned int key,
unsigned int long_short,
int guess)
652 int placeholder[500];
654 unsigned int flip, count;
658 if ( !aNdb )
return -1 ;
661 theTransaction = aNdb->
startTransaction((Uint32)0, (
const char*)&key, (Uint32)4);
665 for (i = 0; i < tNoOfOpsPerExecute; i++) {
670 if (theOperation == NULL) {
671 ndbout <<
"Table missing" << endl;
677 theOperation->
equal((Uint32)0, key);
678 theOperation->
getValue((Uint32)1, (
char*)&flip);
679 theOperation->
getValue((Uint32)2, (
char*)&count);
680 theOperation->
getValue((Uint32)3, (
char*)&placeholder[0]);
682 theOperation->
read_attr((Uint32)1, (Uint32)2);
683 theOperation->branch_eq((Uint32)1, (Uint32)2, (Uint32)0);
688 theOperation->
write_attr((Uint32)1, (Uint32)1);
689 ret_value = theOperation->
incValue((Uint32)2, (Uint32)1);
690 if (ret_value == -1) {
691 ndbout <<
"Error in definition phase " << endl;
696 ret_value = theTransaction->
execute(Commit);
697 if (ret_value == -1) {
698 ndbout <<
"Error in update:" << theTransaction->
getNdbError() << endl;
706 int update_bug(
Ndb* aNdb,
unsigned int key,
unsigned int long_short)
708 int placeholder[500];
710 unsigned int flip, count;
714 if ( !aNdb )
return -1 ;
717 for (i = 0; i < tNoOfOpsPerExecute; i++) {
722 if (theOperation == NULL) {
723 ndbout <<
"Table missing" << endl;
728 theOperation->
equal((Uint32)0, key);
729 theOperation->
getValue((Uint32)1, (
char*)&flip);
730 theOperation->
getValue((Uint32)2, (
char*)&count);
731 theOperation->
getValue((Uint32)3, (
char*)&placeholder[0]);
733 theOperation->
read_attr((Uint32)1, (Uint32)2);
734 theOperation->branch_eq((Uint32)1, (Uint32)2, (Uint32)0);
739 theOperation->
write_attr((Uint32)1, (Uint32)1);
740 ret_value = theOperation->
incValue((Uint32)2, (Uint32)1);
741 if (ret_value == -1) {
742 ndbout <<
"Error in definition phase " << endl;
747 ret_value = theTransaction->
execute(NoCommit);
748 if (ret_value == -1) {
749 ndbout <<
"Error in update:" << theTransaction->
getNdbError() << endl;
757 int update_interpreter_test(
Ndb* aNdb,
unsigned int key,
unsigned int long_short)
759 int placeholder[500];
761 unsigned int flip, count;
766 if ( !aNdb )
return -1 ;
772 for (i = 0; i < tNoOfOpsPerExecute; i++) {
781 if (theOperation == NULL) {
782 ndbout <<
"Table missing" << endl;
790 theOperation->
equal((Uint32)0, key);
795 theOperation->
getValue((Uint32)1, (
char*)&flip);
796 theOperation->
getValue((Uint32)2, (
char*)&count);
797 theOperation->
getValue((Uint32)3, (
char*)&placeholder[0]);
812 theOperation->
sub_reg((Uint32)2, (Uint32)3, (Uint32)2);
813 theOperation->branch_ne((Uint32)2, (Uint32)0, (Uint32)0);
815 theOperation->
sub_reg((Uint32)1, (Uint32)3, (Uint32)1);
816 theOperation->branch_ne((Uint32)1, (Uint32)0, (Uint32)1);
820 theOperation->
add_reg((Uint32)1, (Uint32)2, (Uint32)1);
825 theOperation->branch_eq((Uint32)1, (Uint32)2, Tlabel);
829 theOperation->branch_ne((Uint32)1, (Uint32)2, Tlabel);
835 theOperation->branch_lt((Uint32)1, (Uint32)2, Tlabel);
841 theOperation->branch_gt((Uint32)1, (Uint32)2, Tlabel);
857 theOperation->
branch_ge((Uint32)1, (Uint32)2, Tlabel);
873 theOperation->
add_reg((Uint32)4, (Uint32)5, (Uint32)4);
876 theOperation->branch_eq((Uint32)4, (Uint32)5, Tlabel);
880 theOperation->branch_eq((Uint32)4, (Uint32)5, (Tlabel + 1));
883 theOperation->branch_eq((Uint32)4, (Uint32)5, (Tlabel + 2));
886 theOperation->branch_eq((Uint32)4, (Uint32)5, (Tlabel + 3));
893 theOperation->
add_reg((Uint32)1, (Uint32)2, (Uint32)1);
900 theOperation->
add_reg((Uint32)1, (Uint32)2, (Uint32)1);
907 theOperation->load_const_u64((Uint32)2, (Uint64)(x - 1));
908 theOperation->
add_reg((Uint32)1, (Uint32)2, (Uint32)1);
914 theOperation->load_const_u64((Uint32)2, (Uint64)(x - 1));
915 theOperation->
add_reg((Uint32)1, (Uint32)2, (Uint32)1);
916 theOperation->load_const_u64((Uint32)2, (Uint64)1);
920 theOperation->
read_attr((Uint32)1, (Uint32)2);
921 theOperation->branch_eq((Uint32)1, (Uint32)2, Tlabel);
927 theOperation->
write_attr((Uint32)1, (Uint32)1);
928 ret_value = theOperation->
incValue((Uint32)2, (Uint32)1);
929 if (ret_value == -1) {
930 ndbout <<
"Error in definition phase " << endl;
938 ret_value = theTransaction->
execute(Commit);
939 if (ret_value == -1) {
940 ndbout <<
"Error in update:" << theTransaction->
getNdbError() << endl;
954 myRandom48Init(NdbTick_CurrentMillisecond());
958 int loop_count_ops = 0;
962 unsigned int thread_no = 0 ;
963 unsigned long total_milliseconds;
964 unsigned int key = 0 ;
965 unsigned int prob = 0 ;
966 unsigned long transaction_time = 0 ;
967 unsigned long transaction_max_time = 0 ;
968 unsigned long min_time, max_time[MAX_TIMERS];
969 double mean_time, mean_square_time, std_time;
971 thread_no = tabThread->ThreadNo;
972 pMyNdb = tabThread->NdbRef;
974 pMyNdb =
new Ndb(
"TEST_DB" );
980 min_time = 0xFFFFFFFF;
982 memset(&max_time, 0,
sizeof max_time) ;
984 mean_square_time = 0;
985 ThreadReady[thread_no] = 1;
987 while (!ThreadStart[thread_no]){
988 NdbSleep_MilliSleep(1);
992 if (ThreadStart[thread_no] == 999){
995 ThreadReady[thread_no] = 1;
999 tType = ThreadStart[thread_no];
1001 ThreadStart[thread_no] = 0;
1002 ThreadReady[thread_no] = 0 ;
1006 loop_count_ops = tNoOfOperations;
1009 for (count=0 ; count < loop_count_ops ; count++) {
1015 key = myRandom48(tNoOfRecords);
1026 Tsuccess =
lookup(pMyNdb, key, 0, 1);
1033 Tsuccess =
lookup(pMyNdb, key, 1, 1);
1039 Tsuccess = update(pMyNdb, key, 0, 1);
1045 Tsuccess = update(pMyNdb, key, 1, 1);
1051 prob = myRandom48(100);
1053 Tsuccess = update(pMyNdb, key, 0, 1);
1055 Tsuccess =
lookup(pMyNdb, key, 0, 1);
1061 prob = myRandom48(100);
1063 Tsuccess = update(pMyNdb, key, 1, 1);
1065 Tsuccess =
lookup(pMyNdb, key, 1, 1);
1071 prob = myRandom48(100);
1073 Tsuccess = update(pMyNdb, key, 0, 1);
1075 Tsuccess =
lookup(pMyNdb, key, 0, 1);
1081 prob = myRandom48(100);
1083 Tsuccess = update(pMyNdb, key, 1, 1);
1085 Tsuccess =
lookup(pMyNdb, key, 1, 1);
1091 prob = myRandom48(100);
1093 Tsuccess = update(pMyNdb, key, 0, 1);
1095 Tsuccess = update(pMyNdb, key, 1, 1);
1097 Tsuccess =
lookup(pMyNdb, key, 0, 1);
1099 Tsuccess =
lookup(pMyNdb, key, 1, 1);
1105 Tsuccess = update_bug(pMyNdb, key, 0);
1111 Tsuccess = update_interpreter_test(pMyNdb, key, 0);
1117 Tsuccess = update_bug(pMyNdb, key, 1);
1123 Tsuccess = update_interpreter_test(pMyNdb, key, 1);
1129 Tsuccess =
lookup(pMyNdb, key, 0, 0);
1135 Tsuccess =
lookup(pMyNdb, key, 1, 0);
1141 Tsuccess = update(pMyNdb, key, 0, 0);
1147 Tsuccess = update(pMyNdb, key, 1, 0);
1150 Tsuccess = multiRecordTest(pMyNdb, key);
1156 if(-1 == Tsuccess) {
1157 NDBT_ProgramExit(NDBT_FAILED);
1164 transaction_time = (
unsigned long)timer.elapsedTime() ;
1168 transaction_max_time = transaction_time;
1169 for (Ti = 0; Ti < MAX_TIMERS; Ti++) {
1170 if (transaction_max_time > max_time[Ti]) {
1171 Uint32 tmp = max_time[Ti];
1172 max_time[Ti] = transaction_max_time;
1173 transaction_max_time = tmp;
1176 if (transaction_time < min_time) min_time = transaction_time;
1177 mean_time = (double)transaction_time + mean_time;
1178 mean_square_time = (double)(transaction_time * transaction_time) + mean_square_time;
1184 total_milliseconds = (
unsigned long)timer_top.elapsedTime() ;
1185 mean_time = mean_time / loop_count_ops;
1186 mean_square_time = mean_square_time / loop_count_ops;
1187 std_time = sqrt(mean_square_time - (mean_time * mean_time));
1191 ndbout <<
"Thread = " << thread_no <<
" reporting:" << endl ;
1192 ndbout <<
"------------------------------" << endl ;
1193 ndbout <<
"Total time is " << (
unsigned int)(total_milliseconds /1000);
1194 ndbout <<
" seconds and " << (
unsigned int)(total_milliseconds % 1000);
1195 ndbout <<
" milliseconds" << endl;
1196 ndbout <<
"Minimum time = " << (
unsigned int)min_time <<
" milliseconds" << endl;
1197 for (Ti = 0; Ti < MAX_TIMERS; Ti++) {
1198 ndbout <<
"Maximum timer " << Ti <<
" = " << (
unsigned int)max_time[Ti] <<
" milliseconds" << endl;
1199 ndbout <<
"Mean time = " << (
unsigned int)mean_time <<
" milliseconds" << endl;
1200 ndbout <<
"Standard deviation on time = " << (
unsigned int)std_time;
1201 ndbout <<
" milliseconds" << endl << endl ;