41 #include <TStopwatch.h>
44 #include <RQ_OBJECT.h>
113 fThread->Connect(
"Timeout()",
"ClientThread",
this,
"Run()");
144 printf(
"Initializing dataset...");
157 printf(
"\n* Starting Benchmark Run *\n");
170 Double_t rtime =
fTimer.RealTime();
171 Double_t ctime =
fTimer.CpuTime();
173 printf(
"* Benchmark finished *");
174 printf(
"\n\n* Benchmark Report *\n" );
175 printf(
"-------------------------------------------------\n");
176 printf(
"Time to execute %d transactions: Real time %.3f, CPU time %.3f seconds\n",
182 Emit(
"ReportDone()");
201 ret = gRandom->Integer(hi-lo);
240 query =
"CREATE TABLE branches (";
241 query+=
"Bid INT NOT NULL, PRIMARY KEY(Bid), ";
242 query+=
"Bbalance INT,";
243 query+=
"filler CHAR(88))";
248 query =
"CREATE TABLE tellers ( ";
249 query+=
"Tid INT NOT NULL, PRIMARY KEY(Tid),";
251 query+=
"Tbalance INT,";
252 query+=
"filler CHAR(84))";
257 query =
"CREATE TABLE accounts ( ";
258 query+=
"Aid INT NOT NULL, PRIMARY KEY(Aid), ";
260 query+=
"Abalance INT, ";
261 query+=
"filler CHAR(84))";
266 query =
"CREATE TABLE history ( ";
270 query+=
"delta INT, ";
271 query+=
"time TIMESTAMP, ";
272 query+=
"filler CHAR(22))";
286 sprintf(str,
"INSERT INTO branches(Bid,Bbalance) VALUES ( %d ,0)",
i);
292 sprintf(str,
"INSERT INTO tellers(Tid,Bid,Tbalance) VALUES (%d,%d,0)",
i,
i /
ntellers);
298 sprintf(str,
"INSERT INTO accounts(Aid,Bid,Abalance) VALUES (%d,%d,0)",
i,
i /
naccounts);
316 str =
"DROP TABLE branches";
319 str =
"DROP TABLE tellers";
322 str =
"DROP TABLE accounts";
325 str =
"DROP TABLE history";
344 sprintf(query,
"UPDATE accounts SET Abalance = Abalance + %d WHERE Aid = %d",delta,aid);
348 sprintf(query,
"SELECT Abalance FROM accounts WHERE Aid = %d",aid);
361 sprintf(query,
"UPDATE tellers SET Tbalance = Tbalance + %d WHERE Tid = %d",delta,tid);
365 sprintf(query,
"UPDATE branches SET Bbalance = Bbalance + %d WHERE Bid = %d",delta,bid);
369 sprintf(query,
"INSERT INTO history(Tid, Bid, Aid, delta) VALUES (%d,%d,%d,%d)", tid,bid,aid,delta);
385 printf(
"Transaction failed: %s\n",str.Data());
392 void bench(
const TString& dsn=
"",
const TString& usr=
"",
393 const TString& psw=
"",
const TString& option=
"",
394 const TString& tpc_str=
"100",
const TString& clients_str=
"10")
401 Bool_t initialize_dataset = kFALSE;
405 Int_t tpc = atoi(tpc_str.Data());
406 Int_t clients = atoi(clients_str.Data());
411 if(option.Contains(
"-init")) initialize_dataset = kTRUE;
412 else if(option.Contains(
"-v"))
gVerbose = kTRUE;
414 printf(
"\n usage: obench(dsn,usr,psw,[option],[tpc],[clients])\n");
416 printf(
"dsn Data Source Name\n");
417 printf(
"usr user name\n");
419 printf(
"tpc transactions per client\n");
420 printf(
"clients number of simultaneous clients\n");
421 printf(
"option string:\n");
422 printf(
"-v verbose error messages\n");
423 printf(
"-init initialize the tables\n");
425 printf(
"\n*********************************************************\n");
426 printf(
"* RDBCBench v1.0 *\n");
427 printf(
"*********************************************************\n");
429 printf(
"DSN: %s\n",dsn.Data());
430 printf(
"User: %s\n",usr.Data());
453 printf(
"SQL Error: %s\n",str.Data());
462 #include <TApplication.h>
466 TROOT
root(
"RDBCbench",
"RDBC benchmark program");
468 int main(
int argc,
char **argv)
471 cerr <<
"Usage: " << argv[0] <<
" url username" << endl
472 <<
"or " << argv[0] <<
" url username password [option] [tpc] [clients]" << endl;
476 TApplication theApp(
"App", &argc, argv);
478 gSystem->Load(
"libRDBC");
479 gSystem->Load(
"./RDBCbench_C");
481 if(argc==3)
bench(argv[1],argv[2],
"");
482 else if(argc==4)
bench(argv[1],argv[2],argv[3]);
483 else if(argc==5)
bench(argv[1],argv[2],argv[3],argv[4]);
484 else if(argc==6)
bench(argv[1],argv[2],argv[3],argv[4],argv[5]);
485 else if(argc==7)
bench(argv[1],argv[2],argv[3],argv[4],argv[5],argv[6]);