#include <iostream>#include <string>#include <sstream>#include <time.h>#include <strings.h>#include <string.h>#include "sqlite3.h"const int nCount = 500000;int main ( int argc, char** argv ){sqlite3* db;sqlite3_open ( "testdb.db", &db );sqlite3_exec ( db, "PRAGMA synchronous = OFF; ", 0, 0, 0 );sqlite3_exec ( db, "drop table if exists t1", 0, 0, 0 );sqlite3_exec ( db, "create table t1(id integer,x integer,y integer ,weight real)", 0, 0, 0 );clock_t t1 = clock();sqlite3_exec ( db, "begin;", 0, 0, 0 );sqlite3_stmt* stmt;const char* sql = "insert into t1 values(?,?,?,?)";sqlite3_prepare_v2 ( db, sql, strlen ( sql ), &stmt, 0 );for ( int i = 0; i < nCount; ++i ){// std::stringstream ssm;// ssm<<"insert into t1 values("<<i<<","<<i*2<<","<<i/2<<","<<i*i<<")";// sqlite3_exec(db,ssm.str().c_str(),0,0,0);sqlite3_reset ( stmt );sqlite3_bind_int ( stmt, 1, i );sqlite3_bind_int ( stmt, 2, i * 2 );sqlite3_bind_int ( stmt, 3, i / 2 );sqlite3_bind_double ( stmt, 4, i * i );sqlite3_step ( stmt );}sqlite3_finalize ( stmt );sqlite3_exec ( db, "commit;", 0, 0, 0 );clock_t t2 = clock();sqlite3_close ( db );std::cout << 1000.0 / ( ( t2 - t1 ) / 1000.0 ) *nCount << " rec/s" << std::endl;return 0;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。