Adding stringify.

This commit is contained in:
Daniel Lemire 2018-04-26 20:47:33 -04:00
parent fd56854c3f
commit 5ccd5f6b4e
2 changed files with 14 additions and 1 deletions

View File

@ -13,6 +13,15 @@
using namespace rapidjson;
using namespace std;
std::string rapidstringme(char * json) {
Document d;
d.Parse(json);
StringBuffer buffer;
Writer<StringBuffer> writer(buffer);
d.Accept(writer);
return buffer.GetString();
}
int main(int argc, char *argv[]) {
if (argc < 2) {
cerr << "Usage: " << argv[0] << " <jsonfile>\n";
@ -75,4 +84,8 @@ int main(int argc, char *argv[]) {
memcpy(buffer, p.first, p.second), repeat, volume, true);
BEST_TIME(d.ParseInsitu(buffer).HasParseError(), false,
memcpy(buffer, p.first, p.second), repeat, volume, true);
size_t strlength = rapidstringme((char*) p.first).size();
std::cout << "input length is "<< p.second << " stringified length is " << strlength << std::endl;
BEST_TIME_NOCHECK(rapidstringme((char*) p.first), , repeat, volume,
true);
}

View File

@ -83,7 +83,7 @@ uint64_t global_rdtsc_overhead = (uint64_t)UINT64_MAX;
RDTSC_SET_OVERHEAD(rdtsc_overhead_func(1), repeat); \
} \
if (verbose) \
printf("%-60s\t: ", #test); \
printf("%-40s\t: ", #test); \
fflush(NULL); \
uint64_t cycles_start, cycles_final, cycles_diff; \
uint64_t min_diff = (uint64_t)-1; \