MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / displayLinuxIoStats

Function displayLinuxIoStats

modules/dasSQLITE/sqlite/shell.c:18037–18066  ·  view source on GitHub ↗

** Attempt to display I/O stats on Linux using /proc/PID/io */

Source from the content-addressed store, hash-verified

18035** Attempt to display I/O stats on Linux using /proc/PID/io
18036*/
18037static void displayLinuxIoStats(FILE *out){
18038 FILE *in;
18039 char z[200];
18040 sqlite3_snprintf(sizeof(z), z, "/proc/%d/io", getpid());
18041 in = fopen(z, "rb");
18042 if( in==0 ) return;
18043 while( fgets(z, sizeof(z), in)!=0 ){
18044 static const struct {
18045 const char *zPattern;
18046 const char *zDesc;
18047 } aTrans[] = {
18048 { "rchar: ", "Bytes received by read():" },
18049 { "wchar: ", "Bytes sent to write():" },
18050 { "syscr: ", "Read() system calls:" },
18051 { "syscw: ", "Write() system calls:" },
18052 { "read_bytes: ", "Bytes read from storage:" },
18053 { "write_bytes: ", "Bytes written to storage:" },
18054 { "cancelled_write_bytes: ", "Cancelled write bytes:" },
18055 };
18056 int i;
18057 for(i=0; i<ArraySize(aTrans); i++){
18058 int n = strlen30(aTrans[i].zPattern);
18059 if( cli_strncmp(aTrans[i].zPattern, z, n)==0 ){
18060 utf8_printf(out, "%-36s %s", aTrans[i].zDesc, &z[n]);
18061 break;
18062 }
18063 }
18064 }
18065 fclose(in);
18066}
18067#endif
18068
18069/*

Callers 1

display_statsFunction · 0.85

Calls 3

strlen30Function · 0.85
cli_strncmpFunction · 0.85
utf8_printfFunction · 0.85

Tested by

no test coverage detected