improve sqlite test
This commit is contained in:
Родитель
4a29c4fa7d
Коммит
7143eab384
|
@ -3087,9 +3087,11 @@ if 'benchmark' not in str(sys.argv):
|
||||||
#build_ll_hook=self.do_autodebug)
|
#build_ll_hook=self.do_autodebug)
|
||||||
|
|
||||||
def test_sqlite(self):
|
def test_sqlite(self):
|
||||||
global QUANTUM_SIZE, OPTIMIZE, RELOOP
|
global QUANTUM_SIZE, OPTIMIZE, RELOOP, USE_TYPED_ARRAYS
|
||||||
if QUANTUM_SIZE == 1 or OPTIMIZE or RELOOP: return self.skip('TODO FIXME')
|
if QUANTUM_SIZE == 1 or USE_TYPED_ARRAYS == 2: return self.skip('TODO FIXME')
|
||||||
|
RELOOP = 0 # too slow
|
||||||
|
|
||||||
|
#global AUTO_OPTIMIZE; AUTO_OPTIMIZE = 1
|
||||||
global CORRECT_SIGNS; CORRECT_SIGNS = 1
|
global CORRECT_SIGNS; CORRECT_SIGNS = 1
|
||||||
global CORRECT_OVERFLOWS; CORRECT_OVERFLOWS = 1
|
global CORRECT_OVERFLOWS; CORRECT_OVERFLOWS = 1
|
||||||
global CORRECT_ROUNDINGS; CORRECT_ROUNDINGS = 1
|
global CORRECT_ROUNDINGS; CORRECT_ROUNDINGS = 1
|
||||||
|
@ -3114,21 +3116,14 @@ if 'benchmark' not in str(sys.argv):
|
||||||
#define SQLITE_DISABLE_LFS
|
#define SQLITE_DISABLE_LFS
|
||||||
#define LONGDOUBLE_TYPE double
|
#define LONGDOUBLE_TYPE double
|
||||||
#define SQLITE_INT64_TYPE int
|
#define SQLITE_INT64_TYPE int
|
||||||
|
#define SQLITE_THREADSAFE 0
|
||||||
''' + open(path_from_root('tests', 'sqlite', 'sqlite3.c'), 'r').read() +
|
''' + open(path_from_root('tests', 'sqlite', 'sqlite3.c'), 'r').read() +
|
||||||
open(path_from_root('tests', 'sqlite', 'test.c'), 'r').read(),
|
open(path_from_root('tests', 'sqlite', 'benchmark.c'), 'r').read(),
|
||||||
#open(path_from_root('tests', 'sqlite', 'benchmark.c'), 'r').read(),
|
open(path_from_root('tests', 'sqlite', 'benchmark.txt'), 'r').read(),
|
||||||
'''count(*) = 2
|
|
||||||
|
|
||||||
a = 1
|
|
||||||
b = 13153
|
|
||||||
c = thirteen thousand one hundred fifty three
|
|
||||||
|
|
||||||
a = 1
|
|
||||||
b = 987
|
|
||||||
c = some other number''',
|
|
||||||
includes=[path_from_root('tests', 'sqlite')],
|
includes=[path_from_root('tests', 'sqlite')],
|
||||||
force_c=True,
|
force_c=True,
|
||||||
post_build=post)# ,build_ll_hook=self.do_autodebug)
|
extra_emscripten_args=['-m'],
|
||||||
|
post_build=post)#,build_ll_hook=self.do_autodebug)
|
||||||
|
|
||||||
def test_zlib(self):
|
def test_zlib(self):
|
||||||
global CORRECT_SIGNS; CORRECT_SIGNS = 1
|
global CORRECT_SIGNS; CORRECT_SIGNS = 1
|
||||||
|
|
|
@ -11,6 +11,38 @@ static int callback(void *NotUsed, int argc, char **argv, char **azColName){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int test(){
|
||||||
|
sqlite3 *db;
|
||||||
|
char *zErrMsg = 0;
|
||||||
|
int rc;
|
||||||
|
int i;
|
||||||
|
const char *commands[] = {
|
||||||
|
"CREATE TABLE t2(a INTEGER, b INTEGER, c VARCHAR(100));",
|
||||||
|
"INSERT INTO t2 VALUES(1,13153,'thirteen thousand one hundred fifty three');",
|
||||||
|
"INSERT INTO t2 VALUES(1,987,'some other number');",
|
||||||
|
"SELECT count(*) FROM t2;",
|
||||||
|
"SELECT a, b, c FROM t2;",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
rc = sqlite3_open(":memory:", &db);
|
||||||
|
if( rc ){
|
||||||
|
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
|
||||||
|
sqlite3_close(db);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
for (i = 0; commands[i]; i++) {
|
||||||
|
rc = sqlite3_exec(db, commands[i], callback, 0, &zErrMsg);
|
||||||
|
if( rc!=SQLITE_OK ){
|
||||||
|
fprintf(stderr, "SQL error on %d: %s\n", i, zErrMsg);
|
||||||
|
sqlite3_free(zErrMsg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sqlite3_close(db);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
sqlite3 *db;
|
sqlite3 *db;
|
||||||
char *zErrMsg = 0;
|
char *zErrMsg = 0;
|
||||||
|
@ -41,6 +73,7 @@ int main(){
|
||||||
}
|
}
|
||||||
|
|
||||||
t = clock();
|
t = clock();
|
||||||
|
TIME("'startup'");
|
||||||
|
|
||||||
RUN("CREATE TABLE t1(a INTEGER, b INTEGER, c VARCHAR(100));");
|
RUN("CREATE TABLE t1(a INTEGER, b INTEGER, c VARCHAR(100));");
|
||||||
TIME("create table");
|
TIME("create table");
|
||||||
|
@ -48,7 +81,7 @@ int main(){
|
||||||
RUN("BEGIN;");
|
RUN("BEGIN;");
|
||||||
|
|
||||||
// 25000 INSERTs in a transaction
|
// 25000 INSERTs in a transaction
|
||||||
for (i = 0; i < 5000; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
RUN("INSERT INTO t1 VALUES(1,12345,'one 1 one 1 one 1');");
|
RUN("INSERT INTO t1 VALUES(1,12345,'one 1 one 1 one 1');");
|
||||||
RUN("INSERT INTO t1 VALUES(2,23422,'two two two two');");
|
RUN("INSERT INTO t1 VALUES(2,23422,'two two two two');");
|
||||||
RUN("INSERT INTO t1 VALUES(3,31233,'three three 33333333333 three');");
|
RUN("INSERT INTO t1 VALUES(3,31233,'three three 33333333333 three');");
|
||||||
|
@ -77,6 +110,7 @@ int main(){
|
||||||
TIME("selects with indexes");
|
TIME("selects with indexes");
|
||||||
|
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
return 0;
|
|
||||||
|
return test();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
count(*) = 2
|
||||||
|
|
||||||
|
a = 1
|
||||||
|
b = 13153
|
||||||
|
c = thirteen thousand one hundred fifty three
|
||||||
|
|
||||||
|
a = 1
|
||||||
|
b = 987
|
||||||
|
c = some other number
|
||||||
|
|
|
@ -29799,7 +29799,7 @@ static int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){
|
||||||
** tests repeatable.
|
** tests repeatable.
|
||||||
*/
|
*/
|
||||||
memset(zBuf, 0, nBuf);
|
memset(zBuf, 0, nBuf);
|
||||||
#if !defined(SQLITE_TEST)
|
#if 0 // XXX EMSCRIPTEN keep it all 0 for simplicity !defined(SQLITE_TEST)
|
||||||
{
|
{
|
||||||
int pid, fd;
|
int pid, fd;
|
||||||
fd = robust_open("/dev/urandom", O_RDONLY, 0);
|
fd = robust_open("/dev/urandom", O_RDONLY, 0);
|
||||||
|
@ -38132,6 +38132,9 @@ static int writeJournalHdr(Pager *pPager){
|
||||||
u32 nHeader = (u32)pPager->pageSize;/* Size of buffer pointed to by zHeader */
|
u32 nHeader = (u32)pPager->pageSize;/* Size of buffer pointed to by zHeader */
|
||||||
u32 nWrite; /* Bytes of header sector written */
|
u32 nWrite; /* Bytes of header sector written */
|
||||||
int ii; /* Loop counter */
|
int ii; /* Loop counter */
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
u8 temp[4];
|
||||||
|
#endif
|
||||||
|
|
||||||
assert( isOpen(pPager->jfd) ); /* Journal file must be open. */
|
assert( isOpen(pPager->jfd) ); /* Journal file must be open. */
|
||||||
|
|
||||||
|
@ -38182,7 +38185,12 @@ static int writeJournalHdr(Pager *pPager){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The random check-hash initialiser */
|
/* The random check-hash initialiser */
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
sqlite3_randomness(sizeof(pPager->cksumInit), temp);
|
||||||
|
pPager->cksumInit = temp[0] + (((u32)temp[1]) << 8) + (((u32)temp[2]) << 16) + (((u32)temp[3]) << 24);
|
||||||
|
#else
|
||||||
sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit);
|
sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit);
|
||||||
|
#endif
|
||||||
put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit);
|
put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit);
|
||||||
/* The initial database size */
|
/* The initial database size */
|
||||||
put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize);
|
put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize);
|
||||||
|
@ -53030,7 +53038,12 @@ static void insertCell(
|
||||||
endPtr = &data[ins];
|
endPtr = &data[ins];
|
||||||
assert( (SQLITE_PTR_TO_INT(ptr)&1)==0 ); /* ptr is always 2-byte aligned */
|
assert( (SQLITE_PTR_TO_INT(ptr)&1)==0 ); /* ptr is always 2-byte aligned */
|
||||||
while( ptr>endPtr ){
|
while( ptr>endPtr ){
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
ptr[0] = ptr[-2];
|
||||||
|
ptr[1] = ptr[-1];
|
||||||
|
#else
|
||||||
*(u16*)ptr = *(u16*)&ptr[-2];
|
*(u16*)ptr = *(u16*)&ptr[-2];
|
||||||
|
#endif
|
||||||
ptr -= 2;
|
ptr -= 2;
|
||||||
}
|
}
|
||||||
put2byte(&data[ins], idx);
|
put2byte(&data[ins], idx);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче