Fix errors with g++

This commit is contained in:
John Keiser 2020-09-02 10:20:31 -07:00
parent b5c8030f19
commit 045377a594
12 changed files with 35 additions and 23 deletions

View File

@ -110,25 +110,24 @@ struct event_aggregate {
double cache_misses() const { return total.cache_misses() / iterations; }
};
template<bool QUIET = false>
struct event_collector {
event_count count{};
time_point<steady_clock> start_clock{};
#if defined(__linux__)
LinuxEvents<PERF_TYPE_HARDWARE, QUIET> linux_events;
event_collector() : linux_events(vector<int>{
LinuxEvents<PERF_TYPE_HARDWARE> linux_events;
event_collector(bool quiet = false) : linux_events(vector<int>{
PERF_COUNT_HW_CPU_CYCLES,
PERF_COUNT_HW_INSTRUCTIONS,
PERF_COUNT_HW_BRANCH_MISSES,
PERF_COUNT_HW_CACHE_REFERENCES,
PERF_COUNT_HW_CACHE_MISSES
}) {}
}, quiet) {}
bool has_events() {
return linux_events.is_working();
}
#else
event_collector() {}
event_collector(SIMDJSON_UNUSED bool _quiet = false) {}
bool has_events() {
return false;
}

View File

@ -16,8 +16,8 @@ public:
simdjson_really_inline const std::vector<my_point> &Records() { return container; }
private:
dom::parser parser;
std::vector<my_point> container;
dom::parser parser{};
std::vector<my_point> container{};
};
simdjson_really_inline bool Dom::Run(const padded_string &json) {

View File

@ -6,6 +6,7 @@
#include "largerandom.h"
namespace largerandom {
namespace {
using namespace simdjson;
using namespace SIMDJSON_IMPLEMENTATION;
@ -19,8 +20,8 @@ public:
simdjson_really_inline const std::vector<my_point> &Records() { return container; }
private:
ondemand::parser parser;
std::vector<my_point> container;
ondemand::parser parser{};
std::vector<my_point> container{};
simdjson_really_inline double first_double(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &iter) {
if (iter.start_object().error() || iter.field_key().error() || iter.field_value()) { throw "Invalid field"; }
@ -50,6 +51,7 @@ simdjson_really_inline bool Iter::Run(const padded_string &json) {
BENCHMARK_TEMPLATE(LargeRandom, Iter);
}
} // namespace largerandom
#endif // SIMDJSON_EXCEPTIONS

View File

@ -6,6 +6,7 @@
#include "largerandom.h"
namespace largerandom {
namespace {
using namespace simdjson;
using namespace SIMDJSON_IMPLEMENTATION;
@ -19,8 +20,8 @@ public:
simdjson_really_inline const std::vector<my_point> &Records() { return container; }
private:
ondemand::parser parser;
std::vector<my_point> container;
ondemand::parser parser{};
std::vector<my_point> container{};
};
simdjson_really_inline bool OnDemand::Run(const padded_string &json) {
@ -39,6 +40,7 @@ simdjson_really_inline bool OnDemand::Run(const padded_string &json) {
BENCHMARK_TEMPLATE(LargeRandom, OnDemand);
}
} // namespace largerandom
#endif // SIMDJSON_EXCEPTIONS

View File

@ -6,6 +6,7 @@
#include "largerandom.h"
namespace largerandom {
namespace {
using namespace simdjson;
using namespace SIMDJSON_IMPLEMENTATION;
@ -99,6 +100,7 @@ error_code Sax::Allocate(size_t new_capacity) {
BENCHMARK_TEMPLATE(LargeRandom, Sax);
}
} // namespace largerandom
#endif // SIMDJSON_EXCEPTIONS

View File

@ -22,16 +22,17 @@
#include <iostream>
#include <vector>
template <int TYPE = PERF_TYPE_HARDWARE, bool QUIET = false> class LinuxEvents {
template <int TYPE = PERF_TYPE_HARDWARE> class LinuxEvents {
int fd;
bool working;
perf_event_attr attribs{};
size_t num_events{};
std::vector<uint64_t> temp_result_vec{};
std::vector<uint64_t> ids{};
bool quiet;
public:
explicit LinuxEvents(std::vector<int> config_vec) : fd(0), working(true) {
explicit LinuxEvents(std::vector<int> config_vec, bool _quiet=false) : fd(0), working(true), quiet{_quiet} {
std::memset(&attribs, 0, sizeof(attribs));
attribs.type = TYPE;
attribs.size = sizeof(attribs);
@ -101,7 +102,7 @@ public:
private:
void report_error(const std::string &context) {
if (!QUIET) {
if (!quiet) {
if (working) {
std::cerr << (context + ": " + std::string(strerror(errno))) << std::endl;
}

View File

@ -25,7 +25,7 @@ template<typename B, typename R> static void ParseRecordsBenchmark(benchmark::St
}
// Run the benchmark
event_collector<true> events;
event_collector events(true);
events.start();
for (SIMDJSON_UNUSED auto _ : state) {
if (!bench.Run(json)) { state.SkipWithError("tweet reading failed"); return; }

View File

@ -16,8 +16,8 @@ public:
simdjson_really_inline const std::vector<tweet> &Records() { return tweets; }
private:
dom::parser parser;
std::vector<tweet> tweets;
dom::parser parser{};
std::vector<tweet> tweets{};
simdjson_really_inline uint64_t nullable_int(dom::element element) {
if (element.is_null()) { return 0; }

View File

@ -18,8 +18,8 @@ public:
simdjson_really_inline const std::vector<tweet> &Records() { return tweets; }
private:
dom::parser parser;
std::vector<tweet> tweets;
dom::parser parser{};
std::vector<tweet> tweets{};
simdjson_really_inline simdjson_result<uint64_t> nullable_int(dom::element element) noexcept {
if (element.is_null()) { return 0; }

View File

@ -6,6 +6,7 @@
#include "partial_tweets.h"
namespace partial_tweets {
namespace {
using namespace simdjson;
using namespace SIMDJSON_IMPLEMENTATION;
@ -19,8 +20,8 @@ public:
simdjson_really_inline const std::vector<tweet> &Records() { return tweets; }
private:
ondemand::parser parser;
std::vector<tweet> tweets;
ondemand::parser parser{};
std::vector<tweet> tweets{};
simdjson_really_inline uint64_t nullable_int(ondemand::value && value) {
if (value.is_null()) { return 0; }
@ -90,6 +91,7 @@ simdjson_really_inline bool Iter::Run(const padded_string &json) {
BENCHMARK_TEMPLATE(PartialTweets, Iter);
}
} // namespace partial_tweets
#endif // SIMDJSON_EXCEPTIONS

View File

@ -6,6 +6,7 @@
#include "partial_tweets.h"
namespace partial_tweets {
namespace {
using namespace simdjson;
using namespace SIMDJSON_IMPLEMENTATION;
@ -19,8 +20,8 @@ public:
simdjson_really_inline const std::vector<tweet> &Records() { return tweets; }
private:
ondemand::parser parser;
std::vector<tweet> tweets;
ondemand::parser parser{};
std::vector<tweet> tweets{};
simdjson_really_inline uint64_t nullable_int(ondemand::value && value) {
if (value.is_null()) { return 0; }
@ -57,6 +58,7 @@ simdjson_really_inline bool OnDemand::Run(const padded_string &json) {
BENCHMARK_TEMPLATE(PartialTweets, OnDemand);
}
} // namespace partial_tweets
#endif // SIMDJSON_EXCEPTIONS

View File

@ -6,6 +6,7 @@
#include "sax_tweet_reader_visitor.h"
namespace partial_tweets {
namespace {
using namespace simdjson;
using namespace SIMDJSON_IMPLEMENTATION;
@ -65,6 +66,7 @@ error_code Sax::Allocate(size_t new_capacity) {
BENCHMARK_TEMPLATE(PartialTweets, Sax);
}
} // namespace partial_tweets
#endif // SIMDJSON_IMPLEMENTATION