- enhanced statistics command

This commit is contained in:
zolliker
2007-02-23 12:14:29 +00:00
parent ebbde45f33
commit 7c3b4fd642

View File

@ -47,14 +47,15 @@ int StatisticsCommand(SConnection *con, SicsInterp *pSics, void *pData,
int argc, char *argv[]) {
Statistics *p;
tv_t now;
double dif, percent, full, dt;
double dif, percent, full, dt, calls;
gettimeofday(&now, 0);
dif = timeFloat(timeDif(lastStat, now));
SCPrintf(con, eStatus, " calls time[%] full[%] mean[ms] command");
SCPrintf(con, eStatus, "calls/s time[%] full[%] mean[ms] command");
SCPrintf(con, eStatus, "----------------------------------------------");
for (p = list; p != NULL; p = p->next) {
if (dif > 0) {
calls = p->cnt / dif;
percent = timeFloat(p->tim) * 100 / dif;
full = timeFloat(p->total) * 100 / dif;
if (full > 0 || percent > 0) {
@ -63,7 +64,7 @@ int StatisticsCommand(SConnection *con, SicsInterp *pSics, void *pData,
} else {
dt = 0;
}
SCPrintf(con, eStatus, "%7ld %7.1f %7.1f %8.2f %s", p->cnt,
SCPrintf(con, eStatus, "%7.1f %7.1f %7.1f %8.2f %s", calls,
percent, full, dt, p->name);
}
}
@ -73,6 +74,8 @@ int StatisticsCommand(SConnection *con, SicsInterp *pSics, void *pData,
p->total.tv_sec = 0;
p->total.tv_usec = 0;
}
SCPrintf(con, eStatus, "----------------------------------------------");
SCPrintf(con, eStatus, "total time %.2f", dif);
lastStat = now;
return 1;
}