Пример #1
0
	bool TestBTree::doTest()
	{
		if( benchmark )
		{
			doBenchmark();
			return true;
		}
		else
		{
			return testRandom() && testClear() && testIteration() 
				&& testComparisons() && testSearching() && testSwap() 
				&& testInsert() && testErase() && testCopy();
		}
	}
Пример #2
0
MAIN(benchMain, int argc, char *argv[])
{
    Mpr         *mpr;
    char        *argp;
    int         err, i, nextArg;
#if BLD_FEATURE_MULTITHREAD
    MprThread   *tp;
#endif

    mpr = mprCreate(argc, argv, 0);

#if VXWORKS || WINCE
    /*
     *  These platforms pass an arg string in via the argc value. Assumes 32-bit.
     */
    mprMakeArgv(mpr, "http", (char*) argc, &argc, &argv);
#endif

    err = 0;
    for (nextArg = 1; nextArg < argc; nextArg++) {
        argp = argv[nextArg];
        if (*argp != '-') {
            break;
        }

        if (strcmp(argp, "--iterations") == 0 || strcmp(argp, "-i") == 0) {
            if (nextArg >= argc) {
                err++;
            } else {
                iterations = atoi(argv[++nextArg]);
            }

        } else if (strcmp(argp, "--workers") == 0 || strcmp(argp, "-w") == 0) {
            if (nextArg >= argc) {
                err++;
            } else {
                i = atoi(argv[++nextArg]);
                if (i <= 0 || i > 100) {
                    mprError(mpr, "%s: Bad number of worker threads (0-100)", mprGetAppName(mpr));
                    exit(2);
                
                }
                workers = i;
            }
        } else {
            err++;
        }
    }
    if (err) {
        mprPrintf(mpr, "usage: bench [-em] [-i iterations] [-t workers]\n");
        mprRawLog(mpr, 0,
            "usage: %s [options]\n"
            "    --iterations count  # Number of iterations to run the test\n"
            "    --workers count     # Set maximum worker threads\n",
            mprGetAppName(mpr));
        exit(2);
    }

#if BLD_FEATURE_MULTITHREAD
    mutex = mprCreateLock(mpr);
    mprSetMaxWorkers(mpr, workers);
#endif

    mprStart(mpr, 0);

#if BLD_FEATURE_MULTITHREAD
    tp = mprCreateThread(mpr, "bench", (MprThreadProc) doBenchmark, (void*) mpr, MPR_NORMAL_PRIORITY, 0);
    mprStartThread(tp);
    while (!testComplete) {
        mprServiceEvents(mprGetDispatcher(mpr), 250, MPR_SERVICE_EVENTS | MPR_SERVICE_IO);
    }
#else
    doBenchmark(mpr, NULL);
#endif

    mprPrintf(mpr, "\n\n");
    // mprFree(mpr);
    return 0;
}