MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / main

Function main

test/sqlite/benchmark.c:60–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60int main(int argc, char **argv){
61 sqlite3 *db;
62 char *zErrMsg = 0;
63 int rc, i;
64 double t;
65 int n, m;
66
67 n = argc > 1 ? atoi(argv[1]) : 5000;
68 m = argc > 2 ? atoi(argv[2]) : 1;
69
70 rc = sqlite3_open(":memory:", &db);
71 if( rc ){
72 fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
73 sqlite3_close(db);
74 exit(1);
75 }
76
77 #define RUN(cmd) \
78 { \
79 rc = sqlite3_exec(db, cmd, callback, 0, &zErrMsg); \
80 if( rc!=SQLITE_OK ){ \
81 fprintf(stderr, "SQL error on %d: %s\n", i, zErrMsg); \
82 sqlite3_free(zErrMsg); \
83 exit(1); \
84 } \
85 }
86
87 #define TIME(msg) \
88 { \
89 double now = emscripten_get_now(); \
90 printf(msg " : took %f ms\n", now - t); \
91 t = now; \
92 }
93
94 t = emscripten_get_now();
95 TIME("'startup' - IGNORE THIS VALUE, it is an artifact");
96
97 RUN("CREATE TABLE t1(a INTEGER, b INTEGER, c VARCHAR(100));");
98 TIME("create table");
99
100 RUN("BEGIN;");
101
102 // n*5 INSERTs in a transaction
103 for (i = 0; i < n; i++) {
104 RUN("INSERT INTO t1 VALUES(1,12345,'one 1 one 1 one 1');");
105 RUN("INSERT INTO t1 VALUES(2,23422,'two two two two');");
106 RUN("INSERT INTO t1 VALUES(3,31233,'three three 33333333333 three');");
107 RUN("INSERT INTO t1 VALUES(4,41414,'FOUR four 4 phor FOUR 44444');");
108 RUN("INSERT INTO t1 VALUES(5,52555,'five 5 FIVE Five phayve 55 5 5 5 5 55 5');");
109 }
110 TIME("25,000 inserts");
111
112 RUN("COMMIT;");
113 TIME("commit");
114
115 // Counts
116 for (i = 0; i < m; i++) {
117 print = i == 0;

Callers

nothing calls this directly

Calls 5

atoiFunction · 0.85
fprintfFunction · 0.85
testFunction · 0.70
exitFunction · 0.50
emscripten_get_nowFunction · 0.50

Tested by

no test coverage detected