|
@@ -0,0 +1,122 @@
|
|
|
|
+<!--#
|
|
|
|
+Test type 5: Database updates
|
|
|
|
+TechEmpower Web Framework Benchmarks
|
|
|
|
+-->
|
|
|
|
+<!--#declaration
|
|
|
|
+#include "world.h"
|
|
|
|
+
|
|
|
|
+static UREDISClient_Base* rc;
|
|
|
|
+static UVector<World*>* pvworld;
|
|
|
|
+
|
|
|
|
+#ifndef AS_cpoll_cppsp_DO
|
|
|
|
+static UValue* pvalue;
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+static void usp_fork_rupdate()
|
|
|
|
+{
|
|
|
|
+ U_TRACE(5, "::usp_fork_rupdate()")
|
|
|
|
+
|
|
|
|
+ rc = U_NEW(UREDISClient<UTCPSocket>);
|
|
|
|
+
|
|
|
|
+ if (rc->connect() == false)
|
|
|
|
+ {
|
|
|
|
+ U_WARNING("usp_fork_rupdate(): %V", rc->UClient_Base::getResponse().rep);
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pvworld = U_NEW(UVector<World*>(500));
|
|
|
|
+
|
|
|
|
+#ifndef AS_cpoll_cppsp_DO
|
|
|
|
+ pvalue = U_NEW(UValue(ARRAY_VALUE));
|
|
|
|
+#endif
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#ifdef DEBUG
|
|
|
|
+static void usp_end_rupdate()
|
|
|
|
+{
|
|
|
|
+ U_TRACE(5, "::usp_end_rupdate()")
|
|
|
|
+
|
|
|
|
+ delete rc;
|
|
|
|
+
|
|
|
|
+ if (pvworld)
|
|
|
|
+ {
|
|
|
|
+ delete pvworld;
|
|
|
|
+
|
|
|
|
+# ifndef AS_cpoll_cppsp_DO
|
|
|
|
+ delete pvalue;
|
|
|
|
+# endif
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
+-->
|
|
|
|
+<!--#args
|
|
|
|
+queries;
|
|
|
|
+-->
|
|
|
|
+<!--#header
|
|
|
|
+Content-Type: application/json; charset=UTF-8
|
|
|
|
+-->
|
|
|
|
+<!--#code
|
|
|
|
+World* pworld;
|
|
|
|
+int i, num_queries;
|
|
|
|
+char* pbuffer = u_buffer;
|
|
|
|
+const char* ptr = queries.data();
|
|
|
|
+
|
|
|
|
+if (u__isdigit(*ptr) == false) num_queries = 1;
|
|
|
|
+else
|
|
|
|
+ {
|
|
|
|
+ num_queries = u_strtoul(ptr, queries.end());
|
|
|
|
+
|
|
|
|
+ if (num_queries < 1) num_queries = 1;
|
|
|
|
+ else if (num_queries > 500) num_queries = 500;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+#ifdef AS_cpoll_cppsp_DO
|
|
|
|
+USP_PUTS_CHAR('[');
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+for (i = 0; i < num_queries; ++i)
|
|
|
|
+ {
|
|
|
|
+ pvworld->push_back(pworld = U_NEW(World));
|
|
|
|
+
|
|
|
|
+ u_put_unalignedp64(pbuffer, U_MULTICHAR_CONSTANT64(' ','w','o','r','l','d',':','\0'));
|
|
|
|
+
|
|
|
|
+ pbuffer += 7+u_num2str32(pbuffer+7, pworld->id = u_get_num_random(10000));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+(void) rc->mget(u_buffer, pbuffer-u_buffer);
|
|
|
|
+
|
|
|
|
+i = 0;
|
|
|
|
+pbuffer = u_buffer;
|
|
|
|
+
|
|
|
|
+while (true)
|
|
|
|
+ {
|
|
|
|
+ pworld = pvworld->at(i);
|
|
|
|
+
|
|
|
|
+ u_put_unalignedp64(pbuffer, U_MULTICHAR_CONSTANT64(' ','w','o','r','l','d',':','\0'));
|
|
|
|
+
|
|
|
|
+ pbuffer += 7+u_num2str32(pbuffer+7, pworld->id);
|
|
|
|
+ *pbuffer = ' ';
|
|
|
|
+ pbuffer += 1+u_num2str32(pbuffer+1, pworld->randomNumber = u_get_num_random(10000));
|
|
|
|
+
|
|
|
|
+#ifdef AS_cpoll_cppsp_DO
|
|
|
|
+ USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", pworld->id, pworld->randomNumber);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ if (++i == num_queries) break;
|
|
|
|
+
|
|
|
|
+#ifdef AS_cpoll_cppsp_DO
|
|
|
|
+ USP_PUTS_CHAR(',');
|
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+(void) rc->mset(u_buffer, pbuffer-u_buffer);
|
|
|
|
+
|
|
|
|
+#ifdef AS_cpoll_cppsp_DO
|
|
|
|
+USP_PUTS_CHAR(']');
|
|
|
|
+#else
|
|
|
|
+USP_JSON_stringify(*pvalue, UVector<World*>, *pvworld);
|
|
|
|
+pvalue->clear();
|
|
|
|
+#endif
|
|
|
|
+pvworld->clear();
|
|
|
|
+-->
|