Adding more benchmarks.

This commit is contained in:
Daniel Lemire 2018-05-08 12:37:21 -04:00
parent 5835b77a00
commit 3c46aa47ce
1 changed files with 20 additions and 0 deletions

View File

@ -15,9 +15,27 @@
using namespace rapidjson; using namespace rapidjson;
using namespace std; using namespace std;
std::string rapidstringmeInsitu(char * json) {
Document d;
d.ParseInsitu(json);
if(d.HasParseError()) {
std::cerr << "problem!" << std::endl;
return "";// should do something
}
StringBuffer buffer;
Writer<StringBuffer> writer(buffer);
d.Accept(writer);
return buffer.GetString();
}
std::string rapidstringme(char * json) { std::string rapidstringme(char * json) {
Document d; Document d;
d.Parse(json); d.Parse(json);
if(d.HasParseError()) {
std::cerr << "problem!" << std::endl;
return "";// should do something
}
StringBuffer buffer; StringBuffer buffer;
Writer<StringBuffer> writer(buffer); Writer<StringBuffer> writer(buffer);
d.Accept(writer); d.Accept(writer);
@ -92,5 +110,7 @@ int main(int argc, char *argv[]) {
std::cout << "input length is "<< p.second << " stringified length is " << strlength << std::endl; std::cout << "input length is "<< p.second << " stringified length is " << strlength << std::endl;
BEST_TIME_NOCHECK(rapidstringme((char*) p.first), , repeat, volume, BEST_TIME_NOCHECK(rapidstringme((char*) p.first), , repeat, volume,
true); true);
BEST_TIME_NOCHECK(rapidstringmeInsitu((char*) buffer), memcpy(buffer, p.first, p.second) , repeat, volume,
true);
free(buffer); free(buffer);
} }