]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add performance tests to the test suite. (CVS 3516)
authordrh <drh@noemail.net>
Thu, 23 Nov 2006 09:39:16 +0000 (09:39 +0000)
committerdrh <drh@noemail.net>
Thu, 23 Nov 2006 09:39:16 +0000 (09:39 +0000)
FossilOrigin-Name: 270c745dffad7aa24f8707720b3d68ad7a6b2749

manifest
manifest.uuid
src/test1.c
test/select6.test
test/tester.tcl

index 5ad991f3552f8b9eda601707647a6690430966e8..777ce5221fb4cab2694fc0bb2fc6b3ecb004e6f4 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sthe\s".dump"\scommand\sin\sthe\sshell.\s\sTicket\s#2072.\s\sAlso\sticket\s#2065.\s(CVS\s3515)
-D 2006-11-20T16:21:10
+C Add\sperformance\stests\sto\sthe\stest\ssuite.\s(CVS\s3516)
+D 2006-11-23T09:39:16
 F Makefile.in 8e14898d41a53033ecb687d93c9cd5d109fb9ae3
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -100,7 +100,7 @@ F src/sqlite3ext.h 2c2156cc32a158e2b7bd9042d42accf94bff2e40
 F src/sqliteInt.h f6bac44ee7b8ee2614b046974551c22999ec674f
 F src/table.c 6d0da66dde26ee75614ed8f584a1996467088d06
 F src/tclsqlite.c e029f739bed90071789fe81a226d53e97a80a4d8
-F src/test1.c 3d0cb8837eb13e6cd5fe2b76a37ba8d9c0ad77fc
+F src/test1.c 19786ff3274635b6eac27a89f842416f388f3654
 F src/test2.c ca74a1d8aeb7d9606e8f6b762c5daf85c1a3f92b
 F src/test3.c 85135c09560c48bdb0a23c9b890ab405486b8ec9
 F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
@@ -282,7 +282,7 @@ F test/select2.test f3c2678c3a9f3cf08ec4988a3845bda64be6d9e3
 F test/select3.test 33c78663e6b1b41220dcec4eb6affb1a05001ffe
 F test/select4.test 305ba0a6e97efc5544def5e5cb49b54e1bf87fd9
 F test/select5.test 0b47058d3e916c1fc9fe81f44b438e02bade21ce
-F test/select6.test a4e97b713b096f17414f50d078ec4efe7dc43253
+F test/select6.test 3607be760b1d4bfd337f43c13b5f3532ca5f09d9
 F test/select7.test 95697d8e8355ef7538e2fe768da16838bbd0fcde
 F test/server1.test e328b8e641ba8fe9273132cfef497383185dc1f5
 F test/shared.test 0ed247941236788c255b3b29b5a82d5ca71b6432
@@ -297,7 +297,7 @@ F test/table.test feea6a3eb08cf166f570255eea5447e42ef82498
 F test/tableapi.test a1982276274d292110d549206bc365b2da43e2ee
 F test/tclsqlite.test 51334389283c74bcbe28645a73159b17e239e9f3
 F test/temptable.test c36f3e5a94507abb64f7ba23deeb4e1a8a8c3821
-F test/tester.tcl 2c2683d3bd51dac27750af89ff3d0f339823b603
+F test/tester.tcl a1940002407a4797c7748d633b92c58bfaa211cf
 F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
 F test/thread2.test 6d7b30102d600f51b4055ee3a5a19228799049fb
 F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
@@ -421,7 +421,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 2fdc147d0059dcdfff2da33bd9fedb0bee057aa1
-R 794dc2fbb3e0e83e5207db81c11bb327
+P 9fdc249609a4745715a2bf49bbf1376ea243a20a
+R efe8add04260169c1047f36db8e1352f
 U drh
-Z 79a147f5026204797ae394029f543a2e
+Z 86f3e2483d981df2a6b869d1c8f0b98e
index 2bc88a14bd6c32df2f231a929c7a75d20bc6e9bc..cc6e4238d9d1f05d1aa9a3ab7d6bec9b0a057add 100644 (file)
@@ -1 +1 @@
-9fdc249609a4745715a2bf49bbf1376ea243a20a
\ No newline at end of file
+270c745dffad7aa24f8707720b3d68ad7a6b2749
\ No newline at end of file
index cc4f4f1d781970a8f74ade76dd300fbb7a86ef05..3cb00e3b817b881625e85bcfd6d2af2f442bba10 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test1.c,v 1.224 2006/11/09 00:24:54 drh Exp $
+** $Id: test1.c,v 1.225 2006/11/23 09:39:16 drh Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -63,6 +63,22 @@ static int get_sqlite_pointer(
   return TCL_OK;
 }
 
+/*
+** Decode a pointer to an sqlite3 object.
+*/
+static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb){
+  struct SqliteDb *p;
+  Tcl_CmdInfo cmdInfo;
+  if( Tcl_GetCommandInfo(interp, zA, &cmdInfo) ){
+    p = (struct SqliteDb*)cmdInfo.objClientData;
+    *ppDb = p->db;
+  }else{
+    *ppDb = (sqlite3*)sqlite3TextToPtr(zA);
+  }
+  return TCL_OK;
+}
+
+
 const char *sqlite3TestErrorName(int rc){
   const char *zName = 0;
   switch( rc & 0xff ){
@@ -121,14 +137,6 @@ int sqlite3TestErrCode(Tcl_Interp *interp, sqlite3 *db, int rc){
   return 0;
 }
 
-/*
-** Decode a pointer to an sqlite3 object.
-*/
-static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb){
-  *ppDb = (sqlite3*)sqlite3TextToPtr(zA);
-  return TCL_OK;
-}
-
 /*
 ** Decode a pointer to an sqlite3_stmt object.
 */
@@ -227,6 +235,65 @@ static int test_exec_printf(
   return TCL_OK;
 }
 
+/*
+** Usage:  sqlite3_exec  DB  SQL
+**
+** Invoke the sqlite3_exec interface using the open database DB
+*/
+static int test_exec(
+  void *NotUsed,
+  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
+  int argc,              /* Number of arguments */
+  char **argv            /* Text of each argument */
+){
+  sqlite3 *db;
+  Tcl_DString str;
+  int rc;
+  char *zErr = 0;
+  char zBuf[30];
+  if( argc!=3 ){
+    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 
+       " DB SQL", 0);
+    return TCL_ERROR;
+  }
+  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
+  Tcl_DStringInit(&str);
+  rc = sqlite3_exec(db, argv[2], exec_printf_cb, &str, &zErr);
+  sprintf(zBuf, "%d", rc);
+  Tcl_AppendElement(interp, zBuf);
+  Tcl_AppendElement(interp, rc==SQLITE_OK ? Tcl_DStringValue(&str) : zErr);
+  Tcl_DStringFree(&str);
+  if( zErr ) sqlite3_free(zErr);
+  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;
+  return TCL_OK;
+}
+
+/*
+** Usage:  sqlite3_exec_nr  DB  SQL
+**
+** Invoke the sqlite3_exec interface using the open database DB.  Discard
+** all results
+*/
+static int test_exec_nr(
+  void *NotUsed,
+  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
+  int argc,              /* Number of arguments */
+  char **argv            /* Text of each argument */
+){
+  sqlite3 *db;
+  int rc;
+  char *zErr = 0;
+  if( argc!=3 ){
+    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 
+       " DB SQL", 0);
+    return TCL_ERROR;
+  }
+  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
+  rc = sqlite3_exec(db, argv[2], 0, 0, &zErr);
+  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;
+  return TCL_OK;
+}
+
 /*
 ** Usage:  sqlite3_mprintf_z_test  SEPARATOR  ARG0  ARG1 ...
 **
@@ -3945,6 +4012,8 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
      { "sqlite3_mprintf_n_test",        (Tcl_CmdProc*)test_mprintf_n        },
      { "sqlite3_last_insert_rowid",     (Tcl_CmdProc*)test_last_rowid       },
      { "sqlite3_exec_printf",           (Tcl_CmdProc*)test_exec_printf      },
+     { "sqlite3_exec",                  (Tcl_CmdProc*)test_exec             },
+     { "sqlite3_exec_nr",               (Tcl_CmdProc*)test_exec_nr          },
      { "sqlite3_get_table_printf",      (Tcl_CmdProc*)test_get_table_printf },
      { "sqlite3_close",                 (Tcl_CmdProc*)sqlite_test_close     },
      { "sqlite3_create_function",       (Tcl_CmdProc*)test_create_function  },
index 5b1ee8980213eecc6e54205373ae94bea2c08987..d89a99d197fbe09e4e0afa4ff6143089f1e43dd3 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file is testing SELECT statements that contain
 # subqueries in their FROM clause.
 #
-# $Id: select6.test,v 1.24 2006/06/11 23:41:56 drh Exp $
+# $Id: select6.test,v 1.25 2006/11/23 09:39:16 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -101,7 +101,7 @@ do_test select6-1.9 {
   }
 } {1 1 1 2 2 2 3 4 3 4 7 7 4 8 15 12 5 5 20 21}
 
-do_test select6-2.0 {
+do_speed_test select6-2.0 {
   execsql {
     CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
     INSERT INTO t2 SELECT * FROM t1;
index 6b72d293bd0704a280532f21497a2c36a4640504..d00bdc230918f5ee77ecf4acaa43911c2a35edcd 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements some common TCL routines used for regression
 # testing the SQLite library
 #
-# $Id: tester.tcl,v 1.69 2006/10/04 11:55:50 drh Exp $
+# $Id: tester.tcl,v 1.70 2006/11/23 09:39:16 drh Exp $
 
 # Make sure tclsqlite3 was compiled correctly.  Abort now with an
 # error message if not.
@@ -78,6 +78,9 @@ set nTest 0
 set skip_test 0
 set failList {}
 set maxErr 1000
+if {![info exists speedTest]} {
+  set speedTest 0
+}
 
 # Invoke the do_test procedure to run a single test 
 #
@@ -118,6 +121,19 @@ proc do_test {name cmd expected} {
   }
 }
 
+# Run an SQL script.  
+# Return the number of microseconds per statement.
+#
+proc speed_trial {name numstmt sql} {
+  puts -nonewline [format {%-20.20s } $name...]
+  flush stdout
+  set speed [time {sqlite3_exec_nr db $sql}]
+  set tm [lindex $speed 0]
+  set per [expr {$tm/(1.0*$numstmt)}]
+  set rate [expr {1000000.0*$numstmt/$tm}]
+  puts [format {%20.1f us/stmt %20.5f stmt/s} $per $rate]
+}
+
 # The procedure uses the special "sqlite_malloc_stat" command
 # (which is only available if SQLite is compiled with -DSQLITE_DEBUG=1)
 # to see how many malloc()s have not been free()ed.  The number