{"id":57,"date":"2007-01-04T12:27:10","date_gmt":"2007-01-04T10:27:10","guid":{"rendered":"http:\/\/katastrophos.net\/andre\/blog\/2007\/01\/04\/sqlite-simple-timing-profiler-patch\/"},"modified":"2008-12-28T23:15:19","modified_gmt":"2008-12-28T22:15:19","slug":"sqlite-simple-timing-profiler-patch","status":"publish","type":"post","link":"https:\/\/katastrophos.net\/andre\/blog\/2007\/01\/04\/sqlite-simple-timing-profiler-patch\/","title":{"rendered":"SQLite simple timing profiler patch"},"content":{"rendered":"<p><strong>Update: SQLite now features an integrated timer which can be activated via the .timer command in the console shell. <a href=\"http:\/\/www.sqlite.org\/cvstrac\/chngview?cn=4522\">Details here.<\/a><\/strong><\/p>\n<p>As a follow-up to <a href=\"http:\/\/katastrophos.net\/andre\/blog\/2007\/01\/04\/sqlite-performance-tuning-and-optimization-on-embedded-systems\/\" target=\"_blank\">my previous post &#8220;SQLite performance tuning and optimization on embedded systems&#8221;<\/a> here is a very basic patch that introduces support for timing SQL queries in the sqlite3 console shell.<\/p>\n<p><strong>SQLite 3.3.8<\/strong>:<br \/>\n<a class=\"downloadlink\" href=\"http:\/\/katastrophos.net\/downloads\/sqlite\/shell.c_sqlite3.3.8_profiling.patch\">Patch against shell.c<\/a> <a class=\"downloadlink\" href=\"http:\/\/katastrophos.net\/downloads\/sqlite\/shell_sqlite3.3.8_profiling.c\">shell.c<\/a><\/p>\n<p><strong>SQLite 3.3.9 CVS<\/strong> &#8211; shell.c rev 1.157:<br \/>\n<a class=\"downloadlink\" href=\"http:\/\/katastrophos.net\/downloads\/sqlite\/shell.c_sqlite3.3.9pre_profiling.patch\">Patch against shell.c<\/a> <a class=\"downloadlink\" href=\"http:\/\/katastrophos.net\/downloads\/sqlite\/shell_sqlite3.3.9pre_profiling.c\">shell.c<\/a><\/p>\n<p>Two new shell commands are introduced in sqlite3:<\/p>\n<pre>\r\n.profile ON|OFF        Turn profiling on or off\r\n.timer start|show      Measure elapsed CPU time\r\n<\/pre>\n<p><strong>.profile ON<\/strong> will turn off output to stdout. Instead it will display CPU execution time for every SQL command processed.<br \/>\nHere is an example output:<\/p>\n<pre>\r\n<strong>sqlite><\/strong> .profile on\r\n<strong>sqlite><\/strong> .read test1.sql\r\nExec time  BEGIN;                                       :  0.000 s.\r\nExec time  DROP TABLE IF EXISTS playlist_view;          :  0.020 s.\r\nExec time  DROP TABLE IF EXISTS overview;               :  0.000 s.\r\nExec time  CREATE TEMPORARY TABLE playlist_view AS   ...  :  0.180 s.\r\nExec time  CREATE TEMPORARY TABLE overview AS        ...  :  0.140 s.\r\nExec time  SELECT DISTINCT genre, genre IN (\"Progress...  :  0.030 s.\r\n...\r\n<\/pre>\n<p>Note: You can still override the output setting with the <strong>.output<\/strong> command after an <strong>.profile ON<\/strong> has been issued.<br \/>\n<strong>.profile OFF<\/strong> will turn off time-based profiling and reenable output to stdout.<\/p>\n<p><strong>.timer start<\/strong> will start a timer. You can execute a sequence of queries and then print the required CPU time via <strong>.timer show<\/strong>.<br \/>\nUse <strong>.timer start<\/strong> again to reset the timer. This .timer patch is based on <a href=\"http:\/\/www.sqlite.org\/cvstrac\/tktview?tn=1227\" target=\"_blank\">SQLite ticket #1227<\/a> by Bartosz Polednia.<\/p>\n<p>Timing is currently done using clock() which provides only a 10 ms precision for CPU time on most systems. This might be inadequate depending on your requirements. If you know a more precise way, please let me know.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update: SQLite now features an integrated timer which can be activated via the .timer command in the console shell. Details here. As a follow-up to my previous post &#8220;SQLite performance tuning and optimization on embedded systems&#8221; here is a very basic patch that introduces support for timing SQL queries in the sqlite3 console shell. SQLite [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[20,19,24],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","tag-development","tag-hack","tag-quasar"],"_links":{"self":[{"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/posts\/57"}],"collection":[{"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/comments?post=57"}],"version-history":[{"count":2,"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/posts\/57\/revisions"}],"predecessor-version":[{"id":82,"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/posts\/57\/revisions\/82"}],"wp:attachment":[{"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/media?parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/categories?post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/tags?post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}