Merge pull request #764 from satherton/cleanup-status-refactor
Status refactor cleanup
This commit is contained in:
commit
700d558e5a
|
@ -1,4 +1,4 @@
|
|||
#include "JsonString.h"
|
||||
#include "JsonBuilder.h"
|
||||
#include <iostream>
|
||||
|
||||
JsonBuilderObject JsonBuilder::makeMessage(const char *name, const char *description) {
|
|
@ -259,11 +259,11 @@ public:
|
|||
write('[');
|
||||
}
|
||||
|
||||
template<typename VT> inline JsonBuilderArray & push_back(VT &&val) {
|
||||
template<typename VT> inline JsonBuilderArray & push_back(const VT &val) {
|
||||
if(elements++ > 0) {
|
||||
write(',');
|
||||
}
|
||||
writeValue(std::forward<VT>(val));
|
||||
writeValue(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -287,18 +287,18 @@ public:
|
|||
write('{');
|
||||
}
|
||||
|
||||
template<typename KT, typename VT> inline JsonBuilderObject & setKey(KT &&name, VT &&val) {
|
||||
template<typename KT, typename VT> inline JsonBuilderObject & setKey(const KT &name, const VT &val) {
|
||||
if(elements++ > 0) {
|
||||
write(',');
|
||||
}
|
||||
write('"');
|
||||
write(name);
|
||||
write("\":");
|
||||
writeValue(std::forward<VT>(val));
|
||||
writeValue(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename KT, typename VT> inline JsonBuilderObject & setKeyRawNumber(KT &&name, VT &&val) {
|
||||
template<typename KT, typename VT> inline JsonBuilderObject & setKeyRawNumber(const KT &name, const VT &val) {
|
||||
if(elements++ > 0) {
|
||||
write(',');
|
||||
}
|
||||
|
@ -332,8 +332,8 @@ public:
|
|||
JsonBuilderObjectSetter(JsonBuilderObject &dest, KT &&name) : dest(dest), name(std::forward<KT>(name)) {}
|
||||
|
||||
// Value is accepted as an rvalue if possible
|
||||
template <class VT> inline void operator=(VT &&value) {
|
||||
dest.setKey(name, std::forward<VT>(value));
|
||||
template <class VT> inline void operator=(const VT &value) {
|
||||
dest.setKey(name, value);
|
||||
}
|
||||
|
||||
protected:
|
|
@ -81,7 +81,7 @@
|
|||
<ClInclude Include="WriteMap.h" />
|
||||
<ClInclude Include="Subspace.h" />
|
||||
<ClInclude Include="Tuple.h" />
|
||||
<ClInclude Include="JsonString.h" />
|
||||
<ClInclude Include="JsonBuilder.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ActorCompiler Include="FailureMonitorClient.actor.cpp" />
|
||||
|
@ -105,7 +105,7 @@
|
|||
<ActorCompiler Include="TaskBucket.actor.cpp" />
|
||||
<ClCompile Include="Subspace.cpp" />
|
||||
<ClCompile Include="Tuple.cpp" />
|
||||
<ClCompile Include="JsonString.cpp" />
|
||||
<ClCompile Include="JsonBuilder.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGUID>{E2939DAA-238E-4970-96C4-4C57980F93BD}</ProjectGUID>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "flow/UnitTest.h"
|
||||
#include "QuietDatabase.h"
|
||||
#include "RecoveryState.h"
|
||||
#include "fdbclient/JsonString.h"
|
||||
#include "fdbclient/JsonBuilder.h"
|
||||
|
||||
const char* RecoveryStatus::names[] = {
|
||||
"reading_coordinated_state", "locking_coordinated_state", "locking_old_transaction_servers", "reading_transaction_system_state",
|
||||
|
@ -2135,18 +2135,37 @@ TEST_CASE("status/json/builderPerf") {
|
|||
|
||||
int64_t bytes = 0;
|
||||
double generated = 0;
|
||||
double serialized = 0;
|
||||
for(int i = 0; i < iterations; i++) {
|
||||
int n = elements;
|
||||
double gstart = timer();
|
||||
JsonBuilderObject obj = randomDocument(strings, n, level);
|
||||
generated += (timer() - gstart);
|
||||
double start;
|
||||
|
||||
start = timer();
|
||||
JsonBuilderObject obj = randomDocument(strings, n, level);
|
||||
double generate = timer() - start;
|
||||
|
||||
start = timer();
|
||||
std::string s = obj.getJson();
|
||||
double serialize = timer() - start;
|
||||
|
||||
start = timer();
|
||||
json_spirit::mValue mv = readJSONStrictly(s);
|
||||
double jsParse = timer() - start;
|
||||
|
||||
start = timer();
|
||||
std::string jsStr = json_spirit::write_string(mv);
|
||||
double jsSerialize = timer() - start;
|
||||
|
||||
printf("JsonBuilder: %8lu bytes %-7.5f gen + %-7.5f serialize = %-7.5f\n", s.size(), generate, serialize, generate + serialize);
|
||||
printf("json_spirit: %8lu bytes %-7.5f parse + %-7.5f serialize = %-7.5f\n", jsStr.size(), jsParse, jsSerialize, jsParse + jsSerialize);
|
||||
printf("\n");
|
||||
|
||||
generated += generate;
|
||||
serialized += serialize;
|
||||
bytes += s.size();
|
||||
}
|
||||
double end = timer();
|
||||
|
||||
double elapsed = end - start;
|
||||
double elapsed = generated + serialized;
|
||||
printf("RESULT: %lld bytes %d elements %d levels %f seconds (%f gen, %f serialize) %f MB/s %f items/s\n",
|
||||
bytes, iterations*elements, level, elapsed, generated, elapsed - generated, bytes / elapsed / 1e6, iterations*elements / elapsed);
|
||||
|
||||
|
|
Loading…
Reference in New Issue