1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
//#define USE_SERVER
#include <iostream>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#ifdef USE_SERVER
#include "ApplicationPoolServer.h"
#else
#include "StandardApplicationPool.h"
#endif
#include "Utils.h"
#include "Logging.h"
using namespace std;
using namespace boost;
using namespace Passenger;
#define TRANSACTIONS 20000
#define CONCURRENCY 24
ApplicationPoolPtr pool;
static void
threadMain(unsigned int times) {
for (unsigned int i = 0; i < times; i++) {
Application::SessionPtr session(pool->get("test/stub/minimal-railsapp"));
for (int x = 0; x < 200000; x++) {
// Do nothing.
}
}
}
int
main() {
thread_group tg;
#ifdef USE_SERVER
ApplicationPoolServer server("ext/apache2/ApplicationPoolServerExecutable",
"bin/passenger-spawn-server");
pool = server.connect();
#else
pool = ptr(new StandardApplicationPool("bin/passenger-spawn-server"));
#endif
pool->setMax(6);
for (int i = 0; i < CONCURRENCY; i++) {
tg.create_thread(boost::bind(&threadMain, TRANSACTIONS / CONCURRENCY));
}
tg.join_all();
return 0;
}
|