function old new delta
nmeter_main 709 707 -2
init_cr 15 12 -3
collect_time 141 131 -10
collect_cpu 610 593 -17
init_cpu 82 63 -19
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-51) Total: -51 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
smallint is26;
// 1 if sample delay is not an integer fraction of a second
smallint need_seconds;
smallint is26;
// 1 if sample delay is not an integer fraction of a second
smallint need_seconds;
int delta;
int deltanz;
struct timeval tv;
int delta;
int deltanz;
struct timeval tv;
#define is26 (G.is26 )
#define need_seconds (G.need_seconds )
#define cur_outbuf (G.cur_outbuf )
#define is26 (G.is26 )
#define need_seconds (G.need_seconds )
#define cur_outbuf (G.cur_outbuf )
-#define final_str (G.final_str )
#define delta (G.delta )
#define deltanz (G.deltanz )
#define tv (G.tv )
#define delta (G.delta )
#define deltanz (G.deltanz )
#define tv (G.tv )
#define INIT_G() do { \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
cur_outbuf = outbuf; \
#define INIT_G() do { \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
cur_outbuf = outbuf; \
deltanz = delta = 1000000; \
} while (0)
deltanz = delta = 1000000; \
} while (0)
#define S_STAT(a) \
typedef struct a { \
struct s_stat *next; \
#define S_STAT(a) \
typedef struct a { \
struct s_stat *next; \
static s_stat* init_cr(const char *param UNUSED_PARAM)
{
static s_stat* init_cr(const char *param UNUSED_PARAM)
{
- final_str = "\r";
- return (s_stat*)0;
+ G.final_char = '\r';
+ return NULL;
// user nice system idle iowait irq softirq (last 3 only in 2.6)
//cpu 649369 0 341297 4336769 11640 7122 1183
//cpuN 649369 0 341297 4336769 11640 7122 1183
// user nice system idle iowait irq softirq (last 3 only in 2.6)
//cpu 649369 0 341297 4336769 11640 7122 1183
//cpuN 649369 0 341297 4336769 11640 7122 1183
S_STAT(cpu_stat)
ullong old[CPU_FIELDCNT];
int bar_sz;
S_STAT(cpu_stat)
ullong old[CPU_FIELDCNT];
int bar_sz;
static void FAST_FUNC collect_cpu(cpu_stat *s)
{
ullong data[CPU_FIELDCNT] = { 0, 0, 0, 0, 0, 0, 0 };
static void FAST_FUNC collect_cpu(cpu_stat *s)
{
ullong data[CPU_FIELDCNT] = { 0, 0, 0, 0, 0, 0, 0 };
static s_stat* init_cpu(const char *param)
{
int sz;
static s_stat* init_cpu(const char *param)
{
int sz;
- cpu_stat *s = xzalloc(sizeof(*s));
- s->collect = collect_cpu;
sz = strtoul(param, NULL, 0); /* param can be "" */
if (sz < 10) sz = 10;
if (sz > 1000) sz = 1000;
sz = strtoul(param, NULL, 0); /* param can be "" */
if (sz < 10) sz = 10;
if (sz > 1000) sz = 1000;
- s->bar = xzalloc(sz+1);
+ s = xzalloc(sizeof(*s) + sz);
/*s->bar[sz] = '\0'; - xzalloc did it */
s->bar_sz = sz;
/*s->bar[sz] = '\0'; - xzalloc did it */
s->bar_sz = sz;
+ s->collect = collect_cpu;
S_STAT(int_stat)
ullong old;
int no;
S_STAT(int_stat)
ullong old;
int no;
S_STAT(ctx_stat)
ullong old;
S_STAT_END(ctx_stat)
S_STAT(ctx_stat)
ullong old;
S_STAT_END(ctx_stat)
S_STAT(blk_stat)
const char* lookfor;
ullong old[2];
S_STAT(blk_stat)
const char* lookfor;
ullong old[2];
S_STAT(fork_stat)
ullong old;
S_STAT_END(fork_stat)
S_STAT(fork_stat)
ullong old;
S_STAT_END(fork_stat)
S_STAT(if_stat)
ullong old[4];
const char *device;
S_STAT(if_stat)
ullong old[4];
const char *device;
S_STAT(mem_stat)
char opt;
S_STAT_END(mem_stat)
S_STAT(mem_stat)
char opt;
S_STAT_END(mem_stat)
S_STAT(swp_stat)
S_STAT_END(swp_stat)
S_STAT(swp_stat)
S_STAT_END(swp_stat)
S_STAT(fd_stat)
S_STAT_END(fd_stat)
S_STAT(fd_stat)
S_STAT_END(fd_stat)
+ unsigned prec;
+ unsigned scale;
S_STAT_END(time_stat)
static void FAST_FUNC collect_time(time_stat *s)
{
char buf[sizeof("12:34:56.123456")];
struct tm* tm;
S_STAT_END(time_stat)
static void FAST_FUNC collect_time(time_stat *s)
{
char buf[sizeof("12:34:56.123456")];
struct tm* tm;
- int us = tv.tv_usec + s->scale/2;
+ unsigned us = tv.tv_usec + s->scale/2;
time_t t = tv.tv_sec;
if (us >= 1000000) {
time_t t = tv.tv_sec;
if (us >= 1000000) {
typedef s_stat* init_func(const char *param);
// Deprecated %NNNd is to be removed, -d MSEC supersedes it
typedef s_stat* init_func(const char *param);
// Deprecated %NNNd is to be removed, -d MSEC supersedes it
while (1) {
gettimeofday(&tv, NULL);
collect_info(first);
while (1) {
gettimeofday(&tv, NULL);
collect_info(first);
print_outbuf();
// Negative delta -> no usleep at all
print_outbuf();
// Negative delta -> no usleep at all