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