|
@@ -5,65 +5,60 @@ 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 UOrmStatement* pstmt_fortune;
|
|
|
|
|
|
+static UOrmSession* psql_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)
|
|
|
|
|
|
+ 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
|
|
#ifdef DEBUG
|
|
static void usp_end_fortune()
|
|
static void usp_end_fortune()
|
|
{
|
|
{
|
|
- U_TRACE(5, "::usp_end_fortune()")
|
|
|
|
-
|
|
|
|
- U_INTERNAL_DUMP("psql_fortune = %p", psql_fortune)
|
|
|
|
-
|
|
|
|
- delete psql_fortune;
|
|
|
|
-
|
|
|
|
- if (pstmt_fortune)
|
|
|
|
- {
|
|
|
|
- delete pstmt_fortune;
|
|
|
|
- delete pfortune;
|
|
|
|
- delete pencoded;
|
|
|
|
- delete pvfortune;
|
|
|
|
- delete pfortune2add;
|
|
|
|
- }
|
|
|
|
|
|
+ U_TRACE(5, "::usp_end_fortune()")
|
|
|
|
+
|
|
|
|
+ if (pstmt_fortune)
|
|
|
|
+ {
|
|
|
|
+ delete pstmt_fortune;
|
|
|
|
+ delete pfortune;
|
|
|
|
+ delete pencoded;
|
|
|
|
+ delete pvfortune;
|
|
|
|
+ delete pfortune2add;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ delete psql_fortune;
|
|
}
|
|
}
|
|
#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 +67,41 @@ pvfortune->push_back(item);
|
|
|
|
|
|
pstmt_fortune->execute();
|
|
pstmt_fortune->execute();
|
|
|
|
|
|
-do {
|
|
|
|
- U_NEW(Fortune, item, Fortune(*pfortune));
|
|
|
|
|
|
+do {
|
|
|
|
+ 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'));
|
|
|
|
- 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();
|
|
pvfortune->clear();
|
|
--></table></body></html>
|
|
--></table></body></html>
|