本文整理汇总了C++中NanoTimer::maxc方法的典型用法代码示例。如果您正苦于以下问题:C++ NanoTimer::maxc方法的具体用法?C++ NanoTimer::maxc怎么用?C++ NanoTimer::maxc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NanoTimer
的用法示例。
在下文中一共展示了NanoTimer::maxc方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DeleteTest
//From prepare to commit(Delete)
int DeleteTest(SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt)
{
int rc,i;
int iHolder;
timer.reset();
for(i=0;i<ITERATION;i++){
timer.start();
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 tCount;
iHolder = i ;
rc = SQLExecute (hstmt);
checkrc (rc, __LINE__);
rc = SQLTransact (henv, hdbc, SQL_COMMIT);
checkrc (rc, __LINE__);
timer.stop ();
}
printf ("Delete: %lld %lld %lld\n", timer.minc (), timer.maxc (),timer.avg ());
return 0;
}
示例3: readOnlyTrans
int
runReadTest (SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt)
{
int iHolder;
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_C_CHAR, sHolder, sizeof (sHolder), NULL);
checkrc (rc, __LINE__);
iHolder = 0;
strcpy (sData, "0123456789012345678901234567890123456789");
int i, j, k;
int tCount;
timer.reset ();
/* Run 1per Test */
for (i = 0; i < 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.minc (), timer.maxc (),
timer.avg ());
/* Set read-write transaction type */
readWriteTrans (hdbc);
return rc;
}
示例4: 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;
}
示例5: main
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, 196);
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;
if (LOAD >0 )
idxInfo->bucketSize = 100007;
else
idxInfo->bucketSize = 10007;
rv = dbMgr->createIndex("indx1", idxInfo);
if (rv != OK) { printf("Index creation failed\n"); return -1; }
printf("Index created\n");
delete idxInfo;
Table *table = dbMgr->openTable("t1");
if (table == NULL) { printf("Unable to open table\n"); return -1; }
int id = 0;
char name[196] = "PRABAKARAN";
table->bindFld("f1", &id);
table->bindFld("f2", name);
char *tuple;
int ret;
int i;
int icount =0;
if (LOAD > 0) {
TableImpl *impl = (TableImpl*)table;
impl->setUndoLogging(false);
strcpy(name, "PRABAKARAN0123456750590");
rv = conn.startTransaction();
if (rv != OK) exit(1);
for(i = 0; i< LOAD; i++)
{
id= i;
ret = table->insertTuple();
if (ret != 0) break;
icount++;
if (i % 100 == 0 ) { rv = conn.commit();
if (rv != OK) exit(1);
rv = conn.startTransaction();
if (rv != OK) exit(1);
}
if (i %50000 == 0) printf("%d rows inserted\n", i);
}
conn.commit();
impl->setUndoLogging(true);
printf("Loaded %d records\n", icount);
}
//TableImpl *impl = (TableImpl*)table;
//impl->setUndoLogging(false);
i = 0;
NanoTimer timer;
icount =0;
for(i = LOAD; i< LOAD+ITERATIONS; i++)
{
timer.start();
rv = conn.startTransaction();
if (rv != OK) exit(1);
id= i;
strcpy(name, "PRABAKARAN0123456750590");
ret = table->insertTuple();
if (ret != 0) break;
// printf("%d\n ", i);
icount++;
conn.commit();
timer.stop();
}
printf("%d rows inserted %lld %lld %lld\n",icount, timer.minc(), timer.maxc(), 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 = LOAD; i< LOAD+ITERATIONS; i++)
{
timer.start();
rv =conn.startTransaction();
//.........这里部分代码省略.........
示例6: SQLConnect
int
runDeleteTest (SQLHANDLE henv, SQLHANDLE hdbc, SQLHANDLE hstmt)
{
int rc,i;
int iHolder;
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__);
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 tCount;
iHolder = i ;
rc = SQLExecute (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 ("Delete: %lld %lld %lld\n", timer.minc (), timer.maxc (),timer.avg ());
return 0;
}
示例7: 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++;
}
//.........这里部分代码省略.........