Skip to content

Commit

Permalink
Report disk average I/O in microseconds/nanoseconds (issue #89)
Browse files Browse the repository at this point in the history
Very fast drives might show 0.0 ms as the average I/O time. Therefore,
average I/O unit will be adapted to the smallest possible unit.
Due to the use of microseconds (abbreviates to a multibyte character),
the ncursesw library is used instead of ncurses library (the latter
calculates the number of characters in a wrong way).
  • Loading branch information
Atoptool committed Jan 4, 2020
1 parent e47d9f7 commit fa101b4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -34,7 +34,7 @@ all: atop atopsar atopacctd atopconvert

atop: atop.o $(ALLMODS) Makefile
$(CC) -c version.c
$(CC) atop.o $(ALLMODS) -o atop -lncurses -lz -lm -lrt $(LDFLAGS)
$(CC) atop.o $(ALLMODS) -o atop -lncursesw -lz -lm -lrt $(LDFLAGS)

atopsar: atop
ln -sf atop atopsar
Expand Down
2 changes: 1 addition & 1 deletion atopsar.c
Expand Up @@ -1716,7 +1716,7 @@ gendskline(struct sstat *ss, char *tstamp, char selector)
pn = dp->name;

printf("%-14s %3.0lf%% %6.1lf %7.1lf %7.1lf %7.1lf "
"%5.1lf %6.2lf ms",
"%5.1lf %9.5lf ms",
pn,
mstot ? (double)dp->io_ms * 100.0 / mstot : 0.0,
mstot ? (double)dp->nread * 1000.0 / mstot : 0.0,
Expand Down
2 changes: 2 additions & 0 deletions showgeneric.c
Expand Up @@ -274,6 +274,7 @@ static const char rcsid[] = "$Id: showgeneric.c,v 1.71 2010/10/25 19:08:32 gerlo
#include <pwd.h>
#include <grp.h>
#include <regex.h>
#include <locale.h>

#include "atop.h"
#include "photoproc.h"
Expand Down Expand Up @@ -2827,6 +2828,7 @@ generic_init(void)
/*
** initialize screen-handling via curses
*/
setlocale(LC_ALL, "");
initscr();
cbreak();
noecho();
Expand Down
12 changes: 6 additions & 6 deletions showsys.c
Expand Up @@ -1903,23 +1903,23 @@ sysprt_DSKAVIO(void *p, void *q, int badness, int *color)

*color = -1;

if (tim > 100.0)
if (tim >= 100.0)
{
sprintf(buf+5, "%4.0lf ms", tim);
}
else if (tim > 10.0)
else if (tim >= 10.0)
{
sprintf(buf+5, "%4.1lf ms", tim);
}
else if (tim > 0.1)
else if (tim >= 0.1)
{
sprintf(buf+5, "%3.2lf ms", tim);
sprintf(buf+5, "%4.2lf ms", tim);
}
else if (tim > 0.01)
else if (tim >= 0.01)
{
sprintf(buf+5, "%4.1lf µs", tim * 1000.0);
}
else if (tim > 0.0001)
else if (tim >= 0.0001)
{
sprintf(buf+5, "%4.2lf µs", tim * 1000.0);
}
Expand Down

0 comments on commit fa101b4

Please sign in to comment.