MAIN(httpMain, int argc, char *argv[]) { MprTime start; double elapsed; if (mprCreate(argc, argv, MPR_USER_EVENTS_THREAD) == 0) { return MPR_ERR_MEMORY; } if ((app = mprAllocObj(App, manageApp)) == 0) { return MPR_ERR_MEMORY; } mprAddRoot(app); mprAddStandardSignals(); initSettings(); if (!parseArgs(argc, argv)) { showUsage(); return MPR_ERR_BAD_ARGS; } mprSetMaxWorkers(app->workers); #if BLD_FEATURE_SSL if (!mprLoadSsl(1)) { mprError("Can't load SSL"); exit(1); } #endif if (mprStart() < 0) { mprError("Can't start MPR for %s", mprGetAppTitle()); exit(2); } start = mprGetTime(); app->http = httpCreate(); httpEaseLimits(app->http->clientLimits); processing(); mprServiceEvents(-1, 0); if (app->benchmark) { elapsed = (double) (mprGetTime() - start); if (app->fetchCount == 0) { elapsed = 0; app->fetchCount = 1; } mprPrintf("\nRequest Count: %13d\n", app->fetchCount); mprPrintf("Time elapsed: %13.4f sec\n", elapsed / 1000.0); mprPrintf("Time per request: %13.4f sec\n", elapsed / 1000.0 / app->fetchCount); mprPrintf("Requests per second: %13.4f\n", app->fetchCount * 1.0 / (elapsed / 1000.0)); mprPrintf("Load threads: %13d\n", app->loadThreads); mprPrintf("Worker threads: %13d\n", app->workers); } if (!app->success && app->verbose) { mprError("Request failed"); } return (app->success) ? 0 : 255; }
MAIN(httpMain, int argc, char **argv, char **envp) { MprTime start; double elapsed; if (mprCreate(argc, argv, MPR_USER_EVENTS_THREAD) == 0) { return MPR_ERR_MEMORY; } if ((app = mprAllocObj(App, manageApp)) == 0) { return MPR_ERR_MEMORY; } mprAddRoot(app); mprAddStandardSignals(); initSettings(); if (parseArgs(argc, argv) < 0) { return MPR_ERR_BAD_ARGS; } mprSetMaxWorkers(app->workers); if (mprStart() < 0) { mprError("Cannot start MPR for %s", mprGetAppTitle()); exit(2); } start = mprGetTime(); app->http = httpCreate(HTTP_CLIENT_SIDE); httpEaseLimits(app->http->clientLimits); #if BIT_STATIC && BIT_PACK_SSL extern MprModuleEntry mprSslInit; mprNop(mprSslInit); #endif processing(); mprServiceEvents(-1, 0); if (app->benchmark) { elapsed = (double) (mprGetTime() - start); if (app->fetchCount == 0) { elapsed = 0; app->fetchCount = 1; } mprPrintf("\nRequest Count: %13d\n", app->fetchCount); mprPrintf("Time elapsed: %13.4f sec\n", elapsed / 1000.0); mprPrintf("Time per request: %13.4f sec\n", elapsed / 1000.0 / app->fetchCount); mprPrintf("Requests per second: %13.4f\n", app->fetchCount * 1.0 / (elapsed / 1000.0)); mprPrintf("Load threads: %13d\n", app->loadThreads); mprPrintf("Worker threads: %13d\n", app->workers); } if (!app->success && app->verbose) { mprError("Request failed"); } mprDestroy(MPR_EXIT_DEFAULT); return (app->success) ? 0 : 255; }