|
@@ -1,64 +1,70 @@
|
|
|
+<!--#
|
|
|
+Test type 5: Database updates
|
|
|
+TechEmpower Web Framework Benchmarks
|
|
|
+-->
|
|
|
<!--#declaration
|
|
|
#include "world.h"
|
|
|
|
|
|
-#ifndef AS_cpoll_cppsp_DO
|
|
|
-static UValue* pvalue;
|
|
|
-#endif
|
|
|
-static UOrmSession* psql_update;
|
|
|
-static UOrmStatement* pstmt1;
|
|
|
-static UOrmStatement* pstmt2;
|
|
|
-static World* pworld_update;
|
|
|
+static World* pworld_update;
|
|
|
+static UOrmSession* psql_update;
|
|
|
+static UOrmStatement* pstmt1;
|
|
|
+static UOrmStatement* pstmt2;
|
|
|
static UVector<World*>* pvworld_update;
|
|
|
|
|
|
-static void usp_init_update()
|
|
|
-{
|
|
|
- U_TRACE(5, "::usp_init_update()")
|
|
|
-
|
|
|
- pworld_update = U_NEW(World);
|
|
|
- pvworld_update = U_NEW(UVector<World*>(500));
|
|
|
-
|
|
|
#ifndef AS_cpoll_cppsp_DO
|
|
|
- pvalue = U_NEW(UValue(ARRAY_VALUE));
|
|
|
+static UValue* pvalue;
|
|
|
#endif
|
|
|
-}
|
|
|
|
|
|
static void usp_fork_update()
|
|
|
{
|
|
|
- U_TRACE(5, "::usp_fork_update()")
|
|
|
+ U_TRACE(5, "::usp_fork_update()")
|
|
|
+
|
|
|
+ psql_update = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
|
|
|
|
|
|
- psql_update = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
|
|
|
+ if (psql_update->isReady())
|
|
|
+ {
|
|
|
+ pstmt1 = U_NEW(UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
|
|
|
+ pstmt2 = U_NEW(UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = ? WHERE id = ?")));
|
|
|
|
|
|
- if (psql_update->isReady())
|
|
|
- {
|
|
|
- pstmt1 = U_NEW(UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
|
|
|
- pstmt2 = U_NEW(UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = ? WHERE id = ?")));
|
|
|
+ if (pstmt1 == 0 ||
|
|
|
+ pstmt2 == 0)
|
|
|
+ {
|
|
|
+ U_ERROR("usp_fork_update(): we cound't connect to db");
|
|
|
+ }
|
|
|
|
|
|
- if (pstmt1 == 0 ||
|
|
|
- pstmt2 == 0)
|
|
|
- {
|
|
|
- U_ERROR("usp_fork_update(): we cound't connect to db");
|
|
|
- }
|
|
|
+ pworld_update = U_NEW(World);
|
|
|
|
|
|
- pstmt1->use( pworld_update->id);
|
|
|
- pstmt1->into(pworld_update->randomNumber);
|
|
|
- pstmt2->use( pworld_update->randomNumber, pworld_update->id);
|
|
|
- }
|
|
|
+ pstmt1->use( pworld_update->id);
|
|
|
+ pstmt1->into(pworld_update->randomNumber);
|
|
|
+ pstmt2->use( pworld_update->randomNumber, pworld_update->id);
|
|
|
+
|
|
|
+ pvworld_update = U_NEW(UVector<World*>(500));
|
|
|
+
|
|
|
+# ifndef AS_cpoll_cppsp_DO
|
|
|
+ pvalue = U_NEW(UValue(ARRAY_VALUE));
|
|
|
+# endif
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
static void usp_end_update()
|
|
|
{
|
|
|
- U_TRACE(5, "::usp_end_update()")
|
|
|
-
|
|
|
- if (pstmt1) delete pstmt1;
|
|
|
- if (pstmt2) delete pstmt2;
|
|
|
-
|
|
|
- delete psql_update;
|
|
|
- delete pvworld_update;
|
|
|
- delete pworld_update;
|
|
|
-#ifndef AS_cpoll_cppsp_DO
|
|
|
- delete pvalue;
|
|
|
-#endif
|
|
|
+ U_TRACE(5, "::usp_end_update()")
|
|
|
+
|
|
|
+ if (pstmt1 &&
|
|
|
+ pstmt2)
|
|
|
+ {
|
|
|
+ delete pstmt1;
|
|
|
+ delete pstmt2;
|
|
|
+
|
|
|
+ delete psql_update;
|
|
|
+ delete pvworld_update;
|
|
|
+ delete pworld_update;
|
|
|
+
|
|
|
+# ifndef AS_cpoll_cppsp_DO
|
|
|
+ delete pvalue;
|
|
|
+# endif
|
|
|
+ }
|
|
|
}
|
|
|
#endif
|
|
|
-->
|
|
@@ -71,7 +77,7 @@ Content-Type: application/json; charset=UTF-8
|
|
|
<!--#code
|
|
|
int i = 0, num_queries = queries.strtol();
|
|
|
|
|
|
- if (num_queries < 1) num_queries = 1;
|
|
|
+ if (num_queries < 1) num_queries = 1;
|
|
|
else if (num_queries > 500) num_queries = 500;
|
|
|
|
|
|
#ifdef AS_cpoll_cppsp_DO
|
|
@@ -79,29 +85,27 @@ USP_PUTS_CHAR('[');
|
|
|
#endif
|
|
|
|
|
|
while (true)
|
|
|
- {
|
|
|
- pworld_update->id = u_get_num_random(10000);
|
|
|
-
|
|
|
- pstmt1->execute();
|
|
|
+ {
|
|
|
+ pworld_update->id = u_get_num_random(10000);
|
|
|
|
|
|
- U_INTERNAL_DUMP("pworld_update->randomNumber = %u", pworld_update->randomNumber)
|
|
|
+ pstmt1->execute();
|
|
|
|
|
|
- pworld_update->randomNumber = u_get_num_random(10000);
|
|
|
+ pworld_update->randomNumber = u_get_num_random(10000);
|
|
|
|
|
|
- pstmt2->execute();
|
|
|
+ pstmt2->execute();
|
|
|
|
|
|
#ifdef AS_cpoll_cppsp_DO
|
|
|
- USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", pworld_update->id, pworld_update->randomNumber);
|
|
|
+ USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", pworld_update->id, pworld_update->randomNumber);
|
|
|
#endif
|
|
|
|
|
|
- pvworld_update->push_back(U_NEW(World(*pworld_update)));
|
|
|
+ pvworld_update->push_back(U_NEW(World(*pworld_update)));
|
|
|
|
|
|
- if (++i == num_queries) break;
|
|
|
+ if (++i == num_queries) break;
|
|
|
|
|
|
#ifdef AS_cpoll_cppsp_DO
|
|
|
- USP_PUTS_CHAR(',');
|
|
|
+ USP_PUTS_CHAR(',');
|
|
|
#endif
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
#ifdef AS_cpoll_cppsp_DO
|
|
|
USP_PUTS_CHAR(']');
|