mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
sync
This commit is contained in:
parent
e4e3cabec0
commit
adfc221a4c
|
@ -5,16 +5,7 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static void usp_fork_query()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_query()")
|
||||
|
||||
World::handlerForkSql();
|
||||
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
(void) World::initPipeline();
|
||||
#endif
|
||||
}
|
||||
static void usp_fork_query() { World::handlerForkSql(); }
|
||||
-->
|
||||
<!--#header
|
||||
-->
|
||||
|
@ -32,39 +23,17 @@ if (World::pdrv)
|
|||
PGresult* res;
|
||||
char* randomNumber;
|
||||
|
||||
while (true)
|
||||
for (; i < num_queries; ++i)
|
||||
{
|
||||
World::sendQueryPrepared(i);
|
||||
res = World::pdrv->execPrepared(World::pstmt);
|
||||
|
||||
if (++i == num_queries) break;
|
||||
|
||||
(void) U_SYSCALL(PQbatchPutSyncOnQueue, "%p", World::conn); // NB: make the difference between pipeline vs batch...
|
||||
}
|
||||
|
||||
(void) U_SYSCALL(PQbatchSendQueue, "%p", World::conn);
|
||||
|
||||
for (i = 0; i < num_queries; ++i)
|
||||
{
|
||||
(void) U_SYSCALL(PQbatchProcessQueue, "%p", World::conn);
|
||||
|
||||
res = (PGresult*) U_SYSCALL(PQgetResult, "%p", World::conn);
|
||||
|
||||
U_INTERNAL_DUMP("Result status: %d (%s) for i=%u, tuples: %d", PQresultStatus(res), PQresStatus(PQresultStatus(res)), i, PQntuples(res))
|
||||
U_INTERNAL_ASSERT_EQUALS(PQnfields(res), 1)
|
||||
U_INTERNAL_ASSERT_EQUALS(PQntuples(res), 1)
|
||||
|
||||
randomNumber = U_SYSCALL(PQgetvalue, "%p,%d,%d", res, 0, 0);
|
||||
|
||||
World::handlerResult(World::rnumber[i], ntohl(*(uint32_t*)randomNumber));
|
||||
|
||||
U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
|
||||
(void) U_SYSCALL(PQgetResult, "%p", World::conn);
|
||||
|
||||
(void) U_SYSCALL(PQbatchProcessQueue, "%p", World::conn);
|
||||
|
||||
res = (PGresult*) U_SYSCALL(PQgetResult, "%p", World::conn);
|
||||
|
||||
U_INTERNAL_DUMP("Result status: %d (%s) for i=%u, tuples: %d", PQresultStatus(res), PQresStatus(PQresultStatus(res)), i, PQntuples(res))
|
||||
|
||||
U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ static void usp_fork_update()
|
|||
if (World::psql_query)
|
||||
{
|
||||
# ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
if (World::initPipeline()) (void) memcpy(query, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = v.randomNumber FROM (VALUES"));
|
||||
if (World::pdrv) (void) memcpy(query, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = v.randomNumber FROM (VALUES"));
|
||||
else
|
||||
# endif
|
||||
{
|
||||
|
@ -52,6 +52,13 @@ if (World::pdrv)
|
|||
|
||||
pquery = u_num2str32(World::rnumber[i], pquery+1);
|
||||
|
||||
res = World::pdrv->execPrepared(World::pstmt);
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(PQnfields(res), 1)
|
||||
U_INTERNAL_ASSERT_EQUALS(PQntuples(res), 1)
|
||||
|
||||
(void) U_SYSCALL(PQgetvalue, "%p,%d,%d", res, 0, 0);
|
||||
|
||||
*pquery = ',';
|
||||
|
||||
pquery = u_num2str32(World::rnum = u_get_num_random_range1(10000), pquery+1);
|
||||
|
@ -61,9 +68,7 @@ if (World::pdrv)
|
|||
|
||||
World::handlerResult(World::rnumber[i], World::rnum);
|
||||
|
||||
World::sendQueryPrepared(i);
|
||||
|
||||
(void) U_SYSCALL(PQbatchPutSyncOnQueue, "%p", World::conn); // NB: make the difference between pipeline vs batch...
|
||||
U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
}
|
||||
|
||||
World::endResult();
|
||||
|
@ -71,14 +76,11 @@ if (World::pdrv)
|
|||
(void) memcpy(pquery-1, ") AS v (id,randomNumber) WHERE World.id = v.id;",
|
||||
U_CONSTANT_SIZE(") AS v (id,randomNumber) WHERE World.id = v.id;")+1);
|
||||
|
||||
(void) U_SYSCALL(PQsendQueryParams, "%p,%S,%d,%p,%p,%p,%d", World::conn, query, 0, U_NULLPTR, U_NULLPTR, U_NULLPTR, U_NULLPTR, 0);
|
||||
res = (PGresult*) U_SYSCALL(PQexec, "%p,%S", (PGconn*)World::conn, query);
|
||||
|
||||
(void) U_SYSCALL(PQbatchSendQueue, "%p", World::conn);
|
||||
U_INTERNAL_ASSERT_EQUALS(PQresultStatus(res), PGRES_COMMAND_OK)
|
||||
|
||||
while (U_SYSCALL(PQbatchProcessQueue, "%p", World::conn) == 1)
|
||||
{
|
||||
while ((res = (PGresult*) U_SYSCALL(PQgetResult, "%p", World::conn))) U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
}
|
||||
U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
|
|
@ -1 +1 @@
|
|||
01C5
|
||||
01CC
|
||||
|
|
|
@ -5,16 +5,7 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static void usp_fork_query()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_query()")
|
||||
|
||||
World::handlerForkSql();
|
||||
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
(void) World::initPipeline();
|
||||
#endif
|
||||
}
|
||||
static void usp_fork_query() { World::handlerForkSql(); }
|
||||
-->
|
||||
<!--#header
|
||||
-->
|
||||
|
@ -32,39 +23,17 @@ if (World::pdrv)
|
|||
PGresult* res;
|
||||
char* randomNumber;
|
||||
|
||||
while (true)
|
||||
for (; i < num_queries; ++i)
|
||||
{
|
||||
World::sendQueryPrepared(i);
|
||||
res = World::pdrv->execPrepared(World::pstmt);
|
||||
|
||||
if (++i == num_queries) break;
|
||||
|
||||
(void) U_SYSCALL(PQbatchPutSyncOnQueue, "%p", World::conn); // NB: make the difference between pipeline vs batch...
|
||||
}
|
||||
|
||||
(void) U_SYSCALL(PQbatchSendQueue, "%p", World::conn);
|
||||
|
||||
for (i = 0; i < num_queries; ++i)
|
||||
{
|
||||
(void) U_SYSCALL(PQbatchProcessQueue, "%p", World::conn);
|
||||
|
||||
res = (PGresult*) U_SYSCALL(PQgetResult, "%p", World::conn);
|
||||
|
||||
U_INTERNAL_DUMP("Result status: %d (%s) for i=%u, tuples: %d", PQresultStatus(res), PQresStatus(PQresultStatus(res)), i, PQntuples(res))
|
||||
U_INTERNAL_ASSERT_EQUALS(PQnfields(res), 1)
|
||||
U_INTERNAL_ASSERT_EQUALS(PQntuples(res), 1)
|
||||
|
||||
randomNumber = U_SYSCALL(PQgetvalue, "%p,%d,%d", res, 0, 0);
|
||||
|
||||
World::handlerResult(World::rnumber[i], ntohl(*(uint32_t*)randomNumber));
|
||||
|
||||
U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
|
||||
(void) U_SYSCALL(PQgetResult, "%p", World::conn);
|
||||
|
||||
(void) U_SYSCALL(PQbatchProcessQueue, "%p", World::conn);
|
||||
|
||||
res = (PGresult*) U_SYSCALL(PQgetResult, "%p", World::conn);
|
||||
|
||||
U_INTERNAL_DUMP("Result status: %d (%s) for i=%u, tuples: %d", PQresultStatus(res), PQresStatus(PQresultStatus(res)), i, PQntuples(res))
|
||||
|
||||
U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ static void usp_fork_update()
|
|||
if (World::psql_query)
|
||||
{
|
||||
# ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
if (World::initPipeline()) (void) memcpy(query, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = v.randomNumber FROM (VALUES"));
|
||||
if (World::pdrv) (void) memcpy(query, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = v.randomNumber FROM (VALUES"));
|
||||
else
|
||||
# endif
|
||||
{
|
||||
|
@ -52,6 +52,13 @@ if (World::pdrv)
|
|||
|
||||
pquery = u_num2str32(World::rnumber[i], pquery+1);
|
||||
|
||||
res = World::pdrv->execPrepared(World::pstmt);
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(PQnfields(res), 1)
|
||||
U_INTERNAL_ASSERT_EQUALS(PQntuples(res), 1)
|
||||
|
||||
(void) U_SYSCALL(PQgetvalue, "%p,%d,%d", res, 0, 0);
|
||||
|
||||
*pquery = ',';
|
||||
|
||||
pquery = u_num2str32(World::rnum = u_get_num_random_range1(10000), pquery+1);
|
||||
|
@ -61,9 +68,7 @@ if (World::pdrv)
|
|||
|
||||
World::handlerResult(World::rnumber[i], World::rnum);
|
||||
|
||||
World::sendQueryPrepared(i);
|
||||
|
||||
(void) U_SYSCALL(PQbatchPutSyncOnQueue, "%p", World::conn); // NB: make the difference between pipeline vs batch...
|
||||
U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
}
|
||||
|
||||
World::endResult();
|
||||
|
@ -71,14 +76,11 @@ if (World::pdrv)
|
|||
(void) memcpy(pquery-1, ") AS v (id,randomNumber) WHERE World.id = v.id;",
|
||||
U_CONSTANT_SIZE(") AS v (id,randomNumber) WHERE World.id = v.id;")+1);
|
||||
|
||||
(void) U_SYSCALL(PQsendQueryParams, "%p,%S,%d,%p,%p,%p,%d", World::conn, query, 0, U_NULLPTR, U_NULLPTR, U_NULLPTR, U_NULLPTR, 0);
|
||||
res = (PGresult*) U_SYSCALL(PQexec, "%p,%S", (PGconn*)World::conn, query);
|
||||
|
||||
(void) U_SYSCALL(PQbatchSendQueue, "%p", World::conn);
|
||||
U_INTERNAL_ASSERT_EQUALS(PQresultStatus(res), PGRES_COMMAND_OK)
|
||||
|
||||
while (U_SYSCALL(PQbatchProcessQueue, "%p", World::conn) == 1)
|
||||
{
|
||||
while ((res = (PGresult*) U_SYSCALL(PQgetResult, "%p", World::conn))) U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
}
|
||||
U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user