Ejemplo n.º 1
0
double check_sync(OSyncEngine *engine, const char *name, int num)
{
	int ret;
	printf(".");
	fflush(stdout);
	starttime = _second();
	osync_trace(TRACE_INTERNAL, "++++++++++++++++ Test \"%s %i\" starting ++++++++++++++", name, num);
	osengine_set_enginestatus_callback(engine, engine_status, NULL);
	sync_now(engine);
	osengine_set_enginestatus_callback(engine, NULL, NULL);
	int wasted = 0;
	int alldeciders = 0;
	osengine_get_wasted(engine, &alldeciders, &wasted);
	osync_trace(TRACE_INTERNAL, "++++++++++++++++ Test \"%s %i\" ended (%i / %i (%i%%)) ++++++++++++++", name, num, wasted, alldeciders, (int)(((float)wasted / (float)alldeciders) * 100));
	double thistime = _second() - starttime;

	printf(".");
	fflush(stdout);

	char *tempdir = g_strdup_printf("%s/plgtest.XXXXXX", g_get_tmp_dir());
	if (!mkdtemp(tempdir))
	{
		g_free(tempdir);
		osync_trace(TRACE_INTERNAL, "unable to create temporary dir: %s", g_strerror(errno));
		abort();
	}
	char *command = g_strdup_printf("mv %s/* %s &> /dev/null", localdir, tempdir);
	ret = system(command);
	if (ret)
	{
		g_free(tempdir);
		g_free(command);
		osync_trace(TRACE_INTERNAL, "Unable to move files to temporary dir: %d", ret);
		abort();
	}
	g_free(command);
	printf(".");
	fflush(stdout);

	check_empty();

	printf(".");
	fflush(stdout);

	osync_group_set_slow_sync(engine->group, "data", TRUE);

	sync_now(engine);
	printf(".");
	fflush(stdout);
	command = g_strdup_printf("test \"x$(diff -x \".*\" %s %s)\" = \"x\"", localdir, tempdir);
	int result = system(command);
	g_free(command);

	g_free(tempdir);
	if (result)
		abort();

	printf(" success\n");
	return thistime;
}
Ejemplo n.º 2
0
void engine_status(OSyncEngine *engine, OSyncEngineUpdate *status, void *user_data)
{
	switch (status->type) {
		case ENG_ENDPHASE_CON:
			osync_trace(TRACE_INTERNAL, "++++++++++++++++ Connection Phase ended ++++++++++++++");
			currenttime = _second();
			connecttime = currenttime - starttime;
			break;
		case ENG_ENDPHASE_READ:
			osync_trace(TRACE_INTERNAL, "++++++++++++++++ Read Phase ended ++++++++++++++");
			readtime = _second() - currenttime;
			currenttime = _second();
			break;
		case ENG_ENDPHASE_WRITE:
			osync_trace(TRACE_INTERNAL, "++++++++++++++++ Write Phase ended ++++++++++++++");
			writetime = _second() - currenttime;
			currenttime = _second();
			break;
		default:
			;
	}
}
Ejemplo n.º 3
0
void
_mtcpu()
{
	struct stkstat	stats;		/* Stack statistics struct */
	double	waltime, clks, percent;

	/* Print total clocks run, wallclock time, and % of machine used */

	waltime	= (double) (_rtc() - _rtstart) / (double) CLK_TCK;
	clks	= _second();
	percent	= (waltime > 0.0) ?
			(100.0 * clks / (waltime * (double) ZQMAXCPU)) : 0.0;

	if (waltime >= 0.0) {
		if (percent > 0.05 && percent < 99.9999)
			(void) fprintf(stderr,
			" CPU: %.3fs,  Wallclock: %.3fs,  %.1f%% of %d-CPU Machine\n",
				clks, waltime, percent, ZQMAXCPU);
		else
			(void) fprintf(stderr,
				" CPU: %.3fs,  Wallclock: %.3fs\n", clks,
				waltime);

	}
	else
		/*
		 *  If system reboot after checkpoint, value of wallclock time
	  	 *  may be negative.  Kernel mod only fixes CX/CEA systems.
		 *  Problem can still occur for Cray-2 systems.  Do not give
		 *  bad wallclock value.
		 */
		(void) fprintf(stderr, " CPU: %.3fs\n", clks);

	/* Print memory/stack hi-water marks and number of overflows */

	STKSTAT(&stats);

	(void) fprintf(stderr,
		" Memory HWM: %d, Stack HWM: %d, Stack segment expansions: %d\n",
		$memhwm, MSWM, SOVFL);

	return;
}