コード例 #1
0
ファイル: efuns_port.c プロジェクト: Yuffster/fluffOS
void
f_rusage (void)
{
    mapping_t *m;
    struct tms t;

    times(&t);
    m = allocate_mapping(2);
    add_mapping_pair(m, "utime", t.tms_utime * 1000 / CLK_TCK);
    add_mapping_pair(m, "stime", t.tms_stime * 1000 / CLK_TCK);
    push_refed_mapping(m);
}
コード例 #2
0
ファイル: mudlib_stats.c プロジェクト: BPotato/fluffos
static mapping_t *
        get_info (mudlib_stats_t * dl)
{
    mapping_t *ret;

    ret = allocate_mapping(8);
    add_mapping_pair(ret, "moves", dl->moves);
    add_mapping_pair(ret, "errors", dl->errors);
    add_mapping_pair(ret, "heart_beats", dl->heart_beats);
    add_mapping_pair(ret, "array_size", dl->size_array);
    add_mapping_pair(ret, "objects", dl->objects);
    return ret;
}
コード例 #3
0
ファイル: efuns_port.c プロジェクト: Yuffster/fluffOS
void
f_rusage (void)
{
    mapping_t *m;
    int i;
    unsigned int clock[2];

    i = timer(clock);           /* returns 0 if success, -1 otherwise */
    m = allocate_mapping(2);
    add_mapping_pair(m, "utime", i ? 0 : clock[0] * 1000 + clock[1] / 1000);
    add_mapping_pair(m, "stime", i ? 0 : clock[0] * 1000 + clock[1] / 1000);
    push_refed_mapping(m);
}
コード例 #4
0
ファイル: debug.c プロジェクト: jrealm/TCW
mapping_t *debug_levels() {
    int dl = debug_level;
    mapping_t *ret = allocate_mapping(10);
    int i;

    for (i = 0; i < NELEM(levels); i++) {
	add_mapping_pair(ret, levels[i].name, dl & levels[i].bit);
	dl &= ~levels[i].bit;
    }

    if (dl)
	add_mapping_pair(ret, "unknown", dl);

    return ret;
}
コード例 #5
0
ファイル: efuns_port.c プロジェクト: Yuffster/fluffOS
void
f_rusage (void)
{
    struct process_stats ps;
    mapping_t *m;
    int utime, stime, maxrss;

    if (get_process_stats(NULL, PS_SELF, &ps, NULL) == -1)
        m = allocate_mapping(0);
    else {
        utime = ps.ps_utime.tv_sec * 1000 + ps.ps_utime.tv_usec / 1000;
        stime = ps.ps_stime.tv_sec * 1000 + ps.ps_stime.tv_usec / 1000;
        maxrss = ps.ps_maxrss * getpagesize() / 1024;

        m = allocate_mapping(19);
        add_mapping_pair(m, "utime", utime);
        add_mapping_pair(m, "stime", stime);
        add_mapping_pair(m, "maxrss", maxrss);
        add_mapping_pair(m, "pagein", ps.ps_pagein);
        add_mapping_pair(m, "reclaim", ps.ps_reclaim);
        add_mapping_pair(m, "zerofill", ps.ps_zerofill);
        add_mapping_pair(m, "pffincr", ps.ps_pffincr);
        add_mapping_pair(m, "pffdecr", ps.ps_pffdecr);
        add_mapping_pair(m, "swap", ps.ps_swap);
        add_mapping_pair(m, "syscall", ps.ps_syscall);
        add_mapping_pair(m, "volcsw", ps.ps_volcsw);
        add_mapping_pair(m, "involcsw", ps.ps_involcsw);
        add_mapping_pair(m, "signal", ps.ps_signal);
        add_mapping_pair(m, "lread", ps.ps_lread);
        add_mapping_pair(m, "lwrite", ps.ps_lwrite);
        add_mapping_pair(m, "bread", ps.ps_bread);
        add_mapping_pair(m, "bwrite", ps.ps_bwrite);
        add_mapping_pair(m, "phread", ps.ps_phread);
        add_mapping_pair(m, "phwrite", ps.ps_phwrite);
    }
    push_refed_mapping(m);
}
コード例 #6
0
ファイル: efuns_port.c プロジェクト: Yuffster/fluffOS
void
f_rusage (void)
{
    struct rusage rus;
    mapping_t *m;
    long usertime, stime;
    int maxrss;

    if (getrusage(RUSAGE_SELF, &rus) < 0) {
        m = allocate_mapping(0);
    } else {
#if 1 /* Was !SunOS_5 */
        usertime = rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
        stime = rus.ru_stime.tv_sec * 1000 + rus.ru_stime.tv_usec / 1000;
#else
        usertime = rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_nsec / 1000000;
        stime = rus.ru_stime.tv_sec * 1000 + rus.ru_stime.tv_nsec / 1000000;
#endif
        maxrss = rus.ru_maxrss;
#ifdef sun
        maxrss *= getpagesize() / 1024;
#endif
        m = allocate_mapping(16);
        add_mapping_pair(m, "utime", usertime);
        add_mapping_pair(m, "stime", stime);
        add_mapping_pair(m, "maxrss", maxrss);
        add_mapping_pair(m, "ixrss", rus.ru_ixrss);
        add_mapping_pair(m, "idrss", rus.ru_idrss);
        add_mapping_pair(m, "isrss", rus.ru_isrss);
        add_mapping_pair(m, "minflt", rus.ru_minflt);
        add_mapping_pair(m, "majflt", rus.ru_majflt);
        add_mapping_pair(m, "nswap", rus.ru_nswap);
        add_mapping_pair(m, "inblock", rus.ru_inblock);
        add_mapping_pair(m, "oublock", rus.ru_oublock);
        add_mapping_pair(m, "msgsnd", rus.ru_msgsnd);
        add_mapping_pair(m, "msgrcv", rus.ru_msgrcv);
        add_mapping_pair(m, "nsignals", rus.ru_nsignals);
        add_mapping_pair(m, "nvcsw", rus.ru_nvcsw);
        add_mapping_pair(m, "nivcsw", rus.ru_nivcsw);
    }
    push_refed_mapping(m);
}
コード例 #7
0
ファイル: efuns_port.c プロジェクト: abzde/dock9
void
f_rusage (void)
{
    struct rusage rus;
    mapping_t *m;
    long usertime, stime;
    int maxrss;

    if (getrusage(RUSAGE_SELF, &rus) < 0) {
        m = allocate_mapping(0);
    } else {
#ifdef __linux__
        char buf[256];
        int fd;
#endif
        usertime = rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
        stime = rus.ru_stime.tv_sec * 1000 + rus.ru_stime.tv_usec / 1000;
        maxrss = rus.ru_maxrss;
#ifdef sun
        maxrss *= getpagesize() / 1024;
#else
#ifdef __linux__
        fd = open("/proc/self/statm", O_RDONLY);
        buf[read(fd, buf, 256)] = 0;
        close(fd);
        sscanf(buf, "%*d %d %*s", &maxrss);
        maxrss *= getpagesize() / 1024;
#endif
#endif
        m = allocate_mapping(16);
        add_mapping_pair(m, "utime", usertime);
        add_mapping_pair(m, "stime", stime);
        add_mapping_pair(m, "maxrss", maxrss);
        add_mapping_pair(m, "ixrss", rus.ru_ixrss);
        add_mapping_pair(m, "idrss", rus.ru_idrss);
        add_mapping_pair(m, "isrss", rus.ru_isrss);
        add_mapping_pair(m, "minflt", rus.ru_minflt);
        add_mapping_pair(m, "majflt", rus.ru_majflt);
        add_mapping_pair(m, "nswap", rus.ru_nswap);
        add_mapping_pair(m, "inblock", rus.ru_inblock);
        add_mapping_pair(m, "oublock", rus.ru_oublock);
        add_mapping_pair(m, "msgsnd", rus.ru_msgsnd);
        add_mapping_pair(m, "msgrcv", rus.ru_msgrcv);
        add_mapping_pair(m, "nsignals", rus.ru_nsignals);
        add_mapping_pair(m, "nvcsw", rus.ru_nvcsw);
        add_mapping_pair(m, "nivcsw", rus.ru_nivcsw);
    }
    push_refed_mapping(m);
}