From cc1e0d579da0e5d11fcfae4c9fa2571d4616a01b Mon Sep 17 00:00:00 2001 From: prabatuty Date: Wed, 19 Mar 2008 18:57:53 +0000 Subject: [PATCH] Adding throughput test --- test/performance/DMLThroughput.c | 107 +++++++++++++++++++++++++++++++++++++++ test/performance/Makefile | 3 ++ 2 files changed, 110 insertions(+) create mode 100644 test/performance/DMLThroughput.c diff --git a/test/performance/DMLThroughput.c b/test/performance/DMLThroughput.c new file mode 100644 index 00000000..29a06233 --- /dev/null +++ b/test/performance/DMLThroughput.c @@ -0,0 +1,107 @@ +#include +#include +#include +//MAX_SYS_DB_SIZE=10485760 +//MAX_DB_SIZE=335544320 +//you may have to set the kernel.shmmax kernel paremeter(login as root) using +//$sysctl -w kernel.shmmax=1000000000 +#define LOAD 0 +int main() +{ + + Connection conn; + DbRetVal rv = conn.open("root", "manager"); + if (rv != OK) + { + printf("Error during connection %d\n", rv); + return -1; + } + + + DatabaseManager *dbMgr = conn.getDatabaseManager(); + if (dbMgr == NULL) { printf("Auth failed\n"); return -1;} + TableDef tabDef; + tabDef.addField("f1", typeInt, 0, NULL, true ); + tabDef.addField("f2", typeString, 6); + rv = dbMgr->createTable("t1", tabDef); + if (rv != OK) { printf("Table creation failed\n"); return -1; } + printf("Table created\n"); + HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); + strcpy(idxInfo->tableName, "t1"); + idxInfo->list.append("f1"); + idxInfo->indType = hashIndex; + idxInfo->bucketSize = 100007; + rv = dbMgr->createIndex("indx1", idxInfo); + if (rv != OK) { printf("Index creation failed\n"); return -1; } + printf("Index created\n"); + Table *table = dbMgr->openTable("t1"); + if (table == NULL) { printf("Unable to open table\n"); return -1; } + int id = 0; + char name[6] = "PRABA"; + table->bindFld("f1", &id); + table->bindFld("f2", name); + char *tuple; + int ret; + int i; + int icount =0; + i = 0; + NanoTimer timer; + icount =0; + for(i = 0; i < 20; i++) + { + timer.start(); + for (int j =0; j < 100000; j++) + { + rv = conn.startTransaction(); + if (rv != OK) exit(1); + id= i*100000+j; + strcpy(name, "KARAN"); + ret = table->insertTuple(); + if (ret != 0) break; + icount++; + conn.commit(); + } + timer.stop(); + printf("Insert: %d %lld\n", icount, timer.last()); + } + printf("%d rows inserted %lld %lld %lld\n",icount, timer.min(), timer.max(), timer.avg()); + + int offset1= os::align(sizeof(int)); + Condition p1; + int val1 = 0; + p1.setTerm("f1", OpEquals, &val1); + table->setCondition(&p1); + icount=0; + + + timer.reset(); + for(i = 0; i< 20; i++) + { + timer.start(); + for (int j=0 ; j <100000; j++) + { + rv =conn.startTransaction(); + if (rv != OK) exit(1); + val1 = i *100000 + j; + table->execute(); + tuple = (char*)table->fetch() ; + if (tuple == NULL) {printf("loop break in %d\n", i);table->close();break;} + // printf(" %d tuple value is %d %s \n", i, *((int*)tuple), tuple+offset1); + table->close(); + icount++; + conn.commit(); + } + timer.stop(); + printf("Select: %d %lld\n", icount, timer.last()); + } + printf("%d rows selected %lld %lld %lld\n", icount, timer.min(), timer.max(), timer.avg()); + timer.reset(); + + dbMgr->closeTable(table); + dbMgr->dropTable("t1"); + printf("Table dropped\n"); + + + conn.close(); + return 0; +} diff --git a/test/performance/Makefile b/test/performance/Makefile index 9f22dfa6..03a829ce 100644 --- a/test/performance/Makefile +++ b/test/performance/Makefile @@ -26,6 +26,7 @@ LIBS= -L$(CSQL_INSTALL_ROOT)/lib -rdynamic -lcsql TARGETS = \ SQLTest \ DMLTest \ + DMLThroughput \ DMLTestChar \ DMLThreadTest \ JDBCTest \ @@ -38,6 +39,8 @@ endif DMLTest: DMLTest.c $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +DMLThroughput: DMLThroughput.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) SQLTest: SQLTest.c $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) -lcsqlsql -lcsqlsqllog -lcsqlodbcadapter -lcsql -lcsqlnw -lodbc $(SYSLIBS) DMLTestChar: DMLTestChar.c -- 2.11.4.GIT