本文整理汇总了C++中NanoTimer::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ NanoTimer::reset方法的具体用法?C++ NanoTimer::reset怎么用?C++ NanoTimer::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NanoTimer
的用法示例。
在下文中一共展示了NanoTimer::reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateTest
//From Prepare to Commit(Update
int UpdateTest(SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt)
{
int rc,i;
int iHolder;
char sHolder[200];
char sData[200];
timer.reset();
for(i=0;i<ITERATION;i++){
timer.start();
rc = SQLPrepare (hstmt,
(unsigned char *) "UPDATE t1 SET f2 = ? WHERE f1 = ?",
SQL_NTS);
checkrc (rc, __LINE__);
SQLINTEGER sLen = SQL_NTS;
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR,
196, 0, (void *) sHolder, 0, &sLen);
checkrc (rc, __LINE__);
rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
0, 0, &iHolder, 0, NULL);
checkrc (rc, __LINE__);
iHolder = 0;
strcpy (sData, "9876543210987654321098765432109876543210");
iHolder = i ;
strcpy (sHolder, sData);
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
}
printf ("Update: %lld %lld %lld\n", timer.minc (), timer.maxc (),timer.avg ());
}
示例2: SQLPrepare
int
runDeleteTest (SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt)
{
int rc;
int iHolder;
rc = SQLPrepare (hstmt, (unsigned char *)
"DELETE FROM t1 WHERE f1 = ?", SQL_NTS);
checkrc (rc, __LINE__);
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
0, 0, &iHolder, 0, NULL);
checkrc (rc, __LINE__);
iHolder = 0;
int i, j, k;
int tCount;
timer.reset ();
/* Run 1per Test */
for (i = START; i < (START+ITERATION); i++)
{
timer.start ();
iHolder = i ;
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
}
printf ("Delete: 1 %lld %lld %lld\n", timer.min (), timer.max (),
timer.avg ());
return 0;
}
示例3: if
//aggregate
long long int aggregate(SQLHANDLE henv, SQLHANDLE hdbc,SQLHANDLE hstmt,int val,bool flag)
{
int summinmax=0,tempTermVar=0;
int rc;
/* Set read-only transaction type */
readOnlyTrans (hdbc);
if(val==1 && flag){
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT MIN(unique1) from big1;", SQL_NTS);
}
else if(val==1 && !flag)
{
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT MIN(unique1) from big1 group by onepercent;", SQL_NTS);
}
else if(val==2 && flag) {
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT MAX(unique1) from big1;", SQL_NTS);
}
else if(val==2 && !flag){
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT MAX(unique1) from big1 group by onepercent;", SQL_NTS);
}
else if(val==3 && flag) {
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT SUM(unique1) from big1;", SQL_NTS);
}
else if(val==3 && !flag){
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT SUM(unique1) from big1 group by onepercent;", SQL_NTS);
}
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 1, SQL_INTEGER, &summinmax, 0, NULL);
checkrc (rc, __LINE__);
int i, j, k;
int Count;
timer.reset ();
for (i = 0; i < 10; i++)
{
timer.start ();
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
rc = SQLFetch (hstmt);
checkrc (rc, __LINE__);
Count++;
// printf("value=%d",summin);
rc = SQLCloseCursor (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
}
//printf ("Read: 1 %lld\n", timer.avg ());
/* Set read-write transaction type */
readWriteTrans (hdbc);
return timer.avg()/1000;
}
示例4: readOnlyTrans
int
runReadTest (SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt)
{
int iHolder;
int second;
char sHolder[200];
char sData[200];
int tempTermVar = 0;
int tempTermVal = 0;
int rc;
/* Set read-only transaction type */
readOnlyTrans (hdbc);
rc = SQLPrepare (hstmt, (unsigned char *)
"SELECT f1, f2 FROM t1 where f1 = ?", SQL_NTS);
checkrc (rc, __LINE__);
long sz = 0;
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
0, 0, &tempTermVar, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 1, SQL_INTEGER, &iHolder, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 2, SQL_INTEGER, &second, 0, NULL);
checkrc (rc, __LINE__);
iHolder = 0;
strcpy (sData, "0123456789012345678901234567890123456789");
int i, j, k;
int tCount;
timer.reset ();
/* Run 1per Test */
for (i = START; i < (START+ITERATION); i++)
{
timer.start ();
tempTermVar = i ;
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
rc = SQLFetch (hstmt);
checkrc (rc, __LINE__);
tempTermVal = iHolder;
strcpy (sData, sHolder);
rc = SQLCloseCursor (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
}
printf ("Read: 1 %lld %lld %lld\n", timer.min (), timer.max (),
timer.avg ());
/* Set read-write transaction type */
readWriteTrans (hdbc);
return rc;
}
示例5: ReadTest
//From Prepare to commit (Read)
int ReadTest(SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt)
{
int iHolder;
char sHolder[200];
char sData[200];
int tempTermVar = 0;
int tempTermVal = 0;
int rc,i;
// Set read-only transaction type
readOnlyTrans (hdbc);
timer.reset();
for(i=0;i<ITERATION;i++){
timer.start();
rc = SQLPrepare (hstmt, (unsigned char *)
"SELECT f1, f2 FROM t1 where f1 = ?", SQL_NTS);
checkrc (rc, __LINE__);
long sz = 0;
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
0, 0, &tempTermVar, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 1, SQL_INTEGER, &iHolder, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 2, SQL_C_CHAR, sHolder, sizeof (sHolder), NULL);
checkrc (rc, __LINE__);
iHolder = 0;
strcpy (sData, "0123456789012345678901234567890123456789");
int tCount;
tempTermVar = i ;
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
rc = SQLFetch (hstmt);
checkrc (rc, __LINE__);
tempTermVal = iHolder;
strcpy (sData, sHolder);
rc = SQLCloseCursor (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop();
}
printf("Select: %lld %lld %lld\n", timer.minc(), timer.maxc(),timer.avg());
readWriteTrans (hdbc);
return rc;
}
示例6: strcpy
int
runInsertTest (SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt)
{
int rc;
int iHolder;
char sHolder[200];
char sData[200];
iHolder = 0;
strcpy (sData, "0123456789012345678901234567890123456789");
rc = SQLPrepare (hstmt, (unsigned char *) "INSERT INTO t1 VALUES (?, ?)",
SQL_NTS);
checkrc (rc, __LINE__);
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
0, 0, &iHolder, 0, NULL);
checkrc (rc, __LINE__);
SQLINTEGER sLen = SQL_NTS;
rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR,
196, 0, (void *) sHolder, 0, &sLen);
checkrc (rc, __LINE__);
int i, j, k;
int tCount;
timer.reset ();
/* Run 1per Test */
for (i = 0; i < ITERATION; i++)
{
timer.start ();
iHolder = i ;
strcpy (sHolder, sData);
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
}
printf ("Insert: 1 %lld %lld %lld\n", timer.minc (), timer.maxc (),
timer.avg ());
return 0;
}
示例7: strcpy
int
runInsertTest (SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt)
{
int rc;
int iHolder;
char sHolder[200];
char sData[200];
iHolder = 0;
strcpy (sData, "0123456789012345678901234567890123456789");
rc = SQLPrepare (hstmt, (unsigned char *) "insert into t1 values(?,12,13,14,15,16,17,18,19,20,21,100,100,'AXXXXXXXXXXXXXXXXXXXXXXXXXCXXXXXXXXXXXXXXXXXXXXXXXX','GXXXXXXXXXXXXXXXXXXXXXXXXXCXXXXXXXXXXXXXXXXXXXXXXXXA','OXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXO')", SQL_NTS);
checkrc (rc, __LINE__);
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
0, 0, &iHolder, 0, NULL);
checkrc (rc, __LINE__);
SQLINTEGER sLen = SQL_NTS;
/* rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR,
196, 0, (void *) sHolder, 0, &sLen);*/
checkrc (rc, __LINE__);
int i, j, k;
int tCount;
timer.reset ();
/* Run 1per Test */
for (i = START; i<(START + ITERATION); i++)
{
timer.start ();
iHolder = i ;
strcpy (sHolder, sData);
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
}
printf ("Insert: 1 %lld %lld %lld\n", timer.min (), timer.max (),
timer.avg ());
return 0;
}
示例8: distinct
//DISTINCT
long long int distinct(SQLHANDLE henv, SQLHANDLE hdbc,SQLHANDLE hstmt)
{
int var_onepercent;
int rc;
readOnlyTrans (hdbc);
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT DISTINCT onepercent FROM big1;", SQL_NTS);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 1, SQL_INTEGER, &var_onepercent, 0, NULL);
checkrc (rc, __LINE__);
int i,count;
timer.reset ();
for (i = 0; i < 10; i++)
{
count=0;
timer.start ();
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
while(SQL_SUCCEEDED(rc = SQLFetch(hstmt))){
count++;
}
//checkrc (rc, __LINE__);
rc = SQLCloseCursor (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
if (count != 100) {
printf("distinct returned %d rows\n");
readWriteTrans(hdbc);
return 0;
}
}
readWriteTrans(hdbc);
return timer.avg()/1000;
}
示例9: joinCondition
long long int joinCondition(SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt,int value)
{
int uni1;
int uni2,uni3,uni4,uni5;
char str1[52];
char str2[52];
int rc;
int searchVal[] = {1, 5, 10, 50, 100, 200, 250, 500, 750, 800};
//Set read-only transaction type
readOnlyTrans (hdbc);
if(value==1 )
{
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT big1.unique1, big1.unique2, small.unique1, small.stringu1 FROM big1,small WHERE big1.unique1=small.unique1 AND big1.unique1 > ? and big1.unique1 <= ?;", SQL_NTS);
}
else {
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT small.unique1, big1.unique1, big2.unique1, small.stringu1, big1.unique2, big2.unique2 FROM big1, big2, small WHERE big1.unique1=small.unique1 AND big1.unique1=big2.unique1 AND big1.unique1 > ? and big1.unique1 <= ?;", SQL_NTS);
}
checkrc (rc, __LINE__);
int tempTermVar1 =0, tempTermVar2=0;
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &tempTermVar1, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &tempTermVar2, 0, NULL);
checkrc (rc, __LINE__);
long sz = 0;
rc = SQLBindCol (hstmt, 1, SQL_C_SLONG, &uni1, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 2, SQL_C_SLONG, &uni2, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 3, SQL_C_SLONG, &uni3, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 4, SQL_C_CHAR, str1, sizeof (str1), NULL);
checkrc (rc, __LINE__);
if(value==2){
rc = SQLBindCol (hstmt, 5, SQL_C_SLONG, &uni4, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 6, SQL_C_SLONG, &uni5, 0, NULL);
checkrc (rc, __LINE__);
}
int i, j, k;
int count=0;
timer.reset ();
for(i=0;i<10;i++){
count=0;
tempTermVar1 = searchVal[i];
tempTermVar2 = searchVal[i]+100;
timer.start ();
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
while(SQL_SUCCEEDED(rc = SQLFetch(hstmt)))
{
count++;
//printf("Uni1:%d uni2=%d uni3=%d \n",uni1,uni2,uni3);
}
rc = SQLCloseCursor (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
if (count != 100) {
printf ("range join returned %d rows\n", count);
readWriteTrans (hdbc);
return 0;
}
}
readWriteTrans (hdbc);
return timer.avg()/1000;
}
示例10: joining
//Joining
long long int joining(SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt,int value)
{
int uni1;
int uni2,uni3,uni4,uni5;
char str1[52];
char str2[52];
int val[10] = {1, 5, 10, 50, 100, 250, 500, 750, 900, 999};
int tempTermVar=0;
char tempval[124]="Value";
int rc;
/* Set read-only transaction type */
readOnlyTrans (hdbc);
if(value==1 ){
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT big1.unique1, big1.unique2, small.unique1, small.stringu1 FROM big1,small WHERE big1.unique1=small.unique1 AND big1.unique1=?;", SQL_NTS);
}
else {
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT small.unique1, big1.unique1, big2.unique1, small.stringu1, big1.unique2, big2.unique2 FROM big1, big2, small WHERE small.unique1=big1.unique2 AND big1.unique2=big2.unique1 AND big1.unique1 = ?;", SQL_NTS);
}
checkrc (rc, __LINE__);
long sz = 0;
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &tempTermVar, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 1, SQL_C_LONG, &uni1, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 2, SQL_C_LONG, &uni2, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 3, SQL_C_LONG, &uni3, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 4, SQL_C_CHAR, str1, sizeof (str1), NULL);
checkrc (rc, __LINE__);
if(value==2 ){
rc = SQLBindCol (hstmt, 5, SQL_C_LONG, &uni4, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 6, SQL_C_LONG, &uni5, 0, NULL);
checkrc (rc, __LINE__);
}
int i, j, k;
int Count=0;
timer.reset ();
for (i = 0; i < 10; i++)
{
tempTermVar = val[i];
timer.start ();
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
rc=SQLFetch(hstmt);
Count++;
rc = SQLCloseCursor (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
// printf("uni1=%d uni2=%d uni3=%d str1=%s \n",uni1,uni2,uni3,str1);
}
readWriteTrans (hdbc);
return timer.avg()/1000;
}
示例11: SQLConnect
int
runReadTest (SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt)
{
int iHolder;
char sHolder[200];
char sData[200];
int tempTermVar = 0;
int tempTermVal = 0;
int rc,i;
timer.reset();
for(i=0;i<ITERATION;i++){
timer.start();
rc = SQLConnect (hdbc,
(SQLCHAR *) DSN, SQL_NTS,
(SQLCHAR *) "root",
(SQLSMALLINT) strlen ("root"),
(SQLCHAR *) "manager",
(SQLSMALLINT) strlen (""));
if (SQL_SUCCEEDED(rc)) {
if (rc == SQL_SUCCESS_WITH_INFO) {
printf("Driver reported the following diagnostics\n");
extract_error("SQLDriverConnect", hdbc, SQL_HANDLE_DBC);
}
}else {
fprintf(stderr, "Failed to connect\n");
extract_error("SQLDriverConnect", hdbc, SQL_HANDLE_DBC);
}
//check_error (SQL_HANDLE_DBC, hdbc, rc, __LINE__);
checkrc (rc, __LINE__);
rc = SQLSetConnectOption (hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF);
checkrc (rc, __LINE__);
rc = SQLAllocHandle (SQL_HANDLE_STMT, hdbc, &hstmt);
checkrc (rc, __LINE__);
// Set read-only transaction type
readOnlyTrans (hdbc);
rc = SQLPrepare (hstmt, (unsigned char *)
"SELECT f1, f2 FROM t1 where f1 = ?", SQL_NTS);
checkrc (rc, __LINE__);
long sz = 0;
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
0, 0, &tempTermVar, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 1, SQL_INTEGER, &iHolder, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 2, SQL_C_CHAR, sHolder, sizeof (sHolder), NULL);
checkrc (rc, __LINE__);
iHolder = 0;
strcpy (sData, "0123456789012345678901234567890123456789");
int tCount;
tempTermVar = i ;
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
rc = SQLFetch (hstmt);
checkrc (rc, __LINE__);
tempTermVal = iHolder;
strcpy (sData, sHolder);
rc = SQLCloseCursor (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
rc = SQLFreeHandle (SQL_HANDLE_STMT, hstmt);
checkrc (rc, __LINE__);
rc = SQLDisconnect (hdbc);
checkrc (rc, __LINE__);
timer.stop();
}
printf("Select: %lld %lld %lld\n", timer.minc(), timer.maxc(),timer.avg());
return rc;
}
示例12: orderBy
long long int orderBy(SQLHANDLE henv, SQLHANDLE hdbc,SQLHANDLE hstmt)
{
int val[] = {1, 5, 10, 50, 100, 500, 1000, 5000 ,7500, 9500};
int var_two, var_four, var_ten, var_twenty, var_onepercent;
char str1[52];
int tempTermVar=0, tempTermVar2=0, tempTermVar3=0;
int rc;
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT two, four, ten, twenty, onepercent, string4 from big1 where unique1 between ? and ? order by unique1;", SQL_NTS);
checkrc (rc, __LINE__);
readOnlyTrans (hdbc);
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &tempTermVar, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &tempTermVar2, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 1, SQL_INTEGER, &var_two, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 2, SQL_INTEGER, &var_four, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 3, SQL_INTEGER, &var_ten, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 4, SQL_INTEGER, &var_twenty, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 5, SQL_INTEGER, &var_onepercent, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 6, SQL_C_CHAR, str1, sizeof (str1), NULL);
checkrc (rc, __LINE__);
int i, j, k;
int count;
timer.reset ();
for (i = 0; i < 10; i++)
{
count=0;
tempTermVar=val[i];
tempTermVar2 = val[i]+100 ;
timer.start ();
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
rc = SQLFetch (hstmt);
while(SQL_SUCCEEDED(rc = SQLFetch(hstmt))) count++;
//checkrc (rc, __LINE__);
rc = SQLCloseCursor (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
if (count != 100) {
printf("orderby returned %d rows \n", count);
readWriteTrans(hdbc);
return 0;
}
}
readWriteTrans(hdbc);
return timer.avg()/1000;
}
示例13: runReadTest
long long int runReadTest (SQLHANDLE henv, SQLHANDLE hdbc,SQLHANDLE hstmt,bool flag)
{
int uni1;
int uni2;
char str1[52];
char str2[52];
//int val[] = {1, 10, 100, 500, 1000, 5000 ,7500, 8000, 9000, 9999};
int val[10] = {1, 5, 10, 50, 100, 250, 500, 750, 900, 999};
int tempTermVar=0;
char tempval[52]="Value";
int rc;
/* Set read-only transaction type */
readOnlyTrans (hdbc);
if(flag){
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT unique1, unique2, stringu1, stringu2 from big1 where unique1=?;", SQL_NTS);
}
else {
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT unique1, unique2, stringu1, stringu2 from big1 where stringu1=?;", SQL_NTS);
}
checkrc (rc, __LINE__);
long sz = 0;
if(flag){
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &tempTermVar, 0, NULL);
checkrc (rc, __LINE__);
}
else{
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_C_CHAR, 196, 0, tempval, 0, NULL);
checkrc (rc, __LINE__);
}
rc = SQLBindCol (hstmt, 1, SQL_INTEGER, &uni1, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 2, SQL_INTEGER, &uni2, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 3, SQL_C_CHAR, str1, sizeof (str1), NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 4, SQL_C_CHAR, str2, sizeof (str2), NULL);
checkrc (rc, __LINE__);
int i, j, k;
int Count;
timer.reset ();
char buf[10]="Value";
/* Run 1per Test */
for (i = 0; i < 10; i++)
{
if(flag){
tempTermVar = val[i] ;}
else{
sprintf(tempval,"%s%d",buf, val[i]);
}
timer.start ();
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
rc = SQLFetch (hstmt);
checkrc (rc, __LINE__);
Count++;
rc = SQLCloseCursor (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
}
//printf ("Read: 1 %lld\n", timer.avg ());
/* Set read-write transaction type */
readWriteTrans (hdbc);
return timer.avg()/1000;
}
示例14: onePerSel
long long int onePerSel(SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt)
{
int uni1;
int uni2;
char str1[52];
char str2[52];
//int val[] = {1, 5, 10, 50, 100, 500, 1000, 5000 ,7500, 9500};
int val[10] = {1, 5, 10, 50, 100, 250, 500, 750, 900, 999};
int tempTermVar=0;
int tempTermVar2=0;
char tempval[124]="Value";
int rc;
readOnlyTrans (hdbc);
rc = SQLPrepare (hstmt, (unsigned char *) "SELECT unique1, unique2, stringu1 from big1 where unique1 between ? and ?;", SQL_NTS);
checkrc (rc, __LINE__);
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &tempTermVar, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &tempTermVar2, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 1, SQL_INTEGER, &uni1, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 2, SQL_INTEGER, &uni2, 0, NULL);
checkrc (rc, __LINE__);
rc = SQLBindCol (hstmt, 3, SQL_C_CHAR, str1, sizeof (str1), NULL);
checkrc (rc, __LINE__);
int i, j, k;
int Count;
timer.reset ();
for (i = 0; i < 10; i++)
{
Count=0;
strcpy(tempval,"Value");
tempTermVar = val[i] ;
tempTermVar2 = val[i]+99 ;
timer.start ();
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
while(SQL_SUCCEEDED(rc = SQLFetch(hstmt)))
{
Count++;
}
// printf("Count=%d\n",Count);
rc = SQLCloseCursor (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
if (Count != 100) {
printf("One % Selection returned %d rows", Count);
readWriteTrans (hdbc);
return 0;
}
}
readWriteTrans (hdbc);
//printf ("Read: 1 %lld\n", timer.avg ());
return timer.avg()/1000;
}
示例15: main
int main()
{
DbRetVal rv = OK;
AbsSqlConnection *con = SqlFactory::createConnection(CSql);
rv = con->connect("root", "manager");
if (rv != OK) return 1;
AbsSqlStatement *stmt = SqlFactory::createStatement(CSql);
stmt->setConnection(con);
char statement[1024];
strcpy(statement, "CREATE TABLE t1 (f1 int, f2 char(196));");
int rows =0;
rv = stmt->prepare(statement);
if (rv != OK) {delete stmt; delete con; return -1; }
rv = stmt->execute(rows);
if (rv != OK) {delete stmt; delete con; return -1; }
stmt->free();
printf("Table t1 created\n");
strcpy(statement, "CREATE INDEX t1idx on t1 (f1);");
rv = stmt->prepare(statement);
if (rv != OK) {delete stmt; delete con; return -1; }
rv = stmt->execute(rows);
if (rv != OK) {delete stmt; delete con; return -1; }
stmt->free();
printf("Index created on t1(f1) \n");
strcpy(statement, "INSERT INTO t1 (f1, f2) VALUES (?, ?);");
int id1 =10;
char name[196];
strcpy(name, "Rithish");
NanoTimer timer;
rv = stmt->prepare(statement);
if (rv != OK) {delete stmt; delete con; return -1; }
int count =0;
for (int i = 0 ; i < ITERATIONS ; i++)
{
timer.start();
rv = con->beginTrans();
if (rv != OK) break;
id1 = i;
stmt->setIntParam(1, id1);
strcpy(name, "Gopika");
stmt->setStringParam(2, name);
rv = stmt->execute(rows);
if (rv != OK) break;
rv = con->commit();
if (rv != OK) break;
timer.stop();
count++;
}
printf("Total Rows Inserted %d %lld %lld %lld\n", count, timer.minc(),
timer.maxc(), timer.avg());
stmt->free();
strcpy(statement, "SELECT * FROM t1 where f1 = ?;");
rv = stmt->prepare(statement);
if (rv != OK) {delete stmt; delete con; return -1; }
stmt->bindField(1, &id1);
stmt->bindField(2, name);
timer.reset();
count =0;
for (int i = 0 ; i < ITERATIONS ; i++)
{
timer.start();
rv = con->beginTrans();
if (rv != OK) break;
stmt->setIntParam(1, i);
stmt->execute(rows);
if (stmt->fetch() == NULL) { printf("unable to read record\n"); break; }
stmt->close();
rv = con->commit();
if (rv != OK) break;
timer.stop();
count++;
}
stmt->free();
printf("Total Rows Selected %d %lld %lld %lld\n", count, timer.minc(),
timer.maxc(), timer.avg());
strcpy(statement, "UPDATE t1 set f2=? where f1=?;");
rv = stmt->prepare(statement);
if (rv != OK) {delete stmt; delete con; return -1; }
stmt->bindField(1, &id1);
stmt->bindField(2, name);
timer.reset();
count =0;
for (int i = 0 ; i < ITERATIONS ; i++)
{
timer.start();
rv = con->beginTrans();
if (rv != OK) break;
stmt->setIntParam(2, i);
stmt->setStringParam(1, "ChangedValue");
rv = stmt->execute(rows);
if (rv != OK && rows !=1) break;
rv = con->commit();
if (rv != OK) break;
timer.stop();
count++;
}
//.........这里部分代码省略.........