26 namespace gregorian = boost::gregorian;
27 using boost::posix_time::duration_from_string;
28 using boost::posix_time::hours;
29 using boost::posix_time::nanoseconds;
30 using boost::posix_time::time_duration;
31 using boost::posix_time::to_iso_extended_string;
32 using boost::posix_time::to_simple_string;
33 using namespace impala;
51 #define VALIDATE_RESULT(actual, expected, str) \
52 if (actual != expected) { \
53 cout << "Parse Error. " \
54 << "String: " << str \
55 << ". Parsed: " << actual << endl; \
59 #define VALIDATE_RESULT(actual, expected, str)
64 vector<StringValue> data;
65 vector<string> memory;
70 data->
memory.push_back(input);
71 const string& str = data->
memory.back();
72 data->
data.push_back(
StringValue(const_cast<char*>(str.c_str()), str.length()));
76 gregorian::date start(gregorian::from_string(startstr));
77 for (
int i = 0; i < n; ++i) {
80 gregorian::date_duration days(val);
83 ss << to_iso_extended_string(start);
89 time_duration start(duration_from_string(startstr));
90 for (
int i = 0; i < n; ++i) {
92 start += nanoseconds(val);
93 if (start.hours() >= 24) start -= hours(24);
95 ss << to_simple_string(start);
102 for (
int i = 0; i < batch_size; ++i) {
103 int n = data->
data.size();
104 for (
int j = 0; j < n; ++j) {
112 for (
int i = 0; i < batch_size; ++i) {
113 int n = data->
data.size();
114 for (
int j = 0; j < n; ++j) {
115 data->
result[j].set_date(gregorian::from_string(data->
memory[j]));
122 for (
int i = 0; i < batch_size; ++i) {
123 int n = data->
data.size();
124 for (
int j = 0; j < n; ++j) {
125 string s(data->
data[j].ptr, data->
data[j].len);
126 data->
result[j].set_date(gregorian::from_string(s));
133 for (
int i = 0; i < batch_size; ++i) {
134 int n = data->
data.size();
135 for (
int j = 0; j < n; ++j) {
136 string s(data->
data[j].ptr, data->
data[j].len);
137 data->
result[j].set_time(duration_from_string(s));
143 int main(
int argc,
char **argv) {
160 Benchmark timestamp_suite(
"ParseTimestamp");
166 cout << timestamp_suite.
Measure();
int AddBenchmark(const std::string &name, BenchmarkFunction fn, void *args, int baseline_idx=0)
void TestImpalaDate(int batch_size, void *d)
void AddTestData(TestData *data, const string &input)
static std::string GetMachineInfo()
Output machine/build configuration as a string.
void TestBoostStringDate(int batch_size, void *d)
std::string Measure()
Runs all the benchmarks and returns the result in a formatted string.
vector< TimestampValue > result
void AddTestDataTimes(TestData *data, int n, const string &startstr)
void AddTestDataDates(TestData *data, int n, const string &startstr)
void TestBoostTime(int batch_size, void *d)
vector< StringValue > data
int main(int argc, char **argv)
static void Init()
Initialize CpuInfo.
void TestBoostDate(int batch_size, void *d)