|
@@ -72,18 +72,27 @@ int main(int argc, char* argv[]) {
|
|
}
|
|
}
|
|
|
|
|
|
int port = atoi(argv[2]);
|
|
int port = atoi(argv[2]);
|
|
|
|
+
|
|
int nprocs = std::thread::hardware_concurrency();
|
|
int nprocs = std::thread::hardware_concurrency();
|
|
|
|
|
|
#if TFB_MYSQL
|
|
#if TFB_MYSQL
|
|
- auto sql_db =
|
|
|
|
- mysql_database(s::host = argv[1], s::database = "hello_world", s::user = "benchmarkdbuser",
|
|
|
|
- s::password = "benchmarkdbpass", s::port = 3306, s::charset = "utf8");
|
|
|
|
- int sql_max_connection = sql_db.connect()("SELECT @@GLOBAL.max_connections;").template read<int>() - 10;
|
|
|
|
|
|
+ int nthreads = nprocs;
|
|
#elif TFB_PGSQL
|
|
#elif TFB_PGSQL
|
|
- auto sql_db =
|
|
|
|
- pgsql_database(s::host = argv[1], s::database = "hello_world", s::user = "benchmarkdbuser",
|
|
|
|
- s::password = "benchmarkdbpass", s::port = 5432, s::charset = "utf8");
|
|
|
|
- int sql_max_connection = atoi(sql_db.connect()("SHOW max_connections;").template read<std::string>().c_str()) - 10;
|
|
|
|
|
|
+
|
|
|
|
+#if MONOTHREAD
|
|
|
|
+ int nthreads = 1;
|
|
|
|
+#else
|
|
|
|
+ int nthreads = nprocs;
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#if TFB_MYSQL
|
|
|
|
+ auto sql_db = mysql_database(s::host = argv[1], s::database = "hello_world", s::user = "benchmarkdbuser",
|
|
|
|
+ s::password = "benchmarkdbpass", s::port = 3306, s::charset = "utf8");
|
|
|
|
+#elif TFB_PGSQL
|
|
|
|
+ auto sql_db = pgsql_database(s::host = argv[1], s::database = "hello_world", s::user = "benchmarkdbuser",
|
|
|
|
+ s::password = "benchmarkdbpass", s::port = 5432, s::charset = "utf8");
|
|
#endif
|
|
#endif
|
|
|
|
|
|
auto fortunes = sql_orm_schema(sql_db, "Fortune").fields(
|
|
auto fortunes = sql_orm_schema(sql_db, "Fortune").fields(
|
|
@@ -94,19 +103,25 @@ int main(int argc, char* argv[]) {
|
|
s::id(s::auto_increment, s::primary_key) = int(),
|
|
s::id(s::auto_increment, s::primary_key) = int(),
|
|
s::randomNumber = int());
|
|
s::randomNumber = int());
|
|
|
|
|
|
-
|
|
|
|
#if TFB_MYSQL
|
|
#if TFB_MYSQL
|
|
- int db_nconn = 128/nprocs;
|
|
|
|
|
|
+ int db_nconn = 4;
|
|
int queries_nconn = 2;
|
|
int queries_nconn = 2;
|
|
- int fortunes_nconn = 128/nprocs;
|
|
|
|
|
|
+ int fortunes_nconn = 4;
|
|
int updates_nconn = 1;
|
|
int updates_nconn = 1;
|
|
#elif TFB_PGSQL
|
|
#elif TFB_PGSQL
|
|
- int db_nconn = 200/nprocs;
|
|
|
|
|
|
+ int db_nconn = 7;
|
|
int queries_nconn = 4;
|
|
int queries_nconn = 4;
|
|
- int fortunes_nconn = 200/nprocs;
|
|
|
|
|
|
+ int fortunes_nconn = 7;
|
|
int updates_nconn = 3;
|
|
int updates_nconn = 3;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+#if MONOTHREAD
|
|
|
|
+ db_nconn *= nprocs;
|
|
|
|
+ queries_nconn *= nprocs;
|
|
|
|
+ fortunes_nconn *= nprocs;
|
|
|
|
+ updates_nconn *= nprocs;
|
|
|
|
+#endif
|
|
|
|
+
|
|
http_api my_api;
|
|
http_api my_api;
|
|
|
|
|
|
my_api.get("/plaintext") = [&](http_request& request, http_response& response) {
|
|
my_api.get("/plaintext") = [&](http_request& request, http_response& response) {
|
|
@@ -200,7 +215,7 @@ int main(int argc, char* argv[]) {
|
|
};
|
|
};
|
|
|
|
|
|
// Start the server for the Techempower benchmark.
|
|
// Start the server for the Techempower benchmark.
|
|
- http_serve(my_api, port, s::nthreads = nprocs);
|
|
|
|
|
|
+ http_serve(my_api, port, s::nthreads = nthreads);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|