예제 #1
0
파일: lat_proc.c 프로젝트: Maxlufs/CSE221
int
main(int ac, char **av)
{
	int parallel = 1;
	int warmup = 0;
	int repetitions = -1;
	int c;
	char* usage = "[-P <parallelism>] [-W <warmup>] [-N <repetitions>] procedure|fork|exec|shell\n";

	while (( c = getopt(ac, av, "P:W:N:")) != EOF) {
		switch(c) {
		case 'P':
			parallel = atoi(optarg);
			if (parallel <= 0) lmbench_usage(ac, av, usage);
			break;
		case 'W':
			warmup = atoi(optarg);
			break;
		case 'N':
			repetitions = atoi(optarg);
			break;
		default:
			lmbench_usage(ac, av, usage);
			break;
		}
	}

	if (optind + 1 != ac) { /* should have one argument left */
		lmbench_usage(ac, av, usage);
	}

	if (!strcmp("procedure", av[optind])) {
		benchmp(NULL, do_procedure, cleanup, 0, parallel, 
			warmup, repetitions, &ac);
		micro("Procedure call", get_n());
	} else if (!strcmp("fork", av[optind])) {
		benchmp(NULL, do_fork, cleanup, 0, parallel, 
			warmup, repetitions, NULL);
		micro(STATIC_PREFIX "Process fork+exit", get_n());
	} else if (!strcmp("exec", av[optind])) {
		benchmp(NULL, do_forkexec, cleanup, 0, parallel,
			warmup, repetitions, NULL);
		micro(STATIC_PREFIX "Process fork+execve", get_n());
	} else if (!strcmp("shell", av[optind])) {
		benchmp(NULL, do_shell, cleanup, 0, parallel,
			warmup, repetitions, NULL);
		micro(STATIC_PREFIX "Process fork+/bin/sh -c", get_n());
	} else {
		lmbench_usage(ac, av, usage);
	}
	return(0);
}
예제 #2
0
파일: menu.c 프로젝트: RomanovSergey/feeler
/*
 * Рабочий - отображает измеренное значение толщины
 * по мере поступления новых данных
 */
int dworkScreen(uint8_t ev) {
	static uint8_t measflag = 0;
	switch (ev) {
	case DIS_PUSH_OK:
		pdisp = dmainM;
		mgPutEv( MG_OFF );
		return 0;
	case DIS_PUSH_L:
		mgPutEv( MG_ON );
		return 0;
	case DIS_PULL_L:
		mgPutEv( MG_OFF );
		return 0;
	case DIS_MEASURE:
		measflag ^= 1;
		break;
	case DIS_PUSH_R:
	case DIS_LONGPUSH_OK:
	case DIS_LONGPUSH_L:
	case DIS_LONGPUSH_R:
		return 0;
	}
	uint16_t freq = getFreq();
	uint16_t microValue;
	int res;

	disClear();
	disSetF( 0, 0, f_5x8 );
	if ( magGetStat() ) {
		disPr( "Измер." );
		if ( measflag ) {
			disPr( "*" );
		}
	} else {
		disPr( "Фикс." );
	}
	disSetF( 0, 68, f_3x5 ); disPr( adcGetBattary() );

	res = micro( freq, &microValue );
	if ( res == 0 ) { // Ferrum
		disSetF( 2, 18, f_10x16 ); disPr( u16to4str( microValue ) );
		disSetF( 2,  0, f_5x8 );   disPr( "Fe" );
		disSetF( 3, 72, f_5x8 );   disPr( "um" );
	} else if ( res == 1 ) { // Air
		disSetF( 2, 18, f_10x16 ); disPr( " Air" );
	} else if ( res == 2 ) { // Aluminum
		disSetF( 2, 18, f_10x16 ); disPr( u16to4str( microValue ) );
		disSetF( 2,  0, f_5x8 );   disPr( "Al" );
		disSetF( 3, 72, f_5x8 );   disPr( "um" );
	} else if ( res == 3 ) { // No Fe calib data
		disSetF( 2, 0, f_5x8 ); disPr( "No Fe calibr.");
	} else if ( res == 4 ) { // No Al calib data
		disSetF( 2, 0, f_5x8 ); disPr( "No Al calibr." );
	} else if ( res == 5 ) { // Freq is zero
		disSetF( 2, 18, f_10x16 ); disPr( "????" );
	}
	disSetF( 5, 64, f_3x5 ); disPr( u32to5str( freq ) );

	return 1;//надо перерисовать
}
예제 #3
0
파일: lat_tcp.c 프로젝트: ash9211/graphene
void
client_main(int ac, char **av)
{
	int     sock;
	char	*server;
	char	buf[100];

	if (ac != 2) {
		fprintf(stderr, "usage: %s host\n", av[0]);
		exit(1);
	}
	server = av[1][0] == '-' ? &av[1][1] : av[1];
	sock = tcp_connect(server, TCP_XACT, SOCKOPT_NONE);

	/*
	 * Stop server code.
	 */
	if (av[1][0] == '-') {
		close(sock);
		exit(0);
	}

	BENCH(doclient(sock), MEDIUM);
	sprintf(buf, "TCP latency using %s", av[1]);
	micro(buf, get_n());
	exit(0);
	/* NOTREACHED */
}
예제 #4
0
int main(int ac, char **av)
{
	int parallel = 1;
	int warmup = 0;
	int repetitions = TRIES;
	char	*usage = "-s\n OR [-P <parallelism>] [-W <warmup>] [-N <repetitions>]\n OR -S\n";
	int	c;

	/* Start the server "-s" or Shut down the server "-S" */
	if (ac == 2) {
		if (!strcmp(av[1], "-s")) {
#ifdef CONFIG_NOMMU
			if (fork() == 0) {
				server_main();
				_exit(0);
			}
#else
			if (fork() == 0) {
				server_main();
			}
#endif
			exit(0);
		}
		if (!strcmp(av[1], "-S")) {
			int sock = unix_connect(CONNAME);
			write(sock, "0", 1);
			close(sock);
			exit(0);
		}
	}

	/*
	 * Rest is client
	 */
	while (( c = getopt(ac, av, "P:W:N:")) != EOF) {
		switch(c) {
		case 'P':
			parallel = atoi(optarg);
			if (parallel <= 0) lmbench_usage(ac, av, usage);
			break;
		case 'W':
			warmup = atoi(optarg);
			break;
		case 'N':
			repetitions = atoi(optarg);
			break;
		default:
			lmbench_usage(ac, av, usage);
			break;
		}
	}

	if (optind != ac) {
		lmbench_usage(ac, av, usage);
	}

	benchmp(NULL, benchmark, NULL, 0, parallel, warmup, repetitions, NULL);
	micro("UNIX connection cost", get_n());
}
예제 #5
0
int
main(int ac, char **av)
{
	int parallel = 1;
	int warmup = 0;
	int repetitions = TRIES;
	int c;
	char* usage = "[-P <parallelism>] [-W <warmup>] [-N <repetitions>] install|catch|prot [file]\n";

	while (( c = getopt(ac, av, "P:W:N:")) != EOF) {
		switch(c) {
		case 'P':
			parallel = atoi(optarg);
			if (parallel <= 0) lmbench_usage(ac, av, usage);
			break;
		case 'W':
			warmup = atoi(optarg);
			break;
		case 'N':
			repetitions = atoi(optarg);
			break;
		default:
			lmbench_usage(ac, av, usage);
			break;
		}
	}
	if (optind != ac - 1 && optind != ac - 2) {
		lmbench_usage(ac, av, usage);
	}

	if (!strcmp("install", av[optind])) {
		benchmp(NULL, do_install, NULL, 0, parallel, 
			warmup, repetitions, NULL);
		micro("Signal handler installation", get_n());
	} else if (!strcmp("catch", av[optind])) {
		bench_catch(parallel, warmup, repetitions);
		micro("Signal handler overhead", get_n());
	} else if (!strcmp("prot", av[optind]) && optind == ac - 2) {
		bench_prot(av[optind+1], parallel, warmup, repetitions);
		micro("Protection fault", get_n());
	} else {
		lmbench_usage(ac, av, usage);
	}
	return(0);
}
int
main(int ac, char **av)
{
	state_t state;
	int rc, c, repetitions = -1, warmup = 0;
	char	buf[256];
	char	*usage = "-s\n OR [-S] [-W <warmup>] [-N <repetitions>] server\n";

	while (( c = getopt(ac, av, "sSP:W:N:")) != EOF) {
		switch(c) {
		case 's': /* Server */
			if (fork() == 0) {
				server_main();
			}
			exit(0);
		case 'S': /* shutdown serverhost */
		{
			int sock = tcp_connect(av[optind],
					       TCP_CONNECT,
					       SOCKOPT_NONE);
			rc = write(sock, "0", 1);
			if (rc < 0)
				DIE_PERROR("write failed");
			close(sock);
			exit(0);
		}
		case 'W':
			warmup = atoi(optarg);
			break;
		case 'N':
			repetitions = atoi(optarg);
			break;
		default:
			lmbench_usage(ac, av, usage);
			break;
		}
	}

	if (optind + 1 != ac) {
		lmbench_usage(ac, av, usage);
	}

	handle_scheduler(benchmp_childid(), 0, 0);

	state.server = av[optind];
	benchmp(NULL, doclient, NULL, 0, 1, warmup, repetitions, &state);

	sprintf(buf, "TCP/IP connection cost to %s", state.server);
	micro(buf, get_n());
	exit(0);
}
예제 #7
0
파일: LAT_UNIX.C 프로젝트: Toendex/relay
int
main(int ac, char **av)
{
	int	sv[2];

	if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1) {
		perror("socketpair");
	}
	if (fork() == 0) {
		BENCH(client(sv[1]), MEDIUM);
		micro("AF_UNIX sock stream latency", get_n());
		kill(getppid(), SIGTERM);
	} else {
		server(sv[0]);
	}
	return(0);
}
예제 #8
0
int 
main(int ac, char **av)
{
	int c;
	int i;
	int parallel = 1;
	int warmup = 0;
	int repetitions = TRIES;
	char buf[1024];
	state_t state;
	char* usage = "[-P <parallelism>] [-W <warmup>] [-N <repetitions>] cmdline...\n";

	while (( c = getopt(ac, av, "P:W:N:")) != EOF) {
		switch(c) {
		case 'P':
			parallel = atoi(optarg);
			if (parallel <= 0) lmbench_usage(ac, av, usage);
			break;
		case 'W':
			warmup = atoi(optarg);
			break;
		case 'N':
			repetitions = atoi(optarg);
			break;
		default:
			lmbench_usage(ac, av, usage);
			break;
		}
	}
	if (optind >= ac) {
		lmbench_usage(ac, av, usage);
	}
	state.argv = (char**)malloc((ac - optind + 1) * sizeof(char*));
	state.pid = 0;
	for (i = 0; i < ac - optind; ++i) {
		state.argv[i] = av[optind + i];
	}
	state.argv[i] = NULL;

	benchmp(NULL, bench, NULL, 0, parallel, warmup, repetitions, &state);
	micro("lat_cmd", get_n());
	return (0);
}
예제 #9
0
int
main(int ac, char **av)
{
	int parallel = 1;
	int warmup = 0;
	int repetitions = -1;
	struct _state state;
	int c;
	char* usage = "[-m <message size>] [-P <parallelism>] [-W <warmup>] [-N <repetitions>]\n";

	state.msize = 1;
	state.pid = 0;

	while (( c = getopt(ac, av, "m:P:W:N:")) != EOF) {
		switch(c) {
		case 'm':
			state.msize = atoi(optarg);
			break;
		case 'P':
			parallel = atoi(optarg);
			if (parallel <= 0) lmbench_usage(ac, av, usage);
			break;
		case 'W':
			warmup = atoi(optarg);
			break;
		case 'N':
			repetitions = atoi(optarg);
			break;
		default:
			lmbench_usage(ac, av, usage);
			break;
		}
	}
	if (optind < ac) {
		lmbench_usage(ac, av, usage);
	}

	benchmp(initialize, benchmark, cleanup, 0, parallel, 
		warmup, repetitions, &state);

	micro("AF_UNIX sock stream latency", get_n());
	return(0);
}
예제 #10
0
int main(){

  std::cout << std::fixed << std::endl;
  
  std::cout << "Time since 1.1.1970:\n" << std::endl;

  auto timeNow= std::chrono::system_clock::now();
  auto duration= timeNow.time_since_epoch();
  std::cout << duration.count() << " nanoseconds " << std::endl;

  typedef std::chrono::duration<long double,std::ratio<1,1000000>> MyMicroSecondTick;
  MyMicroSecondTick micro(duration);
  std::cout << micro.count() << " microseconds" << std::endl;
  
  typedef std::chrono::duration<long double,std::ratio<1,1000>> MyMilliSecondTick;
  MyMilliSecondTick milli(duration);
  std::cout << milli.count() << " milliseconds" << std::endl;
  
  typedef std::chrono::duration<long double> MySecondTick;
  MySecondTick sec(duration);
  std::cout << sec.count() << " seconds " << std::endl;
  
  typedef std::chrono::duration<double, std::ratio<60>> MyMinuteTick;
  MyMinuteTick myMinute(duration);
  std::cout << myMinute.count() << " minutes" << std::endl;

  typedef std::chrono::duration<double, std::ratio<60*60>> MyHourTick;
  MyHourTick myHour(duration);
  std::cout << myHour.count() << " hours" << std::endl;
  
  typedef std::chrono::duration<double, std::ratio<60*60*24*365>> MyYearTick;
  MyYearTick myYear(duration);
  std::cout << myYear.count() << " years" << std::endl;

  typedef std::chrono::duration<double, std::ratio<60*45>> MyLessonTick;
  MyLessonTick myLesson(duration);
  std::cout << myLesson.count() << " lessons" << std::endl;

  std::cout << std::endl;

}
예제 #11
0
int 
main(int ac, char **av)
{
	state_t state;
	int parallel = 1;
	int warmup = 0;
	int repetitions = TRIES;
	int c;
	char* usage = "[-P <parallelism>] [-W <warmup>] [-N <repetitions>]\n";

	while (( c = getopt(ac, av, "P:W:N:")) != EOF) {
		switch(c) {
		case 'P':
			parallel = atoi(optarg);
			if (parallel <= 0) lmbench_usage(ac, av, usage);
			break;
		case 'W':
			warmup = atoi(optarg);
			break;
		case 'N':
			repetitions = atoi(optarg);
			break;
		default:
			lmbench_usage(ac, av, usage);
			break;
		}
	}
	if (optind < ac) {
		lmbench_usage(ac, av, usage);
	}

	state.pid = 0;

	benchmp(initialize, doit, cleanup, SHORT, parallel, 
		warmup, repetitions, &state);
	micro("Pipe latency", get_n());
	return (0);
}
예제 #12
0
파일: lat_rpc.c 프로젝트: Toendex/relay
void
benchmark(char *server, char* protocol)
{
	CLIENT *cl;
	char	buf[256];
	struct	timeval tv;

	cl = clnt_create(server, XACT_PROG, XACT_VERS, protocol);
	if (!cl) {
		clnt_pcreateerror(server);
		exit(1);
	}
	if (strcasecmp(protocol, proto[1]) == 0) {
		tv.tv_sec = 0;
		tv.tv_usec = 2500;
		if (!clnt_control(cl, CLSET_RETRY_TIMEOUT, (char *)&tv)) {
			clnt_perror(cl, "setting timeout");
			exit(1);
		}
	}
	BENCH(doit(cl, server, protocol), MEDIUM);
	sprintf(buf, "RPC/%s latency using %s", protocol, server);
	micro(buf, get_n());
}
예제 #13
0
int
main(int ac, char **av)
{
	int 	c;
	int	parallel = 1;
	int	warmup = 0;
	int	repetitions = -1;
	state_t	state;
	CLIENT	*cl;
	char	buf[1024];
	char	*protocol = NULL;
	char	*usage = "-s\n OR [-p <tcp|udp>] [-P parallel] [-W <warmup>] [-N <repetitions>] serverhost\n OR -S serverhost\n";

	state.msize = 1;
	state.server = NULL;

	while (( c = getopt(ac, av, "sS:m:p:P:W:N:")) != EOF) {
		switch(c) {
		case 's': /* Server */
			if (fork() == 0) {
				server_main();
			}
			exit(0);
		case 'S': /* shutdown serverhost */
		{
			cl = clnt_create(optarg, XACT_PROG, XACT_VERS, "udp");
			if (!cl) {
				clnt_pcreateerror(state.server);
				exit(1);
			}
			clnt_call(cl, RPC_EXIT, (xdrproc_t)xdr_void, 0, 
				  (xdrproc_t)xdr_void, 0, TIMEOUT);
			exit(0);
		}
		case 'm':
			state.msize = atoi(optarg);
			break;
		case 'p':
			protocol = optarg;
			break;
		case 'P':
			parallel = atoi(optarg);
			if (parallel <= 0)
				lmbench_usage(ac, av, usage);
			break;
		case 'W':
			warmup = atoi(optarg);
			break;
		case 'N':
			repetitions = atoi(optarg);
			break;
		default:
			lmbench_usage(ac, av, usage);
			break;
		}
	}

	if (optind != ac - 1) {
		lmbench_usage(ac, av, usage);
	}

	state.server = av[optind++];

	if (protocol == NULL || !strcasecmp(protocol, proto[0])) {
		state.protocol = proto[0];
		benchmp(initialize, benchmark, NULL, MEDIUM, parallel, 
			warmup, repetitions, &state);
		sprintf(buf, "RPC/%s latency using %s", proto[0], state.server);
		micro(buf, get_n());
	}

	if (protocol == NULL || !strcasecmp(protocol, proto[1])) {
		state.protocol = proto[1];
		benchmp(initialize, benchmark, NULL, MEDIUM, parallel, 
			warmup, repetitions, &state);
		sprintf(buf, "RPC/%s latency using %s", proto[1], state.server);
		micro(buf, get_n());
	}
		
	exit(0);
}
예제 #14
0
int
main(int ac, char **av)
{
	state_t state;
	int	parallel = 1;
	int	warmup = 0;
	int	repetitions = TRIES;
	int 	c;
	char	buf[256];
	char	*usage = "-s\n OR [-m <message size>] [-P <parallelism>] [-W <warmup>] [-N <repetitions>] server\n OR -S server\n";

	state.msize = 1;

	while (( c = getopt(ac, av, "sS:m:P:W:N:")) != EOF) {
		switch(c) {
		case 's': /* Server */
#ifdef CONFIG_NOMMU
			server_main();
#else
			if (fork() == 0) {
				server_main();
			}
#endif
			exit(0);
		case 'S': /* shutdown serverhost */
			state.sock = tcp_connect(optarg,
						 TCP_XACT,
						 SOCKOPT_NONE);
			close(state.sock);
			exit(0);
		case 'm':
			state.msize = atoi(optarg);
			break;
		case 'P':
			parallel = atoi(optarg);
			if (parallel <= 0)
				lmbench_usage(ac, av, usage);
			break;
		case 'W':
			warmup = atoi(optarg);
			break;
		case 'N':
			repetitions = atoi(optarg);
			break;
		default:
			lmbench_usage(ac, av, usage);
			break;
		}
	}

	if (optind != ac - 1) {
		lmbench_usage(ac, av, usage);
	}

	state.server = av[optind];
	benchmp(init, doclient, cleanup, MEDIUM, parallel, 
		warmup, repetitions, &state);

	sprintf(buf, "TCP latency using %s", state.server);
	micro(buf, get_n());

	exit(0);
}
예제 #15
0
파일: lat_select.c 프로젝트: Maxlufs/CSE221
int
main(int ac, char **av)
{
	state_t state;
	int parallel = 1;
	int warmup = 0;
	int repetitions = -1;
	int c;
	char* usage = "[-n <#descriptors>] [-P <parallelism>] [-W <warmup>] [-N <repetitions>] file|tcp\n";
	char	buf[256];

	morefds();  /* bump fd_cur to fd_max */
	state.num = 200;
	while (( c = getopt(ac, av, "P:W:N:n:")) != EOF) {
		switch(c) {
		case 'P':
			parallel = atoi(optarg);
			if (parallel <= 0) lmbench_usage(ac, av, usage);
			break;
		case 'W':
			warmup = atoi(optarg);
			break;
		case 'N':
			repetitions = atoi(optarg);
			break;
		case 'n':
			state.num = bytes(optarg);
			break;
		default:
			lmbench_usage(ac, av, usage);
			break;
		}
	}

	if (optind + 1 != ac) {
		lmbench_usage(ac, av, usage);
	}

	if (streq("tcp", av[optind])) {
		state.fid_f = open_socket;
		server(&state);
		benchmp(initialize, doit, cleanup, 0, parallel, 
			warmup, repetitions, &state);
		sprintf(buf, "Select on %d tcp fd's", state.num);
		kill(state.pid, SIGKILL);
		waitpid(state.pid, NULL, 0);
		micro(buf, get_n());
	} else if (streq("file", av[optind])) {
		state.fid_f = open_file;
		server(&state);
		benchmp(initialize, doit, cleanup, 0, parallel, 
			warmup, repetitions, &state);
		unlink(state.fname);
		sprintf(buf, "Select on %d fd's", state.num);
		micro(buf, get_n());
	} else {
		lmbench_usage(ac, av, usage);
	}

	exit(0);
}
예제 #16
0
int
main(int ac, char **av)
{
	state_t state;
	int	c;
	int	parallel = 1;
	int	warmup = 0;
	int	repetitions = TRIES;
	int	msize = 4;
 	char	buf[256];
	char	*usage = "-s\n OR [-S] [-m <message size>] [-P <parallelism>] [-W <warmup>] [-N <repetitions>] server\n NOTE: message size must be >= 4\n";

	if (sizeof(int) != 4) {
		fprintf(stderr, "lat_udp: Wrong sequence size\n");
		return(1);
	}

	while (( c = getopt(ac, av, "sS:m:P:W:N:")) != EOF) {
		switch(c) {
		case 's': /* Server */
			if (fork() == 0) {
				server_main();
			}
			exit(0);
		case 'S': /* shutdown serverhost */
		{
			int seq, n;
			int sock = udp_connect(optarg,
					       UDP_XACT,
					       SOCKOPT_NONE);
			for (n = -1; n > -5; --n) {
				seq = htonl(n);
				(void) send(sock, &seq, sizeof(int), 0);
			}
			close(sock);
			exit (0);
		}
		case 'm':
			msize = atoi(optarg);
			if (msize < sizeof(int)) {
				lmbench_usage(ac, av, usage);
				msize = 4;
			}
			if (msize > MAX_MSIZE) {
				lmbench_usage(ac, av, usage);
				msize = MAX_MSIZE;
			}
			break;
		case 'P':
			parallel = atoi(optarg);
			if (parallel <= 0)
				lmbench_usage(ac, av, usage);
			break;
		case 'W':
			warmup = atoi(optarg);
			break;
		case 'N':
			repetitions = atoi(optarg);
			break;
		default:
			lmbench_usage(ac, av, usage);
			break;
		}
	}

	if (optind + 1 != ac) {
		lmbench_usage(ac, av, usage);
	}

	state.server = av[optind];
	state.msize = msize;
	benchmp(init, doit, cleanup, SHORT, parallel, 
		warmup, repetitions, &state);
	sprintf(buf, "UDP latency using %s", state.server);
	micro(buf, get_n());
	exit(0);
}
예제 #17
0
int main( int argc, char *argv[] )
{
   if( argc < 2 ) {
      printf("\nUsage:\n\t%s Field.Tile.Seq\n", argv[0] );;
      exit(1);
   }

   char *starid = argv[1];
   int m, n, p, l, st, ct, narg, dp;
   int pt, pd, dlc;
   int npb;
   int done = 0;
   int nfits = 0;
   int tamper = 0;
   int rflag = 0;
   int field;
   double t, dt;
   char c, lcdir[256], cbuf[256], outfi[256];
   FILE *outfp;

   clifpar.load( );
   
   LcSet lcs, hlcs;
   PeakFinder pf( clifpar );

   SodophotCuts sodcuts( clifpar, lcdir );
   DaophotCuts daocuts( clifpar, lcdir );
   SodophotSet ss;

   lcs.recycle( );
   /*--- Find star in local sodset cache if possible ---*/
   //   if( sscanf( argv[1], "%d.%d.%d", &field, &tile, &seq) == 3 &&
   //       getenv( "SSPATH" ) ) {
   //      sprintf( cbuf, "%s/F_%d/sodset_%d.%d",
   //	       getenv("SSPATH"), field, field, tile );
   //      if ( ss.open( cbuf ) ) {
   //	 fprintf( stderr, "%s cannot open %s\n", argv[0], cbuf );
   //      }
   //      sodcuts.clean( lcs, ss, ss.find( seq ) );
   //   } else {
   //      printf("environment variable SSPATH not set\n" );
   //   }

   /*--- Find star in local clc cache if possible ---*/
   if( getenv( "LCDIR" ) ) {
      sprintf( lcdir, "%s", getenv("LCDIR") );

      lcdir_sodlc_file( lcdir, starid, 'p', cbuf );
      if( m = ss.open( cbuf ) )
	 printf("Cannot open %s  %d\n", cbuf, m );
      else 
	  sodcuts.clean( lcs, ss, 0 );
      
      lcdir_sodlc_file( lcdir, starid, 'p', cbuf );
      if( !ss.open( cbuf ) ) sodcuts.clean( lcs, ss, 0 );

      lcdir_sodlc_file( lcdir, starid, 'o', cbuf );
      if( !ss.open( cbuf ) ) sodcuts.clean( lcs, ss, 0 );

      lcdir_sodlc_file( lcdir, starid, 'n', cbuf );
      if( !ss.open( cbuf ) ) sodcuts.clean( lcs, ss, 0 );

      lcdir_sodlc_file( lcdir, starid, 'g', cbuf );
      if( !ss.open( cbuf ) ) sodcuts.clean( lcs, ss, 0 );

      lcdir_sodlc_file( lcdir, starid, 'e', cbuf );
      if( !ss.open( cbuf ) ) sodcuts.clean( lcs, ss, 0 );

   } else	{
      printf("environment variable LCDIR not set\n" );
   }
   
   /*--- get local cached daophot lc  ---*/
   DaophotSet daoset;
   daoset.read( lcdir, starid );
   daocuts.clean( lcs, daoset );

   /*--- get local cached ascii data ---*/
   if ( read_ascii_set( lcs, lcdir, starid ) ) {
      fprintf( stderr, "problem with ascii data\n" );
      //return 1;
   }

   p = 0;
   while( p != lcs.count( ) ) {
      if( lcs[p]->nobs == 0 ) {
	 lcs[p]->erase( );
	 lcs.unhook( lcs[p] );
      } else {
	 ++p;
      }
   }

   if( lcs.count( ) == 0 ) {
      printf("Exiting: no data\n" );
      exit( SiteErr::errMissing );
   }

   for( p = 0; p < lcs.count( ); ++p ) {
      printf("Loaded %d points from %s in %s\n",
	     lcs[p]->nobs,lcs[p]->title,Passband::info(lcs[p]->filter)->name);
   }


   LcMerge( lcs );				// combine like passbands
   for( p = 0; p < lcs.count( ); ++p )		// and convert to linear units
      (*lcs[p]).convert( CommonLc::Linear );

   p = 0;
   while( p != lcs.count( ) ) {
      if( lcs[p]->nobs <= 1 ) {
	 printf("Removing %s: too few observations\n", Passband::info(lcs[p]->filter)->name);
	 lcs[p]->erase( );
	 lcs.unhook( lcs[p] );
      } else {
	 ++p;
      }
   }

   /*--- run PointFilter on LcSet ---*/
   pf.eval( lcs );
   
   /*--- Append theory Lc's for later use ---*/
   CommonLc *tlc;
   npb = lcs.count();
   for( n = 0; n < npb; ++n ) {
      lcs.append( tlc = new CommonLc );
      lc_hdr_cpy( *lcs[n], *tlc );
      tlc->units = CommonLc::Linear;
      tlc->phtpkg = CommonLc::Theory;
   }
   
   double tlo, thi, vlo, vhi;
   char instr[256], *ibuf;

   LcMoment M;
   GeneralLcFit *lcfit = 0;
   GaussianFit gfit( clifpar );
   MicroFit micro( clifpar );
   MicroBlendFit fmicro( clifpar );
   MicroBinSrcFit bsmicro( clifpar );
   MicroFinSrcFit fsmicro( clifpar );
   MicroParFit parmicro( clifpar );
   MicroBinSrcFit2 bsmicro2( clifpar );
   MicroYukFit yukmicro ( clifpar );
   gfit.init( lcs, pf );
   micro.init( lcs, pf );
   fmicro.init( lcs, pf );
   bsmicro.init( lcs, pf );
   fsmicro.init( lcs, pf );
   parmicro.init( lcs, pf );
   bsmicro2.init( lcs, pf );
   yukmicro.init( lcs, pf );
   lcfit = &micro;

   char *title = lcs[0]->title;

   /*--- Show raw data for parameter guessing ---*/
   LcPlot plot;
   plot.config( lcs );
   plot.xnot = 0.2;
   if( plot.xlimhi - plot.xlimlo > 200 )
      tlo = plot.xlimlo = plot.xlimhi - 400;
   thi = plot.xlimhi += 20;
   plot.draw( lcs );

   do {
      printf("%s\n\n", title );
      printf("f\t\tFit\n");
      printf("l\t\tLimits <[tlo thi [vlo vhi]]>\n");
      printf("d\t\tShow data <Lc # [start count]>\n");
      printf("r\t\tToggle residual plot\n");
      printf("s\t\tStatistics\n");
      printf("p\t\tPlot <device>\n" );
      printf("a\t\tRestore all data\n");
      printf("x\t\tRemove <Lc #>\n");
      printf("q\t\tQuit\n");
      printf("<space>\t\tRefresh\n" );
      fflush( stdin );
      do {
	 printf(" > ");
	 c = getc( stdin );
	 gets( ibuf = instr );
	 printf("\n");
	 done = 0;
	 c = tolower( c );
	 if( c == 'l' || c == 'd' || c == 'x' || c == 'p' ) {
	    while( isspace( *ibuf ) ) ++ibuf;
	 }
	 fflush( stdin );
	 switch( c ) {
	 case 'f' :	// select and perform fit
	    if( rflag ) {
	       printf( "Toggle out of residual mode first\n" );
	       break;
	    }
	    //	    printf("\t0\t%s\n", gfit.name );
	    printf("\t0\t%s\n", micro.name );
	    //	    printf("\t1\t%s\n", fmicro.name );
	    //	    printf("\t1\t%s\n", bsmicro.name );
	    printf("\t1\t%s\n", fsmicro.name );
	    printf("\t2\t%s\n", parmicro.name );
	    printf("\t3\t%s\n", bsmicro2.name );
	    printf("\t4\t%s\n", bsmicro.name );
	    printf("\t5\t%s\n", yukmicro.name );
	    printf("\t> " );
	    gets( ibuf = instr );
	    switch( atoi( ibuf ) ) {
	    default :
	       printf("\tInvalid fit selection\n");
	       lcfit = &micro;
	       break;
	    case 0 : if (lcfit != &micro) { ++tamper; }
	       lcfit = &micro; break;
	    case 1 : if (lcfit != &fsmicro) { ++tamper; }
	       lcfit = &fsmicro; break;
	    case 2 : if (lcfit != &parmicro) { ++tamper; }
	       lcfit = &parmicro;
	       
	       double eb, el;
	       char ecliptic[256], fts[256], *scrp;

	       // Problem is, clc title is "MACHO object 1.3450.2557" and we
	       //   only want the f.t.s.  Also in lcfit.C.
	       strcpy(ecliptic, lcs[0]->title);
	       scrp = strrchr(ecliptic, ' ');      // ' ' makes \  an int
	       *scrp = 0;
	       ++scrp;
	       strcpy(fts, scrp);
	       
	       sprintf (ecliptic, "ParallaxFit_%s_ecliptic.l", fts);
	       el = clifpar.get(ecliptic, 270.);                  		 // Use rd2lb.gmn
	       printf("\nUsing %-20s = %.7g\n", ecliptic, el );
	       
	       sprintf (ecliptic, "ParallaxFit_%s_ecliptic.b", fts);
	       eb = clifpar.get(ecliptic, -5.);                  		 // Use rd2lb.gmn
 	       printf("Using %-20s = %.7g\n\n", ecliptic, eb );
	       
	       break;
	    case 3 : if (lcfit != &bsmicro2) { ++tamper; }
	       lcfit = &bsmicro2; break;
	    case 4 : if (lcfit != &bsmicro) { ++tamper; }
	       lcfit = &bsmicro; break;
	    case 5 : if (lcfit != &yukmicro) { ++tamper; }
	       lcfit = &yukmicro; break;
	    }
	    if( !lcfit )
	       break;
	    if( tamper ) {
	       pf.eval( lcs );
	       lcfit->init( lcs, pf );
	       tamper = 0; 
	    }
	    lcfit->iopar( 1 );
	    lcfit->ifit( 0, 0, 1 );
	    lcfit->iopar( );
	    dt = (thi - tlo) * 0.001;
	    for( m = p = 0; m < lcs.count( ); ++m ) 
	       if( (*lcs[m]).phtpkg == CommonLc::Theory ) {
		  (*lcs[m]).resize( 1001 );
		  for( n = 0; n < 1001; ++n ) 
		     (*lcs[m]).date[n] = tlo + dt*n;
		  lcfit->FitLc( *lcs[m], p );
		  ++p;
	       }
	    ++nfits;
	    vhi = -( vlo = Infinity );
	    plot.config( lcs );
	    plot.xnot = 0.2;
	    plot.xlimlo = tlo;
	    plot.xlimhi = thi;
	    for( dp = 0; dp < lcs.count( ); ++dp ) {
	       plot.ylim[1][dp] += 0.3 * (plot.ylim[1][dp] - plot.ylim[0][dp]);
	       plot.ylim[0][dp] = 0;
	    }
	    plot.draw( lcs );
	    ++done;
	    break;
	 case 'r' :	// residual
	    if( rflag ) {
	       lcs_residual( lcs, lcfit, 1 );		// correct data
	       rflag = 0;
	    } else { 
	       lcs_residual( lcs, lcfit, 0 );		// take residual
	       rflag = 1;
	       vhi = -( vlo = Infinity );
	    }
	    plot.config( lcs );				// reset limits
	    plot.xnot = 0.2;
	    plot.draw( lcs );
	    break;
	 case 'l' :	// change limits
	    if( narg = sscanf( ibuf, "%lf %lf %lf %lf",
			    &tlo, &thi, &vlo, &vhi ) );

	    plot.config( lcs );
	    plot.xnot = 0.2;
	    if( narg < 2 ) {
	       tlo = plot.xlimlo;
	       thi = plot.xlimhi;
	    } else {
	       plot.xlimlo = tlo;
	       plot.xlimhi = thi;
	    }
	    
	    if( lcfit ) {
	       dt = (thi - tlo) * 0.001;
	       for( m = p = 0; m < lcs.count( ); ++m ) 
		  if( (*lcs[m]).phtpkg == CommonLc::Theory ) {
		     (*lcs[m]).resize( 1001 );
		     for( n = 0; n < 1001; ++n ) 
			(*lcs[m]).date[n] = tlo + dt*n;
		     if( rflag ) 
			for( n = 0; n < 1001; ++n ) 
			   (*lcs[m]).value[n] = 0;
		     else
			lcfit->FitLc( *lcs[m], p );
		     ++p;
		  }
	    }
	    if( narg >= 4 ) {
	       plot.ylimlo = vlo;
	       plot.ylimhi = vhi;
	    }
	    plot.draw( lcs );
	    
	    break;
	 case ' ' :	// refresh plot
	    //vhi = -( vlo = Infinity );
	    plot.draw( lcs );
	    break;
	 case 'd' :	// write Lc data
	    narg = sscanf( ibuf, "%d %d %d", &l, &st, &ct );
	    
	    if( narg == 0 || l < 0 ) {	// write files
	       for( n = pd = pt = 0; n < lcs.count( ); ++n ) {
		  dlc = (*lcs[n]).phtpkg != CommonLc::Theory;
		  sprintf( cbuf, "%s%c%d.dat", starid,
			   dlc ? 'd' : 't', dlc ? pd : pt );
		  if( dlc ) ++pd;		// data curve
		  else ++pt;			// theory curve
		  printf("writing %s\n", cbuf );
		  if( (outfp = fopen( cbuf, "w") ) == 0 ) {
		     fprintf( stderr, "Cannot open %s to write\n", cbuf );
		     continue;
		  } else {
		     (*lcs[n]).print( stdout, 0, 0 );
		     (*lcs[n]).print( outfp );
		     fclose( outfp );
		  }
	       }
	       break;
	    }
	    switch( narg ) {	// subsets are printed to screen
	    default :
	       printf( "No arguments read\n");
	       break;
	    case 1 :
	       (*lcs[l]).print( stdout );
	       ++done;
	       break;
	    case 2 :
	       (*lcs[l]).print( stdout, st );
	       ++done;
	       break;
	    case 3 : case 4 :
	       (*lcs[l]).print( stdout, st, ct );
	       break;
	    }
	    break;

	 case 'p' :	// replot
	    narg = sscanf( ibuf, "%s %s", cbuf, outfi );
	    switch( narg ) {
	    default :
	       plot.print( lcs, "postscript" );
	       break;
	    case 1 :
	       plot.print( lcs, cbuf );
	       break;
	    case 2 :
	       plot.print( lcs, cbuf, outfi );
	       break;
	    }

	 case 'a' :
	    printf("Adding %d Lc's to fit set\n", hlcs.count( ) );
	    tamper = 1;
	    while( hlcs.count( ) ) {
	       lcs.append( hlcs[0] );
	       printf("%s rehooked\n",
		      Passband::info( (*hlcs[0]).filter )->name );
	       hlcs.unhook( hlcs[0] );
	    }
	    plot.config( lcs );
	    plot.xlimlo = tlo;
	    plot.xlimhi = thi;
	    plot.draw( lcs ); 
	    break;
	 case 's' :
	    for( n = 0; n < lcs.count( ); ++n ) {
	       if( lcs[n]->phtpkg == CommonLc::Theory )
		  continue;
	       if( M.eval( *lcs[n] ) )
		  continue;
	       printf("\n%s\n", (*Passband::info( lcs[n]->filter ) ).name );
	       M.print( stdout, 2 );
	    }
	    break;
	 case 'x' :
	    n = atoi( ibuf );
	    if( n < 0 || n >= lcs.count( ) ) {
	       printf("Invalid Lc #\n" );
	       break;
	    }
	    /*--- find data curve n ---*/
	    pd = -1;
	    for( m = p = 0; m < lcs.count( ); ++m ) {
	       if( lcs[m]->phtpkg == CommonLc::Theory ) 
		  continue;
	       if( p == n ) pd = m;
	       ++p;
	    }
	    if( pd >= 0 ) { 
	       hlcs.append( lcs[pd] );
	       printf("%s unhooked\n",
		      Passband::info( (*lcs[pd]).filter )->name );
	       lcs.unhook( lcs[pd] );
	       ++tamper;
	    }
	    /*--- find theory curve n ---*/
	    pt = -1;
	    for( m = p = 0; m < lcs.count( ); ++m ) {
	       if( lcs[m]->phtpkg == CommonLc::Theory ) {
		  if( p == n ) pt = m;
		  ++p;
	       }
	    }
	    if( pt >= 0 ) { 
	       hlcs.append( lcs[pt] );
	       printf("%s unhooked\n",
		      Passband::info( (*lcs[pt]).filter )->name );
	       lcs.unhook( lcs[pt] );
	       ++tamper;
	    }
	    plot.config( lcs );
	    plot.xlimlo = tlo;
	    plot.xlimhi = thi;
	    plot.draw( lcs );
	    break;

	 case 'q' :
	    exit( 0 );
	 default:
	    break;
	 }
	 fflush( stdin );
      } while( !done );			// waiting for directions
   } while( 1 );
   return 0;
}
예제 #18
0
파일: lat_proc.c 프로젝트: ash9211/graphene
int
main(int ac, char **av)
{
	if (ac < 2) goto usage;

	if (!strcmp("procedure", av[1])) {
		BENCH(do_procedure(ac), 0);
		micro("Procedure call", get_n());
	} else if (!strcmp("fork", av[1])) {
		BENCH(do_fork(), 0);
#ifdef STATIC
		micro("Static Process fork+exit", get_n());
#else
		micro("Process fork+exit", get_n());
#endif
	} else if (!strcmp("dfork", av[1])) {
		BENCH(do_dfork(), 0);
#ifdef STATIC
		micro("Static Process double fork+exit", get_n());
#else
		micro("Process double fork+exit", get_n());
#endif
	} else if (!strcmp("exec", av[1])) {
		BENCH(do_forkexec(), 0);
#ifdef STATIC
		micro("Static Process fork+execve", get_n());
#else
		micro("Process fork+execve", get_n());
#endif
	} else if (!strcmp("dforkexec", av[1])) {
		BENCH(do_dforkexec(), 0);
#ifdef STATIC
		micro("Static Process double fork+execve", get_n());
#else
		micro("Process double fork+execve", get_n());
#endif
	} else if (!strcmp("shell", av[1])) {
		BENCH(do_shell(), 0);
#ifdef STATIC
		micro("Static Process fork+/bin/sh -c", get_n());
#else
		micro("Process fork+/bin/sh -c", get_n());
#endif
	} else {
usage:		printf("Usage: %s fork|exec|shell|dfork|dforkexec\n", av[0]);
	}
	return(0);
}
int main(int ac, char **av)
{
    int             realtime = 0;
    int		    parallel = 1;
    int             warmup = 0;
    int             repetitions = -1;
    int             c;
    char            buf[512];
    timer_e	    what = USLEEP;
    state_t         state;
    char           *scheduler = "";
    char           *mechanism = "usleep";
    char           *usage = "[-r] [-u <method>] [-P <parallelism>] [-W <warmup>] [-N <repetitions>] usecs\nmethod=usleep|nanosleep|select|pselect|itimer\n";

    realtime = 0;

    while ((c = getopt(ac, av, "ru:W:N:")) != EOF) {
	switch (c) {
	case 'r':
	    realtime = 1;
	    break;
	case 'u':
	    if (strcmp(optarg, "usleep") == 0) {
		what = USLEEP;
		mechanism = "usleep";
	    } else if (strcmp(optarg, "nanosleep") == 0) {
		what = NANOSLEEP;
		mechanism = "nanosleep";
	    } else if (strcmp(optarg, "select") == 0) {
		what = SELECT;
		mechanism = "select";
#ifdef _POSIX_SELECT
	    } else if (strcmp(optarg, "pselect") == 0) {
		what = PSELECT;
		mechanism = "pselect";
#endif /* _POSIX_SELECT */
	    } else if (strcmp(optarg, "itimer") == 0) {
		what = ITIMER;
		mechanism = "itimer";
	    } else {
		lmbench_usage(ac, av, usage);
	    }
	    break;
	case 'P':
	    parallel = atoi(optarg);
	    if (parallel <= 0) lmbench_usage(ac, av, usage);
	    break;
	case 'W':
	    warmup = atoi(optarg);
	    break;
	case 'N':
	    repetitions = atoi(optarg);
	    break;
	default:
	    lmbench_usage(ac, av, usage);
	    break;
	}
    }
    if (optind != ac - 1) {
	lmbench_usage(ac, av, usage);
    }

    state.usecs = bytes(av[optind]);
    if (realtime && set_realtime()) scheduler = "realtime ";

    switch (what) {
    case USLEEP:
	benchmp(NULL, bench_usleep, NULL, 
		0, parallel, warmup, repetitions, &state);
	break;
    case NANOSLEEP:
	benchmp(NULL, bench_nanosleep, NULL, 
		0, parallel, warmup, repetitions, &state);
	break;
    case SELECT:
	benchmp(NULL, bench_select, NULL, 
		0, parallel, warmup, repetitions, &state);
	break;
#ifdef _POSIX_SELECT
    case PSELECT:
	benchmp(NULL, bench_pselect, NULL, 
		0, parallel, warmup, repetitions, &state);
	break;
#endif /* _POSIX_SELECT */
    case ITIMER:
	benchmp(initialize, bench_itimer, NULL, 
		0, parallel, warmup, repetitions, &state);
	break;
    default:
	lmbench_usage(ac, av, usage);
	break;
    }
    sprintf(buf, "%s%s %lu microseconds", scheduler, mechanism, state.usecs);
    micro(buf, get_n());
    return (0);
}
예제 #20
0
int
main(int ac, char **av)
{
	int parallel = 1;
	int warmup = 0;
	int repetitions = TRIES;
	int c;
	struct _state state;
	char* usage = "[-P <parallelism>] [-W <warmup>] [-N <repetitions>] null|read|write|stat|fstat|open [file]\n";

	while (( c = getopt(ac, av, "P:W:N:")) != EOF) {
		switch(c) {
		case 'P':
			parallel = atoi(optarg);
			if (parallel <= 0) lmbench_usage(ac, av, usage);
			break;
		case 'W':
			warmup = atoi(optarg);
			break;
		case 'N':
			repetitions = atoi(optarg);
			break;
		default:
			lmbench_usage(ac, av, usage);
			break;
		}
	}
	if (optind != ac - 1 && optind != ac - 2 ) {
		lmbench_usage(ac, av, usage);
	}
	
	state.file = FNAME;
	if (optind == ac - 2) 
		state.file = av[optind + 1];

	if (!strcmp("null", av[optind])) {
		benchmp(NULL, do_getppid, NULL, 0, parallel, 
			warmup, repetitions, &state);
		micro("Simple syscall", get_n());
	} else if (!strcmp("write", av[optind])) {
		state.fd = open("/dev/null", 1);
		benchmp(NULL, do_write, NULL, 0, parallel, 
			warmup, repetitions, &state);
		micro("Simple write", get_n());
		close(state.fd);
	} else if (!strcmp("read", av[optind])) {
		state.fd = open("/dev/zero", 0);
		if (state.fd == -1) {
			fprintf(stderr, "Simple read: -1\n");
			return(1);
		}
		benchmp(NULL, do_read, NULL, 0, parallel, 
			warmup, repetitions, &state);
		micro("Simple read", get_n());
		close(state.fd);
	} else if (!strcmp("stat", av[optind])) {
		benchmp(NULL, do_stat, NULL, 0, parallel, 
			warmup, repetitions, &state);
		micro("Simple stat", get_n());
	} else if (!strcmp("fstat", av[optind])) {
		state.fd = open(state.file, 0);
		benchmp(NULL, do_fstat, NULL, 0, parallel, 
			warmup, repetitions, &state);
		micro("Simple fstat", get_n());
		close(state.fd);
	} else if (!strcmp("open", av[optind])) {
		benchmp(NULL, do_openclose, NULL, 0, parallel, 
			warmup, repetitions, &state);
		micro("Simple open/close", get_n());
	} else {
		lmbench_usage(ac, av, usage);
	}
	return(0);
}
예제 #21
0
int
main(int ac, char **av)
{
	char	c;
	int	n, N, fd, fid;
	pid_t	pid, ppid;
	char	buf[L_tmpnam+256];
	char	fname[L_tmpnam];
	char*	report_file = "Select on %d fd's";
	char*	report_tcp  = "Select on %d tcp fd's";
	char*	report;
	char*	usage = "lat_select tcp|file [n]\n";

	morefds();
	N = 200;
	fname[0] = 0;
	pid = 0;
	c = 0;
	nfds = 0;
	FD_ZERO(&set);
	report = report_file;

	if (ac != 2 && ac != 3) {
		fprintf(stderr, usage);
		exit(1);
	}

	if (streq(av[1], "tcp")) {
		report = report_tcp;
		
		/* Create a socket for clients to connect to */
		fd = tcp_server(TCP_SELECT, SOCKOPT_REUSE);
		if (fd <= 0) {
			perror("lat_select: Could not open tcp server socket");
			exit(1);
		}

		/* Start server process to accept client connections */
		ppid = getpid();
		switch(pid = fork()) {
		case 0:
			/* child server process */
			if (signal(SIGTERM, sigterm) == SIG_ERR) {
				perror("signal(SIGTERM, sigterm) failed");
				exit(1);
			}
			FD_SET(fd, &set);
			while (ppid == getppid()) {
				int newsock = tcp_accept(fd, SOCKOPT_NONE);
				if (newsock >= nfds) nfds = newsock + 1;
				FD_SET(newsock, &set);
			}
			sigterm(SIGTERM);
			/* NOTREACHED */
		case -1:
			/* error */
			perror("lat_select::server(): fork() failed");
			exit(1);
		default:
			break;
		}
		close(fd);
		fd = tcp_connect("127.0.0.1", TCP_SELECT, SOCKOPT_NONE);
		if (fd <= 0) {
			perror("lat_select: Could not open socket");
			exit(1);
		}
	} else if (streq(av[1], "file")) {
		/* Create a temporary file for clients to open */
		tmpnam(fname);
		fd = open(fname, O_RDWR|O_APPEND|O_CREAT, 0666);
		unlink(fname);
		if (fd <= 0) {
			char buf[L_tmpnam+128];
			sprintf(buf, 
				"lat_select: Could not create temp file %s", fname);
			perror(buf);
			exit(1);
		}
	} else {
		fprintf(stderr, usage);
		exit(1);
	}

	if (ac == 3) N = atoi(av[2]);

	for (n = 0; n < N; n++) {
		fid = dup(fd);
		if (fid == -1) break;
		if (fid >= nfds) nfds = fid + 1;
		FD_SET(fid, &set);
	}
	BENCH(doit(nfds, &set), 0);
	sprintf(buf, report, n);
	micro(buf, get_n());

	for (fid = 0; fid < nfds; fid++) {
		if (FD_ISSET(fid, &set)) {
			close(fid);
		}
	}
	close(fd);
	if (pid) kill(pid, SIGTERM);

	exit(0);
}