Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions velox/functions/sparksql/benchmarks/CastBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ core::TypedExprPtr makeCastExpr(
// expression, e.g. when the input type is TIMESTAMP_UTC.
void addTypedCastBenchmark(
const std::string& name,
const RowVectorPtr& input,
const RowVectorPtr& inputVector,
core::TypedExprPtr castExpr,
core::ExecCtx& execCtx,
std::vector<std::shared_ptr<exec::ExprSet>>& typedExprSets,
int32_t iterations) {
auto exprSet = std::make_shared<exec::ExprSet>(
std::vector<core::TypedExprPtr>{std::move(castExpr)}, &execCtx);
typedExprSets.push_back(
std::make_shared<exec::ExprSet>(
std::vector<core::TypedExprPtr>{std::move(castExpr)}, &execCtx));
auto* exprSet = typedExprSets.back().get();
auto* input = inputVector.get();
folly::addBenchmark(__FILE__, name, [input, exprSet, &execCtx, iterations]() {
exec::EvalCtx evalCtx(&execCtx, exprSet.get(), input.get());
exec::EvalCtx evalCtx(&execCtx, exprSet, input);
SelectivityVector rows(input->size());
std::vector<VectorPtr> results(1);

Expand Down Expand Up @@ -140,17 +144,21 @@ int main(int argc, char** argv) {

auto queryCtx = core::QueryCtx::create();
core::ExecCtx execCtx(benchmarkBuilder.pool(), queryCtx.get());
std::vector<std::shared_ptr<exec::ExprSet>> typedExprSets;
typedExprSets.reserve(2);
addTypedCastBenchmark(
setName + "##cast_timestamp_as_timestamp_utc",
timestampInput,
makeCastExpr(TIMESTAMP(), "timestamp", TIMESTAMP_UTC()),
execCtx,
typedExprSets,
iterations);
addTypedCastBenchmark(
setName + "##cast_timestamp_utc_as_timestamp",
timestampInput,
makeCastExpr(TIMESTAMP_UTC(), "timestamp_utc", TIMESTAMP()),
execCtx,
typedExprSets,
iterations);

benchmarkBuilder.registerBenchmarks();
Expand Down
Loading