mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-10-19 19:55:22 +08:00
sync
This commit is contained in:
parent
dd7188d3b3
commit
913f15755e
|
|
@ -63,7 +63,6 @@ static void usp_end_fortune()
|
||||||
<!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr><!--#code
|
<!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr><!--#code
|
||||||
uint32_t sz;
|
uint32_t sz;
|
||||||
Fortune* item;
|
Fortune* item;
|
||||||
char* s = UClientImage_Base::wbuffer->data();
|
|
||||||
char* ptr = UClientImage_Base::wbuffer->pend();
|
char* ptr = UClientImage_Base::wbuffer->pend();
|
||||||
|
|
||||||
U_NEW(Fortune, item, Fortune(*pfortune2add));
|
U_NEW(Fortune, item, Fortune(*pfortune2add));
|
||||||
|
|
@ -106,7 +105,7 @@ for (uint32_t i = 0, n = pvfortune->size(); i < n; ++i)
|
||||||
ptr += 10;
|
ptr += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
UClientImage_Base::wbuffer->size_adjust(ptr - s);
|
UClientImage_Base::wbuffer->size_adjust(ptr);
|
||||||
|
|
||||||
pvfortune->clear();
|
pvfortune->clear();
|
||||||
--></table></body></html>
|
--></table></body></html>
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ UString result;
|
||||||
(void) U_JFIND(mc->vitem[0], "randomNumber", result);
|
(void) U_JFIND(mc->vitem[0], "randomNumber", result);
|
||||||
|
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
char* s = UClientImage_Base::wbuffer->data();
|
|
||||||
char* ptr = UClientImage_Base::wbuffer->pend();
|
char* ptr = UClientImage_Base::wbuffer->pend();
|
||||||
uint32_t sz = result.size();
|
uint32_t sz = result.size();
|
||||||
|
|
||||||
|
|
@ -72,7 +71,7 @@ u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'
|
||||||
|
|
||||||
*ptr++ = '}';
|
*ptr++ = '}';
|
||||||
|
|
||||||
UClientImage_Base::wbuffer->size_adjust(ptr - s);
|
UClientImage_Base::wbuffer->size_adjust(ptr);
|
||||||
#else
|
#else
|
||||||
World world(id, result.strtoul());
|
World world(id, result.strtoul());
|
||||||
USP_OBJ_JSON_stringify(world);
|
USP_OBJ_JSON_stringify(world);
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ static void usp_end_mfortune()
|
||||||
Fortune* item;
|
Fortune* item;
|
||||||
UString result;
|
UString result;
|
||||||
uint32_t i, n, sz;
|
uint32_t i, n, sz;
|
||||||
char* s = UClientImage_Base::wbuffer->data();
|
|
||||||
char* ptr = UClientImage_Base::wbuffer->pend();
|
char* ptr = UClientImage_Base::wbuffer->pend();
|
||||||
|
|
||||||
U_NEW(Fortune, item, Fortune(*pfortune2add));
|
U_NEW(Fortune, item, Fortune(*pfortune2add));
|
||||||
|
|
@ -102,7 +101,7 @@ for (i = 0, ++n; i < n; ++i)
|
||||||
ptr += 10;
|
ptr += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
UClientImage_Base::wbuffer->size_adjust(ptr - s);
|
UClientImage_Base::wbuffer->size_adjust(ptr);
|
||||||
|
|
||||||
pvfortune->clear();
|
pvfortune->clear();
|
||||||
--></table></body></html>
|
--></table></body></html>
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ int i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
(void) UClientImage_Base::wbuffer->reserve(36U * num_queries);
|
(void) UClientImage_Base::wbuffer->reserve(36U * num_queries);
|
||||||
|
|
||||||
char* s = UClientImage_Base::wbuffer->data();
|
|
||||||
char* ptr = UClientImage_Base::wbuffer->pend();
|
char* ptr = UClientImage_Base::wbuffer->pend();
|
||||||
|
|
||||||
*ptr++ = '[';
|
*ptr++ = '[';
|
||||||
|
|
@ -113,7 +112,7 @@ while (true)
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
*ptr++ = ']';
|
*ptr++ = ']';
|
||||||
|
|
||||||
UClientImage_Base::wbuffer->size_adjust(ptr - s);
|
UClientImage_Base::wbuffer->size_adjust(ptr);
|
||||||
#else
|
#else
|
||||||
USP_OBJ_JSON_stringify(*pvworld_query);
|
USP_OBJ_JSON_stringify(*pvworld_query);
|
||||||
pvworld_query->clear();
|
pvworld_query->clear();
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ int i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
(void) UClientImage_Base::wbuffer->reserve(36U * num_queries);
|
(void) UClientImage_Base::wbuffer->reserve(36U * num_queries);
|
||||||
|
|
||||||
char* s = UClientImage_Base::wbuffer->data();
|
|
||||||
char* ptr = UClientImage_Base::wbuffer->pend();
|
char* ptr = UClientImage_Base::wbuffer->pend();
|
||||||
|
|
||||||
*ptr++ = '[';
|
*ptr++ = '[';
|
||||||
|
|
@ -111,7 +110,7 @@ while (true)
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
*ptr++ = ']';
|
*ptr++ = ']';
|
||||||
|
|
||||||
UClientImage_Base::wbuffer->size_adjust(ptr - s);
|
UClientImage_Base::wbuffer->size_adjust(ptr);
|
||||||
#else
|
#else
|
||||||
USP_OBJ_JSON_stringify(*pvworld_update);
|
USP_OBJ_JSON_stringify(*pvworld_update);
|
||||||
pvworld_update->clear();
|
pvworld_update->clear();
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,6 @@ while (true)
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
(void) UClientImage_Base::wbuffer->reserve(36U * num_queries);
|
(void) UClientImage_Base::wbuffer->reserve(36U * num_queries);
|
||||||
|
|
||||||
char* s = UClientImage_Base::wbuffer->data();
|
|
||||||
char* p = UClientImage_Base::wbuffer->pend();
|
char* p = UClientImage_Base::wbuffer->pend();
|
||||||
|
|
||||||
*p++ = '[';
|
*p++ = '[';
|
||||||
|
|
@ -148,7 +147,7 @@ while (true)
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
*p++ = ']';
|
*p++ = ']';
|
||||||
|
|
||||||
UClientImage_Base::wbuffer->size_adjust(p - s);
|
UClientImage_Base::wbuffer->size_adjust(p);
|
||||||
#else
|
#else
|
||||||
USP_OBJ_JSON_stringify(*pvworld_update);
|
USP_OBJ_JSON_stringify(*pvworld_update);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -5,65 +5,64 @@ TechEmpower Web Framework Benchmarks
|
||||||
<!--#declaration
|
<!--#declaration
|
||||||
#include "fortune.h"
|
#include "fortune.h"
|
||||||
|
|
||||||
static Fortune* pfortune;
|
static Fortune* pfortune;
|
||||||
static Fortune* pfortune2add;
|
static Fortune* pfortune2add;
|
||||||
static UString* pencoded;
|
static UString* pencoded;
|
||||||
static UOrmSession* psql_fortune;
|
static UOrmSession* psql_fortune;
|
||||||
static UOrmStatement* pstmt_fortune;
|
static UOrmStatement* pstmt_fortune;
|
||||||
static UVector<Fortune*>* pvfortune;
|
static UVector<Fortune*>* pvfortune;
|
||||||
|
|
||||||
static void usp_fork_fortune()
|
static void usp_fork_fortune()
|
||||||
{
|
{
|
||||||
U_TRACE(5, "::usp_fork_fortune()")
|
U_TRACE(5, "::usp_fork_fortune()")
|
||||||
|
|
||||||
U_NEW(UOrmSession, psql_fortune, UOrmSession(U_CONSTANT_TO_PARAM("fortune")));
|
U_NEW(UOrmSession, psql_fortune, UOrmSession(U_CONSTANT_TO_PARAM("fortune")));
|
||||||
|
|
||||||
U_INTERNAL_DUMP("psql_fortune = %p", psql_fortune)
|
U_INTERNAL_DUMP("psql_fortune = %p", psql_fortune)
|
||||||
|
|
||||||
if (psql_fortune->isReady() == false)
|
if (psql_fortune->isReady() == false)
|
||||||
{
|
{
|
||||||
U_WARNING("usp_fork_fortune(): we cound't connect to db");
|
U_WARNING("usp_fork_fortune(): we cound't connect to db");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
U_NEW(UOrmStatement, pstmt_fortune, UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
|
U_NEW(UOrmStatement, pstmt_fortune, UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
|
||||||
|
|
||||||
// if (UOrmDriver::isPGSQL()) *psql_fortune << "BEGIN ISOLATION LEVEL SERIALIZABLE; COMMIT";
|
// if (UOrmDriver::isPGSQL()) *psql_fortune << "BEGIN ISOLATION LEVEL SERIALIZABLE; COMMIT";
|
||||||
|
|
||||||
U_NEW(Fortune, pfortune, Fortune);
|
U_NEW(Fortune, pfortune, Fortune);
|
||||||
|
|
||||||
pstmt_fortune->into(*pfortune);
|
pstmt_fortune->into(*pfortune);
|
||||||
|
|
||||||
U_NEW(UString, pencoded, UString(100U));
|
U_NEW(UString, pencoded, UString(100U));
|
||||||
U_NEW(UVector<Fortune*>, pvfortune, UVector<Fortune*>);
|
U_NEW(UVector<Fortune*>, pvfortune, UVector<Fortune*>);
|
||||||
U_NEW(Fortune, pfortune2add, Fortune(0, U_STRING_FROM_CONSTANT("Additional fortune added at request time.")));
|
U_NEW(Fortune, pfortune2add, Fortune(0, U_STRING_FROM_CONSTANT("Additional fortune added at request time.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static void usp_end_fortune()
|
static void usp_end_fortune()
|
||||||
{
|
{
|
||||||
U_TRACE(5, "::usp_end_fortune()")
|
U_TRACE(5, "::usp_end_fortune()")
|
||||||
|
|
||||||
U_INTERNAL_DUMP("psql_fortune = %p", psql_fortune)
|
U_INTERNAL_DUMP("psql_fortune = %p", psql_fortune)
|
||||||
|
|
||||||
delete psql_fortune;
|
delete psql_fortune;
|
||||||
|
|
||||||
if (pstmt_fortune)
|
if (pstmt_fortune)
|
||||||
{
|
{
|
||||||
delete pstmt_fortune;
|
delete pstmt_fortune;
|
||||||
delete pfortune;
|
delete pfortune;
|
||||||
delete pencoded;
|
delete pencoded;
|
||||||
delete pvfortune;
|
delete pvfortune;
|
||||||
delete pfortune2add;
|
delete pfortune2add;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
-->
|
-->
|
||||||
<!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr><!--#code
|
<!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr><!--#code
|
||||||
uint32_t sz;
|
uint32_t sz;
|
||||||
Fortune* item;
|
Fortune* item;
|
||||||
char* s = UClientImage_Base::wbuffer->data();
|
|
||||||
char* ptr = UClientImage_Base::wbuffer->pend();
|
char* ptr = UClientImage_Base::wbuffer->pend();
|
||||||
|
|
||||||
U_NEW(Fortune, item, Fortune(*pfortune2add));
|
U_NEW(Fortune, item, Fortune(*pfortune2add));
|
||||||
|
|
@ -72,41 +71,41 @@ pvfortune->push_back(item);
|
||||||
|
|
||||||
pstmt_fortune->execute();
|
pstmt_fortune->execute();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
U_NEW(Fortune, item, Fortune(*pfortune));
|
U_NEW(Fortune, item, Fortune(*pfortune));
|
||||||
|
|
||||||
pvfortune->push_back(item);
|
pvfortune->push_back(item);
|
||||||
}
|
}
|
||||||
while (pstmt_fortune->nextRow());
|
while (pstmt_fortune->nextRow());
|
||||||
|
|
||||||
pvfortune->sort(Fortune::cmp_obj);
|
pvfortune->sort(Fortune::cmp_obj);
|
||||||
|
|
||||||
for (uint32_t i = 0, n = pvfortune->size(); i < n; ++i)
|
for (uint32_t i = 0, n = pvfortune->size(); i < n; ++i)
|
||||||
{
|
{
|
||||||
Fortune* elem = (*pvfortune)[i];
|
Fortune* elem = (*pvfortune)[i];
|
||||||
|
|
||||||
UXMLEscape::encode(elem->message, *pencoded);
|
UXMLEscape::encode(elem->message, *pencoded);
|
||||||
|
|
||||||
sz = pencoded->size();
|
sz = pencoded->size();
|
||||||
|
|
||||||
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','t','r','>','<','t','d','>'));
|
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','t','r','>','<','t','d','>'));
|
||||||
|
|
||||||
ptr = u_num2str32(elem->id, ptr+8);
|
ptr = u_num2str32(elem->id, ptr+8);
|
||||||
|
|
||||||
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','t','d'));
|
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','t','d'));
|
||||||
ptr += 8;
|
ptr += 8;
|
||||||
|
|
||||||
*ptr++ = '>';
|
*ptr++ = '>';
|
||||||
|
|
||||||
(void) memcpy(ptr, pencoded->data(), sz);
|
(void) memcpy(ptr, pencoded->data(), sz);
|
||||||
ptr += sz;
|
ptr += sz;
|
||||||
|
|
||||||
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t'));
|
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t'));
|
||||||
u_put_unalignedp16(ptr+8, U_MULTICHAR_CONSTANT16('r','>'));
|
u_put_unalignedp16(ptr+8, U_MULTICHAR_CONSTANT16('r','>'));
|
||||||
ptr += 10;
|
ptr += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
UClientImage_Base::wbuffer->size_adjust(ptr - s);
|
UClientImage_Base::wbuffer->size_adjust(ptr);
|
||||||
|
|
||||||
pvfortune->clear();
|
pvfortune->clear();
|
||||||
--></table></body></html>
|
--></table></body></html>
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ UString result;
|
||||||
(void) U_JFIND(mc->vitem[0], "randomNumber", result);
|
(void) U_JFIND(mc->vitem[0], "randomNumber", result);
|
||||||
|
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
char* s = UClientImage_Base::wbuffer->data();
|
|
||||||
char* ptr = UClientImage_Base::wbuffer->pend();
|
char* ptr = UClientImage_Base::wbuffer->pend();
|
||||||
uint32_t sz = result.size();
|
uint32_t sz = result.size();
|
||||||
|
|
||||||
|
|
@ -72,7 +71,7 @@ u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'
|
||||||
|
|
||||||
*ptr++ = '}';
|
*ptr++ = '}';
|
||||||
|
|
||||||
UClientImage_Base::wbuffer->size_adjust(ptr - s);
|
UClientImage_Base::wbuffer->size_adjust(ptr);
|
||||||
#else
|
#else
|
||||||
World world(id, result.strtoul());
|
World world(id, result.strtoul());
|
||||||
USP_OBJ_JSON_stringify(world);
|
USP_OBJ_JSON_stringify(world);
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ static void usp_end_mfortune()
|
||||||
Fortune* item;
|
Fortune* item;
|
||||||
UString result;
|
UString result;
|
||||||
uint32_t i, n, sz;
|
uint32_t i, n, sz;
|
||||||
char* s = UClientImage_Base::wbuffer->data();
|
|
||||||
char* ptr = UClientImage_Base::wbuffer->pend();
|
char* ptr = UClientImage_Base::wbuffer->pend();
|
||||||
|
|
||||||
U_NEW(Fortune, item, Fortune(*pfortune2add));
|
U_NEW(Fortune, item, Fortune(*pfortune2add));
|
||||||
|
|
@ -102,7 +101,7 @@ for (i = 0, ++n; i < n; ++i)
|
||||||
ptr += 10;
|
ptr += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
UClientImage_Base::wbuffer->size_adjust(ptr - s);
|
UClientImage_Base::wbuffer->size_adjust(ptr);
|
||||||
|
|
||||||
pvfortune->clear();
|
pvfortune->clear();
|
||||||
--></table></body></html>
|
--></table></body></html>
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ int i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
(void) UClientImage_Base::wbuffer->reserve(36U * num_queries);
|
(void) UClientImage_Base::wbuffer->reserve(36U * num_queries);
|
||||||
|
|
||||||
char* s = UClientImage_Base::wbuffer->data();
|
|
||||||
char* ptr = UClientImage_Base::wbuffer->pend();
|
char* ptr = UClientImage_Base::wbuffer->pend();
|
||||||
|
|
||||||
*ptr++ = '[';
|
*ptr++ = '[';
|
||||||
|
|
@ -113,7 +112,7 @@ while (true)
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
*ptr++ = ']';
|
*ptr++ = ']';
|
||||||
|
|
||||||
UClientImage_Base::wbuffer->size_adjust(ptr - s);
|
UClientImage_Base::wbuffer->size_adjust(ptr);
|
||||||
#else
|
#else
|
||||||
USP_OBJ_JSON_stringify(*pvworld_query);
|
USP_OBJ_JSON_stringify(*pvworld_query);
|
||||||
pvworld_query->clear();
|
pvworld_query->clear();
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ int i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
(void) UClientImage_Base::wbuffer->reserve(36U * num_queries);
|
(void) UClientImage_Base::wbuffer->reserve(36U * num_queries);
|
||||||
|
|
||||||
char* s = UClientImage_Base::wbuffer->data();
|
|
||||||
char* ptr = UClientImage_Base::wbuffer->pend();
|
char* ptr = UClientImage_Base::wbuffer->pend();
|
||||||
|
|
||||||
*ptr++ = '[';
|
*ptr++ = '[';
|
||||||
|
|
@ -111,7 +110,7 @@ while (true)
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
*ptr++ = ']';
|
*ptr++ = ']';
|
||||||
|
|
||||||
UClientImage_Base::wbuffer->size_adjust(ptr - s);
|
UClientImage_Base::wbuffer->size_adjust(ptr);
|
||||||
#else
|
#else
|
||||||
USP_OBJ_JSON_stringify(*pvworld_update);
|
USP_OBJ_JSON_stringify(*pvworld_update);
|
||||||
pvworld_update->clear();
|
pvworld_update->clear();
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,6 @@ while (true)
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
(void) UClientImage_Base::wbuffer->reserve(36U * num_queries);
|
(void) UClientImage_Base::wbuffer->reserve(36U * num_queries);
|
||||||
|
|
||||||
char* s = UClientImage_Base::wbuffer->data();
|
|
||||||
char* p = UClientImage_Base::wbuffer->pend();
|
char* p = UClientImage_Base::wbuffer->pend();
|
||||||
|
|
||||||
*p++ = '[';
|
*p++ = '[';
|
||||||
|
|
@ -148,7 +147,7 @@ while (true)
|
||||||
#ifdef AS_cpoll_cppsp_DO
|
#ifdef AS_cpoll_cppsp_DO
|
||||||
*p++ = ']';
|
*p++ = ']';
|
||||||
|
|
||||||
UClientImage_Base::wbuffer->size_adjust(p - s);
|
UClientImage_Base::wbuffer->size_adjust(p);
|
||||||
#else
|
#else
|
||||||
USP_OBJ_JSON_stringify(*pvworld_update);
|
USP_OBJ_JSON_stringify(*pvworld_update);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user