From: Martin Mares Date: Thu, 9 Feb 2012 21:48:31 +0000 (+0100) Subject: The `profile' module has been removed X-Git-Tag: v5.0~91 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=0c8be696e4121d4d1b8a4439d63819a01a8292c8;p=libucw.git The `profile' module has been removed It was obsolete and I do not know of any use in last 5 years. --- diff --git a/ucw/Makefile b/ucw/Makefile index 36e11b13..9a136a0d 100644 --- a/ucw/Makefile +++ b/ucw/Makefile @@ -15,7 +15,6 @@ LIBUCW_MODS= \ log log-stream log-file log-syslog log-conf proctitle tbf \ conf-alloc conf-dump conf-input conf-intr conf-journal conf-parse conf-section \ ipaccess \ - profile \ fastbuf ff-binary ff-string ff-printf ff-unicode ff-stkstring \ fb-file carefulio fb-mem fb-temp tempfile fb-mmap fb-limfd fb-buffer fb-grow fb-pool fb-atomic fb-param fb-socket \ char-cat char-upper char-lower unicode stkstring \ @@ -49,7 +48,6 @@ LIBUCW_MAIN_INCLUDES= \ prime.h \ bitops.h \ conf.h getopt.h ipaccess.h \ - profile.h \ fastbuf.h lfs.h ff-unicode.h ff-binary.h \ url.h \ mainloop.h \ diff --git a/ucw/doc/index.txt b/ucw/doc/index.txt index a9981c5f..4a14d521 100644 --- a/ucw/doc/index.txt +++ b/ucw/doc/index.txt @@ -78,8 +78,6 @@ Yet undocumented modules * `semaphore.h` * `threads.h` * `workqueue.h` -- Profiling support - * `profile.h` License ------- diff --git a/ucw/profile.c b/ucw/profile.c deleted file mode 100644 index 13af31ed..00000000 --- a/ucw/profile.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * UCW Library -- Poor Man's Profiler - * - * (c) 2001 Martin Mares - * - * This software may be freely distributed and used according to the terms - * of the GNU Lesser General Public License. - */ - -#include "ucw/lib.h" -#include "ucw/profile.h" - -#include - -/* PROFILE_TOD */ - -#include - -void -prof_tod_init(struct prof_tod *c) -{ - c->sec = c->usec = 0; -} - -void -prof_tod_switch(struct prof_tod *o, struct prof_tod *n) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - if (n) - { - n->start_sec = tv.tv_sec; - n->start_usec = tv.tv_usec; - } - if (o) - { - o->sec += tv.tv_sec - o->start_sec; - o->usec += tv.tv_usec - o->start_usec; - if (o->usec < 0) - { - o->usec += 1000000; - o->sec--; - } - else while (o->usec >= 1000000) - { - o->usec -= 1000000; - o->sec++; - } - } -} - -int -prof_tod_format(char *buf, struct prof_tod *c) -{ - return sprintf(buf, "%d.%06d", c->sec, c->usec); -} - -/* PROFILE_TSC */ - -#ifdef CPU_I386 - -void -prof_tsc_init(struct prof_tsc *c) -{ - c->ticks = 0; -} - -int -prof_tsc_format(char *buf, struct prof_tsc *c) -{ - return sprintf(buf, "%lld", c->ticks); -} - -#endif - -/* PROFILE_KTSC */ - -#ifdef CONFIG_LINUX - -#include -#include -static int self_prof_fd = -1; - -void -prof_ktsc_init(struct prof_ktsc *c) -{ - if (self_prof_fd < 0) - { - self_prof_fd = open("/proc/self/profile", O_RDONLY, 0); - if (self_prof_fd < 0) - die("Unable to open /proc/self/profile: %m"); - } - c->ticks_user = 0; - c->ticks_sys = 0; -} - -void -prof_ktsc_switch(struct prof_ktsc *o, struct prof_ktsc *n) -{ - unsigned long long u, s; - byte buf[256]; - - int l = pread(self_prof_fd, buf, sizeof(buf)-1, 0); - ASSERT(l > 0 && l < (int)sizeof(buf)-1); - buf[l] = 0; - l = sscanf(buf, "%lld%lld", &u, &s); - ASSERT(l == 2); - - if (n) - { - n->start_user = u; - n->start_sys = s; - } - if (o) - { - u -= o->start_user; - o->ticks_user += u; - s -= o->start_sys; - o->ticks_sys += s; - } -} - -int -prof_ktsc_format(char *buf, struct prof_ktsc *c) -{ - return sprintf(buf, "%lld+%lld", (long long) c->ticks_user, (long long) c->ticks_sys); -} - -#endif diff --git a/ucw/profile.h b/ucw/profile.h deleted file mode 100644 index 245ad768..00000000 --- a/ucw/profile.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * UCW Library -- Poor Man's Profiler - * - * (c) 2001 Martin Mares - * - * This software may be freely distributed and used according to the terms - * of the GNU Lesser General Public License. - */ - -/* - * Usage: - * #define PROFILE_xxx - * #include "ucw/profile.h" - * prof_t cnt; - * prof_init(&cnt); - * ... - * prof_start(&cnt); - * ... - * prof_stop(&cnt); - * printf("%s\n", PROF_STR(cnt)); - */ - -#ifndef _UCW_PROFILE_H -#define _UCW_PROFILE_H - -/* PROFILE_TOD: gettimeofday() profiler */ - -struct prof_tod { - u32 start_sec, start_usec; - s32 sec, usec; -}; - -void prof_tod_init(struct prof_tod *); -void prof_tod_switch(struct prof_tod *, struct prof_tod *); -int prof_tod_format(char *, struct prof_tod *); - -/* PROFILE_TSC: i386 TSC profiler */ - -#ifdef CPU_I386 - -struct prof_tsc { - u64 start_tsc; - u64 ticks; -}; - -void prof_tsc_init(struct prof_tsc *); -int prof_tsc_format(char *, struct prof_tsc *); - -#endif - -/* PROFILE_KTSC: Linux kernel TSC profiler */ - -#ifdef CONFIG_LINUX - -struct prof_ktsc { - u64 start_user, start_sys; - u64 ticks_user, ticks_sys; -}; - -void prof_ktsc_init(struct prof_ktsc *); -void prof_ktsc_switch(struct prof_ktsc *, struct prof_ktsc *); -int prof_ktsc_format(char *, struct prof_ktsc *); - -#endif - -/* Select the right profiler */ - -#if defined(PROFILE_TOD) - -#define PROFILER -#define PROF_STR_SIZE 21 -typedef struct prof_tod prof_t; -#define prof_init prof_tod_init -#define prof_switch prof_tod_switch -#define prof_format prof_tod_format - -#elif defined(PROFILE_TSC) - -#define PROFILER -#define PROFILER_INLINE -#define PROF_STR_SIZE 24 - -typedef struct prof_tsc prof_t; -#define prof_init prof_tsc_init -#define prof_format prof_tsc_format - -#define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val)) - -static inline void prof_start(prof_t *c) -{ - rdtscll(c->start_tsc); -} - -static inline void prof_stop(prof_t *c) -{ - u64 tsc; - rdtscll(tsc); - tsc -= c->start_tsc; - c->ticks += tsc; -} - -static inline void prof_switch(prof_t *o, prof_t *n) -{ - u64 tsc; - rdtscll(tsc); - n->start_tsc = tsc; - tsc -= o->start_tsc; - o->ticks += tsc; -} - -#elif defined(PROFILE_KTSC) - -#define PROFILER -#define PROF_STR_SIZE 50 -typedef struct prof_ktsc prof_t; -#define prof_init prof_ktsc_init -#define prof_switch prof_ktsc_switch -#define prof_format prof_ktsc_format - -#endif - -#ifdef PROFILER - -/* Stuff common for all profilers */ -#ifndef PROFILER_INLINE -static inline void prof_start(prof_t *c) { prof_switch(NULL, c); } -static inline void prof_stop(prof_t *c) { prof_switch(c, NULL); } -#endif -#define PROF_STR(C) ({ static char _x[PROF_STR_SIZE]; prof_format(_x, &(C)); _x; }) - -#else - -/* Dummy profiler with no output */ -typedef struct { } prof_t; -static inline void prof_init(prof_t *c UNUSED) { } -static inline void prof_start(prof_t *c UNUSED) { } -static inline void prof_stop(prof_t *c UNUSED) { } -static inline void prof_switch(prof_t *c UNUSED, prof_t *d UNUSED) { } -static inline void prof_format(char *b, prof_t *c UNUSED) { b[0]='?'; b[1]=0; } -#define PROF_STR_SIZE 2 -#define PROF_STR(C) "?" - -#endif - -#endif