27 using namespace impala;
46 #define VALIDATE_RESULT(actual, expected, str) \
47 if (actual != expected) { \
48 cout << "Parse Error. " \
49 << "String: " << str \
50 << ". Parsed: " << actual << endl; \
54 #define VALIDATE_RESULT(actual, expected, str)
59 vector<StringValue> data;
60 vector<string> memory;
65 data->
memory.push_back(input);
66 const string& str = data->
memory.back();
67 data->
data.push_back(
StringValue(const_cast<char*>(str.c_str()), str.length()));
71 bool leading_space =
false,
bool trailing_space =
false) {
72 for (
int i = 0; i < n; ++i) {
75 val =
static_cast<int32_t
>((val * (max - min)) + min);
77 if (leading_space) ss <<
" ";
79 if (trailing_space) ss <<
" ";
84 #define DIGIT(c) (c -'0')
88 bool negative =
false;
91 case '-': negative =
true;
95 for (; i < len; ++i) {
96 val = val * 10 +
DIGIT(s[i]);
99 return negative ? -val : val;
105 bool negative =
false;
107 case '-': negative =
true;
108 case '+': --len, ++s;
113 val += (
DIGIT(s[len - 8])) * 10000;
115 val += (
DIGIT(s[len - 7])) * 10000;
117 val += (
DIGIT(s[len - 6])) * 10000;
119 val += (
DIGIT(s[len - 5])) * 10000;
121 val += (
DIGIT(s[len - 4])) * 1000;
123 val += (
DIGIT(s[len - 3])) * 100;
125 val += (
DIGIT(s[len - 2])) * 10;
127 val += (
DIGIT(s[len - 1]));
129 return negative ? -val : val;
138 bool negative =
false;
140 case '-': negative =
true;
141 case '+': --len, ++s;
162 return negative ? -val : val;
170 for (
int i = 0; i < batch_size; ++i) {
171 int n = data->
data.size();
172 for (
int j = 0; j < n; ++j) {
180 for (
int i = 0; i < batch_size; ++i) {
181 int n = data->
data.size();
182 for (
int j = 0; j < n; ++j) {
183 data->
result[j] = strtol(data->
data[j].ptr, NULL, 10);
190 for (
int i = 0; i < batch_size; ++i) {
191 int n = data->
data.size();
192 for (
int j = 0; j < n; ++j) {
195 int32_t val = StringParser::StringToInt<int32_t>(str.
ptr, str.
len, &dummy);
204 for (
int i = 0; i < batch_size; ++i) {
205 int n = data->
data.size();
206 for (
int j = 0; j < n; ++j) {
217 for (
int i = 0; i < batch_size; ++i) {
218 int n = data->
data.size();
219 for (
int j = 0; j < n; ++j) {
230 for (
int i = 0; i < batch_size; ++i) {
231 int n = data->
data.size();
232 for (
int j = 0; j < n; ++j) {
241 int main(
int argc,
char **argv) {
252 AddTestData(&data_leading_space, 1000, -5, 1000,
true,
false);
253 data_leading_space.
result.resize(data_leading_space.
data.size());
256 AddTestData(&data_trailing_space, 1000, -5, 1000,
false,
true);
257 data_trailing_space.
result.resize(data_trailing_space.
data.size());
260 AddTestData(&data_both_space, 1000, -5, 1000,
true,
true);
261 data_both_space.
result.resize(data_trailing_space.
data.size());
264 for (
int i = 0; i < 1000; ++i) {
267 data_garbage.
result.resize(data_garbage.
data.size());
270 for (
int i = 0; i < 1000; ++i) {
273 data_trailing_garbage.
result.resize(data_trailing_garbage.
data.size());
void TestImpalaCased(int batch_size, void *d)
int AddBenchmark(const std::string &name, BenchmarkFunction fn, void *args, int baseline_idx=0)
static std::string GetMachineInfo()
Output machine/build configuration as a string.
void TestImpalaUnrolled(int batch_size, void *d)
std::string Measure()
Runs all the benchmarks and returns the result in a formatted string.
int32_t AtoiUnsafe(char *s, int len)
void AddTestData(TestData *data, const string &input)
void TestImpalaUnsafe(int batch_size, void *d)
int32_t AtoiUnrolled(char *s, int len)
int main(int argc, char **argv)
void TestAtoi(int batch_size, void *d)
int32_t AtoiCased(char *s, int len)
vector< StringValue > data
void TestStrtol(int batch_size, void *d)
static void Init()
Initialize CpuInfo.
#define VALIDATE_RESULT(actual, expected, str)
void TestImpala(int batch_size, void *d)