diff options
author | drh <drh@noemail.net> | 2016-03-04 16:42:43 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-03-04 16:42:43 +0000 |
commit | 2606aca80f35c4672c7834e90786d737679fa35b (patch) | |
tree | 2a8be85e2e802ad5ba42c4bb8e9102712cb287aa /src/shell.c | |
parent | fd37e67b16d6c6228aa58709299c86ec81a552a5 (diff) | |
parent | 3298a641a2b1c883b34e9d85541db50d6e2d1ff9 (diff) | |
download | sqlite-2606aca80f35c4672c7834e90786d737679fa35b.tar.gz sqlite-2606aca80f35c4672c7834e90786d737679fa35b.zip |
Merge recent enhancements from trunk. Default page size is 4096. Writes
to statement journals are avoided.
FossilOrigin-Name: 456df3365e2df60e34762f2024bb551538b3f72b
Diffstat (limited to 'src/shell.c')
-rw-r--r-- | src/shell.c | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/shell.c b/src/shell.c index 1cf9eb447..2ce2f292d 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1301,6 +1301,43 @@ static char *save_err_msg( return zErrMsg; } +#ifdef __linux__ +/* +** Attempt to display I/O stats on Linux using /proc/PID/io +*/ +static void displayLinuxIoStats(FILE *out){ + FILE *in; + char z[200]; + sqlite3_snprintf(sizeof(z), z, "/proc/%d/io", getpid()); + in = fopen(z, "rb"); + if( in==0 ) return; + while( fgets(z, sizeof(z), in)!=0 ){ + static const struct { + const char *zPattern; + const char *zDesc; + } aTrans[] = { + { "rchar: ", "Bytes received by read():" }, + { "wchar: ", "Bytes sent to write():" }, + { "syscr: ", "Read() system calls:" }, + { "syscw: ", "Write() system calls:" }, + { "read_bytes: ", "Bytes read from storage:" }, + { "write_bytes: ", "Bytes written to storage:" }, + { "cancelled_write_bytes: ", "Cancelled write bytes:" }, + }; + int i; + for(i=0; i<ArraySize(aTrans); i++){ + int n = (int)strlen(aTrans[i].zPattern); + if( strncmp(aTrans[i].zPattern, z, n)==0 ){ + raw_printf(out, "%-36s %s", aTrans[i].zDesc, &z[n]); + break; + } + } + } + fclose(in); +} +#endif + + /* ** Display memory stats. */ @@ -1423,6 +1460,10 @@ static int display_stats( raw_printf(pArg->out, "Virtual Machine Steps: %d\n", iCur); } +#ifdef __linux__ + displayLinuxIoStats(pArg->out); +#endif + /* Do not remove this machine readable comment: extra-stats-output-here */ return 0; @@ -1977,7 +2018,7 @@ static char zHelp[] = #endif ".shell CMD ARGS... Run CMD ARGS... in a system shell\n" ".show Show the current values for various settings\n" - ".stats on|off Turn stats on or off\n" + ".stats ?on|off? Show stats or turn stats on or off\n" ".system CMD ARGS... Run CMD ARGS... in a system shell\n" ".tables ?TABLE? List names of tables\n" " If TABLE specified, only list tables matching\n" @@ -4116,8 +4157,10 @@ static int do_meta_command(char *zLine, ShellState *p){ if( c=='s' && strncmp(azArg[0], "stats", n)==0 ){ if( nArg==2 ){ p->statsOn = booleanValue(azArg[1]); + }else if( nArg==1 ){ + display_stats(p->db, p, 0); }else{ - raw_printf(stderr, "Usage: .stats on|off\n"); + raw_printf(stderr, "Usage: .stats ?on|off?\n"); rc = 1; } }else |