Exemple #1
0
/**
 * @brief Entry point for all thread work requests.
 */
void RunThreadsOn (void (*func)(unsigned int), int unsigned workcount, qboolean progress, const char *id)
{
	int start, end;

	if (threadstate.numthreads < 1)  /* ensure safe thread counts */
		threadstate.numthreads = 1;

	if (threadstate.numthreads > MAX_THREADS)
		threadstate.numthreads = MAX_THREADS;

	threadstate.workindex = 0;
	threadstate.workcount = workcount;
	threadstate.workfrac = -1;
	threadstate.progress = progress;
	threadstate.worktick = sqrt(workcount) + 1;

	WorkFunction = func;

	start = time(NULL);

	if (threadstate.progress) {
		fprintf(stdout, "%10s: ", id);
		fflush(stdout);
	}

	RunThreads();

	end = time(NULL);

	if (threadstate.progress) {
		Verb_Printf(VERB_NORMAL, " (time: %6is, #: %i)\n", end - start, workcount);
	}
}
LOCAL_C TInt testThreads(TThreadFunction aFunc, TChar c, TChar d)
/// Run threads testing read and write of the drives both ways round.
/// The thread will report any error and return it as a value, the program will
/// exit at a higher level after cleaning up.
	{
	TInt r;
	if ((r = RunThreads(aFunc, c, d, EWrite)) != KErrNone) return r;
	if ((r = RunThreads(aFunc, c, d, ERead))  != KErrNone) return r;
	if ((r = RunThreads(aFunc, d, c, EWrite)) != KErrNone) return r;
	if ((r = RunThreads(aFunc, d, c, ERead))  != KErrNone) return r;
	// display totals;
	test.Printf(_L("average write throughput = %d bytes/sec\n"), GetSpeed(gWrStats));
	test.Printf(_L("average read  throughput = %d bytes/sec\n"), GetSpeed(gRdStats));
	test.Printf(_L("\n"));
	gWrStats.Init();
	gRdStats.Init();
	return r;
	}
Exemple #3
0
/*
 * RunThreadsOn
 *
 * Entry point for all thread work requests.
 */
void RunThreadsOn(int workcount, boolean_t progress, void(*func)(int)){
	time_t start, end;

	thread_work.index = 0;
	thread_work.count = workcount;
	thread_work.fraction = -1;
	thread_work.progress = progress;

	WorkFunction = func;

	start = time(NULL);

	RunThreads();

	end = time(NULL);

	if(thread_work.progress)
		Com_Print(" (%i seconds)\n", (int)(end - start));
}