1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-10-05 19:18:01 +08:00
This commit is contained in:
stefanocasazza 2016-05-13 19:27:34 +02:00
parent 14c5da6b18
commit be68eeb09c
5 changed files with 43 additions and 37 deletions

View File

@ -267,7 +267,7 @@ public:
// OPERATOR
bool operator==(const UValue& v) const;
bool operator==(const UValue& v) const __pure;
bool operator!=(const UValue& v) const { return ! operator==(v); }
// SERVICES

View File

@ -252,7 +252,7 @@ void UValue::set(const UValue& v)
U_ASSERT(invariant())
}
bool UValue::operator==(const UValue& v) const
__pure bool UValue::operator==(const UValue& v) const
{
U_TRACE(0+256, "UValue::operator==(%p)", &v)

View File

@ -95,6 +95,8 @@ while (true)
#ifdef AS_cpoll_cppsp_DO
USP_PUTS_CHAR(',');
#endif
rnumber.clear();
}
#ifdef AS_cpoll_cppsp_DO

View File

@ -11,7 +11,7 @@ static World* pworld_query;
static UElasticSearchClient* es;
#ifndef AS_cpoll_cppsp_DO
static UValue* pvalue;
static UValue* pvalue;
static UVector<World*>* pvworld_query;
#endif
@ -19,45 +19,45 @@ static UVector<World*>* pvworld_query;
static void usp_fork_equery()
{
U_TRACE(5, "::usp_fork_equery()")
U_TRACE(5, "::usp_fork_equery()")
U_NEW(UElasticSearchClient, es, UElasticSearchClient);
if (es->connect() == false)
{
U_WARNING("usp_fork_equery(): connection disabled or failed");
if (es->connect() == false)
{
U_WARNING("usp_fork_equery(): connection disabled or failed");
return;
}
return;
}
U_NEW(World, pworld_query, World);
U_NEW(UString, jquery, U_STRING_FROM_CONSTANT("randomNumber"));
U_NEW(World, pworld_query, World);
U_NEW(UString, jquery, U_STRING_FROM_CONSTANT("randomNumber"));
#ifndef AS_cpoll_cppsp_DO
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
#endif
u__memcpy(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
u__memcpy(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
}
#ifdef DEBUG
static void usp_end_equery()
{
U_TRACE(5, "::usp_end_equery()")
U_TRACE(5, "::usp_end_equery()")
delete es;
delete es;
if (jquery)
{
delete jquery;
delete pworld_query;
if (jquery)
{
delete jquery;
delete pworld_query;
# ifndef AS_cpoll_cppsp_DO
delete pvalue;
delete pvworld_query;
# endif
}
# ifndef AS_cpoll_cppsp_DO
delete pvalue;
delete pvworld_query;
# endif
}
}
#endif
-->
@ -73,29 +73,31 @@ USP_PUTS_CHAR('[');
#endif
while (true)
{
(void) es->sendPOST(U_CONSTANT_TO_PARAM("/tfb/world/_search"), buffer, QLEN+u__snprintf(buffer+QLEN, 128, "%u\"}}}", pworld_query->id = u_get_num_random(10000-1)));
{
(void) es->sendPOST(U_CONSTANT_TO_PARAM("/tfb/world/_search"), buffer, QLEN+u__snprintf(buffer+QLEN, 128, "%u\"}}}", pworld_query->id = u_get_num_random(10000-1)));
(void) UValue::jfind(es->getContent(), *jquery, rnumber);
(void) UValue::jfind(es->getContent(), *jquery, rnumber);
#ifdef AS_cpoll_cppsp_DO
USP_PRINTF("{\"id\":%u,\"randomNumber\":%v}", pworld_query->id, rnumber.rep);
USP_PRINTF("{\"id\":%u,\"randomNumber\":%v}", pworld_query->id, rnumber.rep);
#else
pworld_query->randomNumber = u_strtoul(rnumber.data(), rnumber.end());
pworld_query->randomNumber = u_strtoul(rnumber.data(), rnumber.end());
World* pworld;
World* pworld;
U_NEW(World, pworld, World(*pworld_query));
U_NEW(World, pworld, World(*pworld_query));
pvworld_query->push_back(pworld);
pvworld_query->push_back(pworld);
#endif
if (++i == num_queries) break;
if (++i == num_queries) break;
#ifdef AS_cpoll_cppsp_DO
USP_PUTS_CHAR(',');
USP_PUTS_CHAR(',');
#endif
}
rnumber.clear();
}
#ifdef AS_cpoll_cppsp_DO
USP_PUTS_CHAR(']');

View File

@ -98,7 +98,8 @@ make install
# 3. Compile usp pages for benchmark (no more REDIS)
cd ../../src/ulib/net/server/plugin/usp
make json.la plaintext.la db.la query.la update.la fortune.la \
make json.la plaintext.la edb.la equery.la eupdate.la \
db.la query.la update.la fortune.la \
mdb.la mquery.la mupdate.la mfortune.la
# rdb.la rquery.la rupdate.la rfortune.la
@ -109,6 +110,7 @@ fi
mkdir -p $ULIB_DOCUMENT_ROOT
cp .libs/json.so .libs/plaintext.so \
.libs/edb.so .libs/equery.so .libs/eupdate.so \
.libs/db.so .libs/query.so .libs/update.so .libs/fortune.so \
.libs/mdb.so .libs/mquery.so .libs/mupdate.so .libs/mfortune.so $ULIB_DOCUMENT_ROOT
# .libs/rdb.so .libs/rquery.so .libs/rupdate.so .libs/rfortune.so \