fix pause_timer
This commit is contained in:
@@ -211,8 +211,10 @@ public:
|
||||
PICOBENCH_INLINE
|
||||
void pause_timer()
|
||||
{
|
||||
auto duration = high_res_clock::now() - _start;
|
||||
_duration_ns += std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count();
|
||||
if (!_pause) {
|
||||
auto duration = high_res_clock::now() - _start;
|
||||
_duration_ns += std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count();
|
||||
}
|
||||
_pause = true;
|
||||
}
|
||||
|
||||
|
||||
37
src/sled/uri_bench.cc
Normal file
37
src/sled/uri_bench.cc
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <sled/log/log.h>
|
||||
#include <sled/uri.h>
|
||||
|
||||
std::string
|
||||
GenerateURI(int length)
|
||||
{
|
||||
std::string uri = "http://host";
|
||||
// add host
|
||||
for (int i = 0; i < length; i++) { uri.append("host"); }
|
||||
for (int i = 0; i < length; i++) { uri.append("/path"); }
|
||||
if (length > 0) { uri.append("?"); }
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (i) { uri.append("&"); }
|
||||
uri.append("key" + std::to_string(i) + "=value");
|
||||
}
|
||||
|
||||
uri.append("#fragment");
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
void
|
||||
ParseURI(picobench::state &s)
|
||||
{
|
||||
// int length = 0;
|
||||
for (auto _ : s) {
|
||||
s.pause_timer();
|
||||
auto uri_str = GenerateURI(10);
|
||||
s.resume_timer();
|
||||
auto uri_or = sled::URI::ParseURI(uri_str);
|
||||
s.pause_timer();
|
||||
SLED_ASSERT(uri_or.ok() == true, "");
|
||||
SLED_ASSERT(uri_or.value().href() == uri_str, "{} != {}", uri_or.value().href(), uri_str);
|
||||
}
|
||||
}
|
||||
|
||||
PICOBENCH(ParseURI);
|
||||
Reference in New Issue
Block a user