FreeBSD/tools/tools/netrate/juggle/juggle.c
/*
 * Juggle messages between two file descriptors in a single thread/process,
 * so simply a measure of IPC performance.
 */
Juggle messages between two file descriptors in a single thread/process,
so simply a measure of IPC performance.
Juggle messages between two file descriptors in a single thread / process so simply a measure of IPC performance .
static struct timespec
juggle(int fd1, int fd2, int pipeline)
{
	struct timespec tstart, tfinish;
	int i, j;
	if (clock_gettime(CLOCK_REALTIME, &tstart) < 0)
		err(-1, "juggle: clock_gettime");
	for (i = 0; i < NUMCYCLES; i++) {
		for (j = 0; j < pipeline; j++) {
			if (message_send(fd1) < 0)
				err(-1, "message_send fd1");
		}
		for (j = 0; j < pipeline; j++) {
			if (message_recv(fd2) < 0)
				err(-1, "message_recv fd2");
			if (message_send(fd2) < 0)
				err(-1, "message_send fd2");
		}
		for (j = 0; j < pipeline; j++) {
			if (message_recv(fd1) < 0)
				err(-1, "message_recv fd1");
		}
	}
	if (clock_gettime(CLOCK_REALTIME, &tfinish) < 0)
		err(-1, "juggle: clock_gettime");
	timespecsub(&tfinish, &tstart);
	return (tfinish);
}
static struct timespec juggle ( int fd1 , int fd2 , int pipeline ) { struct timespec tstart , tfinish ; int i , j ; if ( clock_gettime ( CLOCK_REALTIME , & tstart ) < 0 ) err ( -1 , " " ) ; for ( i = 0 ; i < NUMCYCLES ; i ++ ) { for ( j = 0 ; j < pipeline ; j ++ ) { if ( message_send ( fd1 ) < 0 ) err ( -1 , " " ) ; } for ( j = 0 ; j < pipeline ; j ++ ) { if ( message_recv ( fd2 ) < 0 ) err ( -1 , " " ) ; if ( message_send ( fd2 ) < 0 ) err ( -1 , " " ) ; } for ( j = 0 ; j < pipeline ; j ++ ) { if ( message_recv ( fd1 ) < 0 ) err ( -1 , " " ) ; } } if ( clock_gettime ( CLOCK_REALTIME , & tfinish ) < 0 ) err ( -1 , " " ) ; timespecsub ( & tfinish , & tstart ) ; return ( tfinish ) ; }
Juggle messages between two file descriptors in a single thread/process,
 so simply a measure of IPC performance.
Juggle messages between two file descriptors in a single thread / process so simply a measure of IPC performance .