[Pkg-wmaker-commits] [wmsysmon] 04/37: Imported Upstream version 0.7.7

Doug Torrance dtorrance-guest at moszumanska.debian.org
Tue Aug 25 03:09:45 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmsysmon.

commit 2ab8e382c28a97bbbee048bbe311f8d871a96ac3
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Sun Jul 12 10:01:20 2015 -0600

    Imported Upstream version 0.7.7
---
 ChangeLog              |  24 +++++++
 FAQ                    |   7 --
 README                 |  10 +--
 meminfotest/Makefile   |  10 ---
 meminfotest/README     |  21 ------
 meminfotest/test.c     |  18 ------
 profiles/profile-0.6.0 |  15 -----
 profiles/profile-0.7.5 |  22 -------
 profiles/profile-0.7.6 |  22 -------
 src/Makefile           |   2 +-
 src/Makefile-profile   |  29 ---------
 src/wmgeneral.c        |  80 +++--------------------
 src/wmgeneral.h        |   2 +-
 src/wmsysmon.c         | 172 ++++++++++++++-----------------------------------
 14 files changed, 85 insertions(+), 349 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6a707a6..1bc8ca9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,28 @@
 -- end --
+- Aug 4 2002 - Vito Caputo (swivel at gnugeneration.com) -
+	* a few changes, i can't recall, the interrupt meters have been refined
+	  a bit, main event loop changed but theres a slight bug with the
+	  event loop timing, the timeout doesnt get updated dynamically if the
+	  main select() exits before the timeout...  you can see this by say
+	  dragging an icon over wmsysmon a bunch, the meters will all shrink
+	  if interrupts are ocurring, because the time between polls of
+	  the interrupt counts is shorter than before, causing it to think
+	  theres less interrupts, when in fact, there was less time for them
+	  to occur, minor bug.
+
+- Dec 24 2001 - Vito Caputo (swivel at gnugeneration.com) -
+	* minor cleanups, in wmgeneral.c added static int where was just static.
+	  (int is assumed but caused warning in -Wall), also removed some
+	  unused variables...
+
+- Dec 23 2001 - Vito Caputo (swivel at gnugeneration.com) -
+	* removed profiling instrumentation, it's no longer needed.
+	* updated meters, the behaviour is changed a bit, interrupts that
+	  never occur dont get the _ level so you can see which are inactive
+	  in the system, and they should be more responsive.
+	* removed usleep() usage and switched to poll() with a timeout on the
+	  X connection fd, more efficient and allows expose events to be handled
+	  with less latency.
 
 - Jul 11 2000 - Vito Caputo (swivel at gnugeneration.com) -
 	* eliminated the memcpy() used for copying interrupt statistics into
diff --git a/FAQ b/FAQ
deleted file mode 100644
index 9c13a15..0000000
--- a/FAQ
+++ /dev/null
@@ -1,7 +0,0 @@
-Q: Why does wmsysmon use so much CPU time? (4-6% on some systems)
-A: On some machines, polling /proc/meminfo turns out to be an expensive
-   task, this is for the most part fixed in kernel 2.4, but still happens
-   on kernel 2.2.  We have included a test program so you may see if there
-   is such a bottleneck on your system.  For this does not happen on all
-   2.2 machines, we have also cut down the /proc/meminfo polling in 0.7.0+
-   of wmsysmon, so this should not be a problem any longer.  see: meminfotest/README
diff --git a/README b/README
index 550c9e8..22cbb9c 100644
--- a/README
+++ b/README
@@ -18,17 +18,9 @@ binary in /usr/local/bin to use wmsysmon, it may be run from anywhere in
 the filesystem, but on a multi-user system it is preferred to have it available
 for everyone to use, hence /usr/local/bin.
 
-For information on running wmsysmon, execute 'wmsysmon -h' afer building (and
+For information on running wmsysmon, execute 'wmsysmon -h' after building (and
 installing) using the above instructions.
 
-I have also added some profiling output in the directory "profiles", you can
-see in these files the improvements that have been done (scientific proof)
-to wmsysmon.
-
-The Makefile-profile makefile is used for building wmsysmon with profiling
-enabled, this requires the profiling tools to be installed and configured.
-You probably dont care about this.
-
 Cheers.
 
 - Vito Caputo
diff --git a/meminfotest/Makefile b/meminfotest/Makefile
deleted file mode 100644
index 53114b7..0000000
--- a/meminfotest/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-CC := gcc
-
-BIN := test
-OBJ := test.o
-
-$(BIN): $(OBJ)
-	$(CC) -o $(BIN) $(OBJ)
-
-clean:
-	rm -f $(OBJ) $(BIN)
diff --git a/meminfotest/README b/meminfotest/README
deleted file mode 100644
index 596d53c..0000000
--- a/meminfotest/README
+++ /dev/null
@@ -1,21 +0,0 @@
-This is a program used to benchmark your /proc/meminfo, you need to time it
-using the time program (TIME(1)), simply run make to build it, then execute
-it like so:
-
-time ./test
-
-If the results are over 30s of system time, your /proc/meminfo is slow.
-On my P166MMX overclocked to 187Mhz it takes 12s system time, on a dual
-ppro 180Mhz we tested it took 1:02s (yes, thats 1 minute and 2 seconds).
-Both were running kernel 2.2.
-
-We also ran the same test on a 400Mhz celeron using both 2.2 and 2.4, on 2.2
-it took 11s, on 2.4 it took 4s.
-
-I would love to hear the results of any tests you perform using this, email
-results to me.
-
-- Vito Caputo
-  swivel at gnugeneration.com
-  GNU Generation
-  www.gnugeneration.com
diff --git a/meminfotest/test.c b/meminfotest/test.c
deleted file mode 100644
index 6a321ab..0000000
--- a/meminfotest/test.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include	<stdio.h>
-#include	<dirent.h>
-
-
-main(void)
-{
-	char		buf[128];
-	FILE		*fp;
-	int		i = 0;
-
-	fp = fopen("/proc/meminfo", "r");
-
-	while(i < 1000) {
-		freopen("/proc/meminfo", "r", fp);
-		while(fgets(buf, 128, fp));
-		i++;
-	}
-}
diff --git a/profiles/profile-0.6.0 b/profiles/profile-0.6.0
deleted file mode 100644
index 6a33732..0000000
--- a/profiles/profile-0.6.0
+++ /dev/null
@@ -1,15 +0,0 @@
-Reading Profile files in /home/swivel/src/wmsysmon/src/profile.*
-
-NODE 0;CONTEXT 0;THREAD 0:
----------------------------------------------------------------------------------------
-%Time    Exclusive    Inclusive       #Call      #Subrs  Inclusive Name
-              msec   total msec                          usec/call 
----------------------------------------------------------------------------------------
-100.0            0       10,480           1           1   10480000 main() int(int, char **)
-100.0           60       10,480           1        3000   10480000 wmsysmon_routine() (int, char **)
- 93.9        9,840        9,840        1000           2       9840 DrawMem() 
-  5.4          200          570        1000       16011        570 DrawStuff() 
-  3.4          360          360       16000           0         22 DrawMeter() (int, unsigned int, int, int)
-  0.1           10           10          13           0        769 DrawBar() (int, int, int, int, float, int, int)
-  0.1           10           10        1000           4         10 DrawUptime() 
-  0.0            0            0           4           0          0 BlitString() (char *, int, int)
diff --git a/profiles/profile-0.7.5 b/profiles/profile-0.7.5
deleted file mode 100644
index 2befb26..0000000
--- a/profiles/profile-0.7.5
+++ /dev/null
@@ -1,22 +0,0 @@
-Reading Profile files in /home/swivel/src/wmsysmon/src/profile.*
-
-NODE 0;CONTEXT 0;THREAD 0:
----------------------------------------------------------------------------------------
-%Time    Exclusive    Inclusive       #Call      #Subrs  Inclusive Name
-              msec   total msec                          usec/call 
----------------------------------------------------------------------------------------
-100.0            0           40           1           1      40000 main() int(int, char **)
-100.0            0           40           1        4116      40000 wmsysmon_routine() (int, char **)
- 50.0           20           20        1000           2         20 DrawMem() 
- 50.0           20           20           1           0      20000 GetXPM (XpmIcon *, char *)
-  0.0            0            0           3           8          0 BlitString() (char *, int, int)
-  0.0            0            0       16140           0          0 DirtyWindow (int, int, int, int)
-  0.0            0            0           5          10          0 DrawBar() (int, int, int, int, float, int, int)
-  0.0            0            0          12          12          0 DrawLite() (int, int, int)
-  0.0            0            0       16000       15999          0 DrawMeter() (int, unsigned int, int, int)
-  0.0            0            0        1000       16015          0 DrawStuff() 
-  0.0            0            0        1000           3          0 DrawUptime() 
-  0.0            0            0           2           0          0 GetColor Pixel
-  0.0            0            0        1000           0          0 RedrawWindow 
-  0.0            0            0       16029       16028          0 copyXPMArea (int, int, int, int, int, int)
-  0.0            0            0           1           0          0 createXBMfromXPM (char *, char **, int, int)
diff --git a/profiles/profile-0.7.6 b/profiles/profile-0.7.6
deleted file mode 100644
index e52ae4a..0000000
--- a/profiles/profile-0.7.6
+++ /dev/null
@@ -1,22 +0,0 @@
-Reading Profile files in profile.*
-
-NODE 0;CONTEXT 0;THREAD 0:
----------------------------------------------------------------------------------------
-%Time    Exclusive    Inclusive       #Call      #Subrs  Inclusive Name
-              msec   total msec                          usec/call 
----------------------------------------------------------------------------------------
-100.0            0           70           1           1      70000 main() int(int, char **)
-100.0           30           70           1          17      70000 wmsysmon_routine() (int, char **)
- 42.9           30           30           1           0      30000 GetXPM (XpmIcon *, char *)
- 28.6           20           20        1000       16912         20 DrawStuff() 
-  0.0            0            0           3           8          0 BlitString() (char *, int, int)
-  0.0            0            0       17398           0          0 DirtyWindow (int, int, unsigned int, unsigned int)
-  0.0            0            0         365         730          0 DrawBar() (int, int, int, int, float, int, int)
-  0.0            0            0         550         550          0 DrawLite() (int, int, int)
-  0.0            0            0        1000        4102          0 DrawMem() 
-  0.0            0            0       16000       15999          0 DrawMeter() (int, unsigned int, int, int)
-  0.0            0            0        1000           3          0 DrawUptime() 
-  0.0            0            0           2           0          0 GetColor Pixel
-  0.0            0            0        1000           0          0 RedrawWindow 
-  0.0            0            0       17287       17286          0 copyXPMArea (int, int, int, int, int, int)
-  0.0            0            0           1           0          0 createXBMfromXPM (char *, char **, int, int)
diff --git a/src/Makefile b/src/Makefile
index b629a5e..c167d22 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -3,7 +3,7 @@ CC = gcc
 LIBDIR += -L/usr/X11R6/lib
 LDFLAGS += -lXpm -lXext -lX11 -lm -s
 #CFLAGS = -g #-DMONDEBUG
-CFLAGS += -O3 -m486 -fomit-frame-pointer -I/usr/X11R6/include #-DHI_INTS #undefine HI_INTS if your x86 SMP or alpha
+CFLAGS += -Wall -O3 -m486 -fomit-frame-pointer -I/usr/X11R6/include #-DHI_INTS #undefine HI_INTS if your x86 SMP or alpha
 
 BIN = wmsysmon
 OBJS =	wmgeneral.o \
diff --git a/src/Makefile-profile b/src/Makefile-profile
deleted file mode 100644
index 5cb3c68..0000000
--- a/src/Makefile-profile
+++ /dev/null
@@ -1,29 +0,0 @@
-TAUROOTDIR := /home/swivel/tau
-
-include $(TAUROOTDIR)/include/Makefile
-
-CFLAGS := $(TAU_INCLUDE) $(TAU_DEFS)
-LIBS := $(TAU_LIBS) -lpthread
-
-CC = $(TAU_CC)
-CXX = $(TAU_CXX)
-
-LIBDIR += -L/usr/X11R6/lib
-LDFLAGS += -g -lXpm -lXext -lX11 -lm
-#CFLAGS = -p #-DMONDEBUG
-CFLAGS += -O3 -DPROF #-DHI_INTS #undefine HI_INTS if your x86 smp or alpha
-
-BIN = wmsysmon
-OBJS =	wmgeneral.o \
-	wmsysmon.o
-
-$(BIN): $(OBJS)
-	$(CXX) -o $(BIN) $(OBJS) $(LIBDIR) $(LDFLAGS) $(LIBS)
-
-all: wmsysmon
-
-clean:
-	rm -f $(OBJS) $(BIN)
-
-install:
-	install -g root -o root $(BIN) /usr/local/bin
diff --git a/src/wmgeneral.c b/src/wmgeneral.c
index dfc4184..29c2cfa 100644
--- a/src/wmgeneral.c
+++ b/src/wmgeneral.c
@@ -8,9 +8,6 @@
 #include <X11/Xlib.h>
 #include <X11/xpm.h>
 #include <X11/extensions/shape.h>
-#ifdef PROF
-#include <Profile/Profiler.h>
-#endif
 
 #include "wmgeneral.h"
 
@@ -37,10 +34,6 @@ static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) {
 
 	XWindowAttributes	attributes;
 	int			err;
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "GetXPM", "(XpmIcon *, char *)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 
 	/* For the colormap */
 	XGetWindowAttributes(display, Root, &attributes);
@@ -54,9 +47,6 @@ static void GetXPM(XpmIcon *wmgen, char *pixmap_bytes[]) {
 	wmgen->dirty_w = 0;
 	wmgen->dirty_h = 0;
 	
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 	if (err != XpmSuccess) {
 		fprintf(stderr, "Not enough free colorcells.\n");
 		exit(1);
@@ -68,10 +58,6 @@ static Pixel GetColor(char *name) {
 
 	XColor				color;
 	XWindowAttributes	attributes;
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "GetColor", "Pixel", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 
 	XGetWindowAttributes(display, Root, &attributes);
 
@@ -82,18 +68,11 @@ static Pixel GetColor(char *name) {
 		fprintf(stderr, "wm.app: can't allocate %s.\n", name);
 	}
 
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 	return color.pixel;
 }
 
 
 void RedrawWindow(void) {
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "RedrawWindow", "", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 	
 	if(wmgen.dirty_w && wmgen.dirty_h)
 	XCopyArea(display,
@@ -133,34 +112,20 @@ void RedrawWindow(void) {
 	wmgen.dirty_w = 0;
 	wmgen.dirty_h = 0;
 
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
 void RedrawWindowXY(int x, int y) {
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "RedrawWindowXY", "(int, int)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 	
 	XCopyArea(display, wmgen.pixmap, iconwin, NormalGC, 
 				x, y, wmgen.attributes.width, wmgen.attributes.height, 0,0);
 	XCopyArea(display, wmgen.pixmap, win, NormalGC,
 				x, y, wmgen.attributes.width, wmgen.attributes.height, 0,0);
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
 void DirtyWindow(int x, int y, unsigned int w, unsigned int h) {
-	static	nx, ny, nw, nh;
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "DirtyWindow", "(int, int, unsigned int, unsigned int)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
+	static	int	nx, ny, nw, nh;
 
 #ifdef MONDEBUG
 	printf("currently dirty: X: %i Y: %i W: %u H: %u new: X: %i Y: %i W: %u H: %u\n",
@@ -191,21 +156,12 @@ void DirtyWindow(int x, int y, unsigned int w, unsigned int h) {
 	wmgen.dirty_w = nw;
 	wmgen.dirty_h = nh;
 #ifdef MONDEBUG
-	printf("Final: X: %i Y: %i W: %u H: %u\n",
-		wmgen.dirty_x,
-		wmgen.dirty_y,
-		wmgen.dirty_w,
-		wmgen.dirty_h);
-		
 	printf("Dirty: X: %i Y: %i W: %i H: %i\n",
 		wmgen.dirty_x,
 		wmgen.dirty_y,
 		wmgen.dirty_w,
 		wmgen.dirty_h);
 #endif
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 };
 
 
@@ -218,10 +174,6 @@ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) {
     int		bcount;
     int     curpixel;
 
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "createXBMfromXPM", "(char *, char **, int, int)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 	
 	sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth);
 
@@ -258,17 +210,10 @@ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) {
 		}
 	}
 
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
 void copyXPMArea(int sx, int sy, unsigned int w, unsigned int h, int dx, int dy) {
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "copyXPMArea", "(int, int, int, int, int, int)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 
 	XCopyArea(display,
 		  wmgen.pixmap,
@@ -282,17 +227,10 @@ void copyXPMArea(int sx, int sy, unsigned int w, unsigned int h, int dx, int dy)
 		  dy);
 
 	DirtyWindow(dx, dy, w, h);
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
 void copyXBMArea(int sx, int sy, unsigned int w, unsigned int h, int dx, int dy) {
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "copyXBMArea", "(int, int, unsigned int, unsigned int, int, int)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 
 	XCopyArea(display,
 		  wmgen.mask,
@@ -307,9 +245,6 @@ void copyXBMArea(int sx, int sy, unsigned int w, unsigned int h, int dx, int dy)
 
 	DirtyWindow(dx, dy, w, h);
 
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
@@ -320,7 +255,7 @@ void setMaskXY(int x, int y) {
 }
 
 
-void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, int pixmask_width, int pixmask_height) {
+int openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, int pixmask_width, int pixmask_height) {
 
 	unsigned int	borderwidth = 1;
 	XClassHint		classHint;
@@ -334,7 +269,7 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
 	char			*geometry = NULL;
 
 	int				dummy=0;
-	int				i, wx, wy;
+	int				i, wx, wy, fd;
 
 	for (i=1; argv[i]; i++) {
 		if (!strcmp(argv[i], "-display")) {
@@ -350,8 +285,9 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
 	if (!(display = XOpenDisplay(display_name))) {
 		fprintf(stderr, "%s: can't open display %s\n", 
 						wname, XDisplayName(display_name));
-		exit(1);
+		return -1;
 	}
+	fd = ConnectionNumber(display);
 	screen  = DefaultScreen(display);
 	Root    = RootWindow(display, screen);
 	d_depth = DefaultDepth(display, screen);
@@ -392,7 +328,7 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
 
 	if (XStringListToTextProperty(&wname, 1, &name) == 0) {
 		fprintf(stderr, "%s: can't allocate window name\n", wname);
-		exit(1);
+		return -1;
 	}
 
 	XSetWMName(display, win, &name);
@@ -429,8 +365,10 @@ void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bit
 	if (geometry) {
 		if (sscanf(geometry, "+%d+%d", &wx, &wy) != 2) {
 			fprintf(stderr, "Bad geometry string.\n");
-			exit(1);
+			return -1;
 		}
 		XMoveWindow(display, win, wx, wy);
 	}
+
+	return fd;
 }
diff --git a/src/wmgeneral.h b/src/wmgeneral.h
index 7470f0c..22ed3df 100644
--- a/src/wmgeneral.h
+++ b/src/wmgeneral.h
@@ -47,7 +47,7 @@ Display		*display;
 void AddMouseRegion(int index, int left, int top, int right, int bottom);
 int CheckMouseRegion(int x, int y);
 
-void openXwindow(int argc, char *argv[], char **, char *, int, int);
+int openXwindow(int argc, char *argv[], char **, char *, int, int);
 void RedrawWindow(void);
 void RedrawWindowXY(int x, int y);
 
diff --git a/src/wmsysmon.c b/src/wmsysmon.c
index 522d20f..b780ead 100644
--- a/src/wmsysmon.c
+++ b/src/wmsysmon.c
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <ctype.h>
 #include <math.h>
+#include <sys/poll.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/param.h>
@@ -37,9 +38,6 @@
 #include <X11/xpm.h>
 #include <X11/extensions/shape.h>
 
-#ifdef PROF
-#include <Profile/Profiler.h>
-#endif
 
 #include "wmgeneral.h"
 
@@ -49,7 +47,7 @@
 #include "wmsysmon-master-i386.xpm"
 #endif
 
-#define WMSYSMON_VERSION "0.7.6"
+#define WMSYSMON_VERSION "0.7.7"
 
 #define CHAR_WIDTH 5
 #define CHAR_HEIGHT 7
@@ -121,7 +119,7 @@ char	buf[1024];
 FILE	*statfp;
 FILE	*memfp;
 
-int	update_rate = 100000;
+int	update_rate = 50;
 
 char	*ProgName;
 
@@ -143,12 +141,6 @@ void DrawMeter(unsigned int, unsigned int, int, int);
 
 int main(int argc, char *argv[]) {
 	int	i;
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "main()", "int(int, char **)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-	TAU_PROFILE_INIT(argc, argv);
-	TAU_PROFILE_SET_NODE(0);
-#endif
 
 	/* set meter x,y pairs */
 	meter[3][0] = 108;
@@ -192,7 +184,7 @@ int main(int argc, char *argv[]) {
 				break;
 			case 'r':
 				if (argc > (i + 1)) {
-					update_rate = (atoi(argv[i + 1]) * 1000);
+					update_rate = (atoi(argv[i + 1]));
 					i++;
 				}
 				break;
@@ -210,9 +202,6 @@ int main(int argc, char *argv[]) {
 
 	wmsysmon_routine(argc, argv);
 
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 
 	return 0;
 }
@@ -221,21 +210,19 @@ int main(int argc, char *argv[]) {
 void wmsysmon_routine(int argc, char **argv)
 {
 	int		i;
-#ifdef PROF
-	int		x = 0;
-#endif
 	XEvent		Event;
-	int		but_stat = -1;
 	FILE		*fp;
+	int		xfd;
+	struct pollfd	pfd;
     
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "wmsysmon_routine()", "(int, char **)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 
 	createXBMfromXPM(wmsysmon_mask_bits, wmsysmon_master_xpm, wmsysmon_mask_width, wmsysmon_mask_height);
     
-	openXwindow(argc, argv, wmsysmon_master_xpm, wmsysmon_mask_bits, wmsysmon_mask_width, wmsysmon_mask_height);
+	xfd = openXwindow(argc, argv, wmsysmon_master_xpm, wmsysmon_mask_bits, wmsysmon_mask_width, wmsysmon_mask_height);
+	if(xfd < 0) exit(1);
+
+	pfd.fd = xfd;
+	pfd.events = (POLLIN);
 
     /* init ints */
 	bzero(&_last_ints, sizeof(_last_ints));
@@ -272,22 +259,17 @@ void wmsysmon_routine(int argc, char **argv)
 		else if(strstr(buf, "intr")) intr_l = i;
 	}
 
-#ifdef PROF
-	while (x < 1000) {
-#else
 	while(1) {
-#endif
         
 		curtime = time(0);
 
-#if 1
 		DrawUptime();
 		DrawStuff();
 		DrawMem();
 		RedrawWindow();
-#endif
         
 		/* X Events */
+		poll(&pfd, 1, update_rate);
 		while (XPending(display)) {
 			XNextEvent(display, &Event);
 			switch (Event.type) {
@@ -308,25 +290,15 @@ void wmsysmon_routine(int argc, char **argv)
 #endif
 			}
 		}
-#ifdef PROF
-		x++;
-#endif
 
-		usleep(update_rate);
+/*		usleep(update_rate); */
 	}
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
 void DrawMeter(unsigned int level, unsigned int peak, int dx, int dy)
 {
 	static unsigned int	a;
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "DrawMeter()", "(int, unsigned int, int, int)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 
 	/* meters are on a per interruptscale, dictated by the peak, maintain
 	 * this peak outside of here, you can use a fixed peak for all ints but
@@ -350,9 +322,6 @@ void DrawMeter(unsigned int level, unsigned int peak, int dx, int dy)
 		    VBAR_H,
 		    dx,
 		    dy);
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
@@ -360,10 +329,6 @@ void DrawMeter(unsigned int level, unsigned int peak, int dx, int dy)
 void DrawBar(int sx, int sy, int w, int h, float percent, int dx, int dy)
 {
 	static int	tx;
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "DrawBar()", "(int, int, int, int, float, int, int)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 
 	tx = (float)((float)w * ((float)percent / (float)100.0));
 
@@ -371,18 +336,11 @@ void DrawBar(int sx, int sy, int w, int h, float percent, int dx, int dy)
 
 	copyXPMArea(sx, sy + h + 1, w - tx, h, dx + tx, dy);
 
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
 void DrawLite(int state, int dx, int dy)
 {
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "DrawLite()", "(int, int, int)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 
 	switch(state) {
 		case B_RED:
@@ -397,9 +355,6 @@ void DrawLite(int state, int dx, int dy)
 			break;
 	}
 
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
@@ -410,10 +365,6 @@ void DrawUptime(void)
 	static long	uptime;
     	static int	i;
 
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "DrawUptime()", "", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
     
 	uptime = curtime - start_uptime + start_time;
 
@@ -460,9 +411,6 @@ void DrawUptime(void)
 	}
 
 	first = 0;
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
@@ -492,10 +440,6 @@ void DrawStuff( void )
 	static long	intdiff;
 	static long	stage;
 	static long	*tints;
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "DrawStuff()", "", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 
 	stage = io = iodiff = iopercent = pageins = pageouts = swapins = swapouts = 0;
 
@@ -650,46 +594,52 @@ void DrawStuff( void )
 #endif
 	} else if(int_mode == INT_METERS) {
 		for (i = 0; i < 8; i++) {
-			intdiff = ints[i] - last_ints[i];
-			int_peaks[i] = (int_peaks[i] + intdiff) >> 1;
+			if(last_ints[i]) {
+				intdiff = ints[i] - last_ints[i];
+				int_peaks[i] = (int_peaks[i] + intdiff) >> 1;
 #ifdef HI_INTS
-			DrawMeter(intdiff,
-				  int_peaks[i],
-				  VBAR_H + (i * VBAR_W) + i,
-				  43);
+				DrawMeter(intdiff,
+					  int_peaks[i],
+					  VBAR_H + (i * VBAR_W) + i,
+					  43);
 #else
-			DrawMeter(intdiff,
-				  int_peaks[i],
-				  VBAR_H + (i * VBAR_W) + i,
-				  51);
+				DrawMeter(intdiff,
+					  int_peaks[i],
+					  VBAR_H + (i * VBAR_W) + i,
+					  51);
 #endif
+			}
 		}
 
 		for (i = 8; i < 16; i++) {
-			intdiff = ints[i] - last_ints[i];
-			int_peaks[i] = (int_peaks[i] + intdiff) >> 1;
+			if(last_ints[i]) {
+				intdiff = ints[i] - last_ints[i];
+				int_peaks[i] = (int_peaks[i] + intdiff) >> 1;
 #ifdef HI_INTS
-			DrawMeter(intdiff,
-				  int_peaks[i],
-				  VBAR_H + ((i - 8) * VBAR_W) + (i - 8),
-				  48);
+				DrawMeter(intdiff,
+					  int_peaks[i],
+					  VBAR_H + ((i - 8) * VBAR_W) + (i - 8),
+					  48);
 #else
-			DrawMeter(intdiff,
-				  int_peaks[i],
-				  VBAR_H + ((i - 8) * VBAR_W) + (i - 8),
-				  56);
+				DrawMeter(intdiff,
+					  int_peaks[i],
+					  VBAR_H + ((i - 8) * VBAR_W) + (i - 8),
+					  56);
 #endif
+			}
 		}
 
 #ifdef HI_INTS
 		for (i = 16; i < 24; i++) {
-			intdiff = ints[i] - last_ints[i];
-			int_peaks[i] = (int_peaks[i] + intdiff) >> 1;
-
-			DrawMeter(intdiff,
-				  int_peaks[i],
-				  VBAR_H + ((i - 16) * VBAR_W) + (i - 16),
-				  53);
+			if(last_ints[i]) {
+				intdiff = ints[i] - last_ints[i];
+				int_peaks[i] = (int_peaks[i] + intdiff) >> 1;
+
+				DrawMeter(intdiff,
+					  int_peaks[i],
+					  VBAR_H + ((i - 16) * VBAR_W) + (i - 16),
+					  53);
+			}
 		}
 #endif
 	}
@@ -774,9 +724,6 @@ void DrawStuff( void )
 
 	first = 0;
 
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
@@ -795,10 +742,6 @@ void DrawMem(void)
 	static int 	swappercent = 0;
 	static int	i, ents;
 
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "DrawMem()", "", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 
 	counter--;
 
@@ -855,9 +798,6 @@ void DrawMem(void)
 
 	first = 0;
 
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
@@ -865,10 +805,6 @@ void DrawMem(void)
 void BlitString(char *name, int x, int y)
 {
 	static int	i, c, k;
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "BlitString()", "(char *, int, int)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 
 	k = x;
 	for (i=0; name[i]; i++) {
@@ -885,9 +821,6 @@ void BlitString(char *name, int x, int y)
 		}
 	}
 
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
 
 
@@ -895,10 +828,6 @@ void BlitNum(int num, int x, int y)
 {
 	static int	newx;
 
-#ifdef PROF
-	TAU_PROFILE_TIMER(tautimer, "BlitNum()", "(int, int, int)", TAU_DEFAULT);
-	TAU_PROFILE_START(tautimer);
-#endif
 
 	newx = x;
 
@@ -906,9 +835,6 @@ void BlitNum(int num, int x, int y)
 
 	BlitString(buf, newx, y);
 
-#ifdef PROF
-	TAU_PROFILE_STOP(tautimer);
-#endif
 }
     
 
@@ -916,9 +842,9 @@ void usage(void)
 {
 	fprintf(stderr, "\nwmsysmon - http://www.gnugeneration.com\n");
 	fprintf(stderr, "\n-------------------\n"
-			"|[---------------]|  <--- Memory Use %\n"
-			"|[---------------]|  <--- Swap Use %\n"
-			"|[---------------]|  <--- I/O %\n"
+			"|[---------------]|  <--- Memory Use %%\n"
+			"|[---------------]|  <--- Swap Use %%\n"
+			"|[---------------]|  <--- I/O %%\n"
 			"|                 |\n"
 			"|   000:00:00     |  <--- Uptime days:hours:minutes\n"
 			"|                 |\n"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmsysmon.git



More information about the Pkg-wmaker-commits mailing list