Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Enhance speedtest1.c so that is works on older versions of SQLite, before the introduction of the group_concat() aggregate function. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
9979ba80a649ee61d9d174dc9d9fcab7 |
User & Date: | drh 2016-11-21 18:15:35.996 |
Context
2016-11-21
| ||
21:33 | Remove unnecessary OP_Close opcodes at the end of INSERT operations, resulting in smaller and faster code. (check-in: abeddb6d5a user: drh tags: trunk) | |
18:15 | Enhance speedtest1.c so that is works on older versions of SQLite, before the introduction of the group_concat() aggregate function. (check-in: 9979ba80a6 user: drh tags: trunk) | |
2016-11-20
| ||
17:59 | Fix harmless compiler warnings. (check-in: b3b7b42d9a user: drh tags: trunk) | |
Changes
Changes to test/speedtest1.c.
︙ | ︙ | |||
452 453 454 455 456 457 458 459 460 461 462 463 464 465 | y1 = (y0 + x/y0)/2; if( y1==y0 ) break; y0 = y1; } return y0; } /* ** The main and default testset */ void testset_main(void){ int i; /* Loop counter */ int n; /* iteration count */ int sz; /* Size of the tables */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | y1 = (y0 + x/y0)/2; if( y1==y0 ) break; y0 = y1; } return y0; } #if SQLITE_VERSION_NUMBER<3005004 /* ** An implementation of group_concat(). Used only when testing older ** versions of SQLite that lack the built-in group_concat(). */ struct groupConcat { char *z; int nAlloc; int nUsed; }; static void groupAppend(struct groupConcat *p, const char *z, int n){ if( p->nUsed+n >= p->nAlloc ){ int n2 = (p->nAlloc+n+1)*2; char *z2 = sqlite3_realloc(p->z, n2); if( z2==0 ) return; p->z = z2; p->nAlloc = n2; } memcpy(p->z+p->nUsed, z, n); p->nUsed += n; } static void groupStep( sqlite3_context *context, int argc, sqlite3_value **argv ){ const char *zVal; struct groupConcat *p; const char *zSep; int nVal, nSep; assert( argc==1 || argc==2 ); if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; p= (struct groupConcat*)sqlite3_aggregate_context(context, sizeof(*p)); if( p ){ int firstTerm = p->nUsed==0; if( !firstTerm ){ if( argc==2 ){ zSep = (char*)sqlite3_value_text(argv[1]); nSep = sqlite3_value_bytes(argv[1]); }else{ zSep = ","; nSep = 1; } if( nSep ) groupAppend(p, zSep, nSep); } zVal = (char*)sqlite3_value_text(argv[0]); nVal = sqlite3_value_bytes(argv[0]); if( zVal ) groupAppend(p, zVal, nVal); } } static void groupFinal(sqlite3_context *context){ struct groupConcat *p; p = sqlite3_aggregate_context(context, 0); if( p && p->z ){ p->z[p->nUsed] = 0; sqlite3_result_text(context, p->z, p->nUsed, sqlite3_free); } } #endif /* ** The main and default testset */ void testset_main(void){ int i; /* Loop counter */ int n; /* iteration count */ int sz; /* Size of the tables */ |
︙ | ︙ | |||
521 522 523 524 525 526 527 528 529 530 531 532 533 534 | sqlite3_bind_int64(g.pStmt, 1, (sqlite3_int64)x1); sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC); speedtest1_run(); } speedtest1_exec("COMMIT"); speedtest1_end_test(); n = 25; speedtest1_begin_test(130, "%d SELECTS, numeric BETWEEN, unindexed", n); speedtest1_exec("BEGIN"); speedtest1_prepare( "SELECT count(*), avg(b), sum(length(c)), group_concat(c) FROM t1\n" " WHERE b BETWEEN ?1 AND ?2; -- %d times", n | > > > > | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 | sqlite3_bind_int64(g.pStmt, 1, (sqlite3_int64)x1); sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC); speedtest1_run(); } speedtest1_exec("COMMIT"); speedtest1_end_test(); #if SQLITE_VERSION_NUMBER<3005004 sqlite3_create_function(g.db, "group_concat", 1, SQLITE_UTF8, 0, 0, groupStep, groupFinal); #endif n = 25; speedtest1_begin_test(130, "%d SELECTS, numeric BETWEEN, unindexed", n); speedtest1_exec("BEGIN"); speedtest1_prepare( "SELECT count(*), avg(b), sum(length(c)), group_concat(c) FROM t1\n" " WHERE b BETWEEN ?1 AND ?2; -- %d times", n |
︙ | ︙ | |||
1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 | if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); zKey = argv[++i]; }else if( strcmp(z,"lookaside")==0 ){ if( i>=argc-2 ) fatal_error("missing arguments on %s\n", argv[i]); nLook = integerValue(argv[i+1]); szLook = integerValue(argv[i+2]); i += 2; }else if( strcmp(z,"multithread")==0 ){ sqlite3_config(SQLITE_CONFIG_MULTITHREAD); }else if( strcmp(z,"nomemstat")==0 ){ sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0); }else if( strcmp(z,"nosync")==0 ){ noSync = 1; }else if( strcmp(z,"notnull")==0 ){ g.zNN = "NOT NULL"; #ifdef SQLITE_ENABLE_RBU }else if( strcmp(z,"rbu")==0 ){ sqlite3ota_create_vfs("rbu", 0); | > > | 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 | if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); zKey = argv[++i]; }else if( strcmp(z,"lookaside")==0 ){ if( i>=argc-2 ) fatal_error("missing arguments on %s\n", argv[i]); nLook = integerValue(argv[i+1]); szLook = integerValue(argv[i+2]); i += 2; #if SQLITE_VERSION_NUMBER>=3006000 }else if( strcmp(z,"multithread")==0 ){ sqlite3_config(SQLITE_CONFIG_MULTITHREAD); }else if( strcmp(z,"nomemstat")==0 ){ sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0); #endif }else if( strcmp(z,"nosync")==0 ){ noSync = 1; }else if( strcmp(z,"notnull")==0 ){ g.zNN = "NOT NULL"; #ifdef SQLITE_ENABLE_RBU }else if( strcmp(z,"rbu")==0 ){ sqlite3ota_create_vfs("rbu", 0); |
︙ | ︙ | |||
1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 | }else if( strcmp(z,"reprepare")==0 ){ g.bReprepare = 1; }else if( strcmp(z,"scratch")==0 ){ if( i>=argc-2 ) fatal_error("missing arguments on %s\n", argv[i]); nScratch = integerValue(argv[i+1]); szScratch = integerValue(argv[i+2]); i += 2; }else if( strcmp(z,"serialized")==0 ){ sqlite3_config(SQLITE_CONFIG_SERIALIZED); }else if( strcmp(z,"singlethread")==0 ){ sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); }else if( strcmp(z,"sqlonly")==0 ){ g.bSqlOnly = 1; }else if( strcmp(z,"shrink-memory")==0 ){ g.bMemShrink = 1; }else if( strcmp(z,"size")==0 ){ if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); g.szTest = integerValue(argv[++i]); | > > | 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 | }else if( strcmp(z,"reprepare")==0 ){ g.bReprepare = 1; }else if( strcmp(z,"scratch")==0 ){ if( i>=argc-2 ) fatal_error("missing arguments on %s\n", argv[i]); nScratch = integerValue(argv[i+1]); szScratch = integerValue(argv[i+2]); i += 2; #if SQLITE_VERSION_NUMBER>=3006000 }else if( strcmp(z,"serialized")==0 ){ sqlite3_config(SQLITE_CONFIG_SERIALIZED); }else if( strcmp(z,"singlethread")==0 ){ sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); #endif }else if( strcmp(z,"sqlonly")==0 ){ g.bSqlOnly = 1; }else if( strcmp(z,"shrink-memory")==0 ){ g.bMemShrink = 1; }else if( strcmp(z,"size")==0 ){ if( i>=argc-1 ) fatal_error("missing argument on %s\n", argv[i]); g.szTest = integerValue(argv[++i]); |
︙ | ︙ |