27 using namespace impala;
36 template <
typename Decimal>
47 return rand() /
static_cast<double>(RAND_MAX);
50 template <
typename Decimal>
52 data->
memory.push_back(input);
53 const string& str = data->
memory.back();
54 data->
data.push_back(
StringValue(const_cast<char*>(str.c_str()), str.length()));
57 template <
typename Decimal>
60 DecimalUtil::GetScaleMultiplier<int128_t>(data->
precision - data->
scale) - 1 : 0;
62 DecimalUtil::GetScaleMultiplier<int128_t>(data->
scale) - 1 : 0;
63 for (
int i = 0; i < n; ++i) {
66 if (max_whole > 0) ss << static_cast<int128_t>(max_whole *
Rand());
67 if (max_fraction > 0) ss <<
"." <<
static_cast<int128_t>(max_fraction *
Rand());
72 template <
typename Decimal,
typename Storage>
77 for (
int i = 0; i < batch_size; ++i) {
78 int n = data->
data.size();
79 for (
int j = 0; j < n; ++j) {
82 val = StringParser::StringToDecimal<Storage>(
83 str.
ptr, str.
len, column_type, &dummy);
89 int main(
int argc,
char **argv) {
101 suite.
AddBenchmark(
"Impala Decimal4", TestImpala<Decimal4Value, int32_t>, &data4);
109 suite.
AddBenchmark(
"Impala Decimal8", TestImpala<Decimal8Value, int64_t>, &data8);
117 suite.
AddBenchmark(
"Impala Decimal16", TestImpala<Decimal16Value, int128_t>, &data16);
double probability_negative
int AddBenchmark(const std::string &name, BenchmarkFunction fn, void *args, int baseline_idx=0)
static const int MAX_DECIMAL8_PRECISION
The maximum precision representable by a 8-byte decimal (Decimal8Value)
void AddTestData(TestData< Decimal > *data, const string &input)
static std::string GetMachineInfo()
Output machine/build configuration as a string.
std::string Measure()
Runs all the benchmarks and returns the result in a formatted string.
void TestImpala(int batch_size, void *d)
static const int MAX_DECIMAL4_PRECISION
The maximum precision representable by a 4-byte decimal (Decimal4Value)
int main(int argc, char **argv)
vector< StringValue > data
static void Init()
Initialize CpuInfo.
static ColumnType CreateDecimalType(int precision, int scale)
static const int MAX_PRECISION
Must be kept in sync with FE's max precision/scale.
__int128_t int128_t
We use the c++ int128_t type. This is stored using 16 bytes and very performant.