event/event_test.c

Go to the documentation of this file.
00001 
00002 /*
00003  * $Id: event_test.c,v 1.2 2005/06/22 22:07:15 murrayma Exp $
00004  *
00005  * Author: Markus Stenberg <fingon@iki.fi>
00006  *
00007  *  Copyright (c) 1996 Markus Stenberg
00008  *       All rights reserved
00009  *
00010  * Created: Tue Aug 27 20:08:33 1996 fingon
00011  * Last modified: Sun Nov 24 01:32:49 1996 fingon
00012  *
00013  */
00014 
00015 #include <stdio.h>
00016 
00017 #include "muxevent.h"
00018 
00019 #define number(a,b) (a+rand()%(b-a+1))
00020 
00021 
00022 #if 0
00023 
00024 /* In seconds */
00025 #define TEST_TIME            3600
00026 #else
00027 
00028 /* In iterations */
00029 #define TEST_ITERATIONS      1000000
00030 #endif
00031 
00032 #ifdef TEST_TIME
00033 #define TEST_MSECS           10000
00034 #define TEST_ITERATIONS      TEST_TIME * (1000000 / TEST_MSECS)
00035 #endif
00036 
00037 #define LARGE_NUMBER         500000
00038 #define SIMULTANEOUS_EVENTS  600
00039 
00040 #define SHORT_TIME           1
00041 #define LONG_TIME            2
00042 
00043 
00044 void hellow(MUXEVENT * e)
00045 {
00046     int n;
00047     int d = (int) e->data;
00048 
00049 #if 1
00050     int d1, d2;
00051 
00052     d1 = d / LARGE_NUMBER;
00053     d2 = d % LARGE_NUMBER;
00054     printf("Hello, world!(%d) - %d\n", d1, d2);
00055     n = number(0, 10);
00056 #endif
00057     muxevent_add_simple_arg(!n ? number(1, LONG_TIME) : number(1, SHORT_TIME),
00058         hellow, (int *) (d + 1));
00059 }
00060 
00061 void main()
00062 {
00063     int i;
00064 
00065     muxevent_initialize();
00066     for (i = 0; i < SIMULTANEOUS_EVENTS; i++)
00067         muxevent_add_simple_arg(i + 1, hellow, (int *) (LARGE_NUMBER * i));
00068     for (i = 0; i < TEST_ITERATIONS; i++) {
00069 #ifdef TEST_TIME
00070         usleep(TEST_MSECS);
00071 #endif
00072         muxevent_run();
00073     }
00074 }

Generated on Mon May 28 04:25:18 2007 for BattletechMUX by  doxygen 1.4.7