Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add format for tools #3244

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ jobs:
- name: Check and fix test format
run: python3 scripts/run-clang-format.py --in-place --clang-format-executable /usr/bin/clang-format-18 -r test/

- name: Check and fix tools format
run: python3 scripts/run-clang-format.py --in-place --clang-format-executable /usr/bin/clang-format-18 -r tools/

- name: Check and fix extension format
run: python3 scripts/run-clang-format.py --in-place --clang-format-executable /usr/bin/clang-format-18 -r extension/

Expand Down
4 changes: 2 additions & 2 deletions tools/benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ std::unique_ptr<QueryResult> Benchmark::runWithProfile() const {
return conn->query("PROFILE " + query, encodedJoin);
}

void Benchmark::logQueryInfo(
std::ofstream& log, uint32_t runNum, std::vector<std::string>& actualOutput) const {
void Benchmark::logQueryInfo(std::ofstream& log, uint32_t runNum,
std::vector<std::string>& actualOutput) const {
log << "Run Num: " << runNum << '\n';
log << "Status: " << (actualOutput == expectedOutput ? "pass" : "error") << '\n';
log << "Query: " << query << '\n';
Expand Down
24 changes: 12 additions & 12 deletions tools/benchmark/benchmark_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace benchmark {

const char* BENCHMARK_SUFFIX = ".benchmark";

BenchmarkRunner::BenchmarkRunner(
const std::string& datasetPath, std::unique_ptr<BenchmarkConfig> config)
BenchmarkRunner::BenchmarkRunner(const std::string& datasetPath,
std::unique_ptr<BenchmarkConfig> config)
: config{std::move(config)} {
database = std::make_unique<Database>(
datasetPath, SystemConfig(this->config->bufferPoolSize, this->config->numThreads));
database = std::make_unique<Database>(datasetPath,
SystemConfig(this->config->bufferPoolSize, this->config->numThreads));
spdlog::set_level(spdlog::level::debug);
}

Expand All @@ -37,8 +37,8 @@ void BenchmarkRunner::runAllBenchmarks() {
// an unitialized object.
benchmark.get());
} catch (std::exception& e) {
spdlog::error(
"Error encountered while running benchmark {}: {}.", benchmark->name, e.what());
spdlog::error("Error encountered while running benchmark {}: {}.", benchmark->name,
e.what());
}
}
}
Expand All @@ -51,8 +51,8 @@ void BenchmarkRunner::registerBenchmark(const std::string& path) {
}
}

double BenchmarkRunner::computeAverageOfLastRuns(
const double* runTimes, const int& len, const int& lastRunsToAverage) {
double BenchmarkRunner::computeAverageOfLastRuns(const double* runTimes, const int& len,
const int& lastRunsToAverage) {
double sum = 0;
for (int i = len - lastRunsToAverage; i < len; ++i) {
sum += runTimes[i];
Expand All @@ -77,15 +77,15 @@ void BenchmarkRunner::runBenchmark(Benchmark* benchmark) const {
runTimes[i] = queryResult->getQuerySummary()->getExecutionTime();
}
spdlog::info("Time Taken (Average of Last {} runs) (ms): {}", config->numRuns,
computeAverageOfLastRuns(
&runTimes[0], config->numRuns, config->numRuns /* numRunsToAverage */));
computeAverageOfLastRuns(&runTimes[0], config->numRuns,
config->numRuns /* numRunsToAverage */));
}

void BenchmarkRunner::profileQueryIfEnabled(Benchmark* benchmark) const {
if (config->enableProfile && !config->outputPath.empty()) {
auto profileInfo = benchmark->runWithProfile();
std::ofstream profileFile(
config->outputPath + "/" + benchmark->name + "_profile.txt", std::ios_base::app);
std::ofstream profileFile(config->outputPath + "/" + benchmark->name + "_profile.txt",
std::ios_base::app);
profileFile << profileInfo->getNext()->toString() << '\n';
profileFile.flush();
profileFile.close();
Expand Down
4 changes: 2 additions & 2 deletions tools/benchmark/include/benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class Benchmark {

private:
void loadBenchmark(const std::string& benchmarkPath);
void logQueryInfo(
std::ofstream& log, uint32_t runNum, std::vector<std::string>& actualOutput) const;
void logQueryInfo(std::ofstream& log, uint32_t runNum,
std::vector<std::string>& actualOutput) const;
void verify(std::vector<std::string>& actualOutput) const;

public:
Expand Down
4 changes: 2 additions & 2 deletions tools/benchmark/include/benchmark_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class BenchmarkRunner {
void registerBenchmarks(const std::string& path);

void runAllBenchmarks();
static double computeAverageOfLastRuns(
const double* runTimes, const int& len, const int& lastRunsToAverage);
static double computeAverageOfLastRuns(const double* runTimes, const int& len,
const int& lastRunsToAverage);

private:
void registerBenchmark(const std::string& path);
Expand Down
4 changes: 2 additions & 2 deletions tools/benchmark/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ int main(int argc, char** argv) {
try {
runner.registerBenchmarks(benchmarkPath);
} catch (std::exception& e) {
spdlog::error(
"Error encountered while registering benchmark in {}: {}.", benchmarkPath, e.what());
spdlog::error("Error encountered while registering benchmark in {}: {}.", benchmarkPath,
e.what());
}
runner.runAllBenchmarks();
return 0;
Expand Down
Loading