Skip to content

Commit

Permalink
Add format for tools (#3244)
Browse files Browse the repository at this point in the history
* Add format for tools

* Run clang-format

---------

Co-authored-by: CI Bot <mewim@users.noreply.github.com>
  • Loading branch information
mewim and mewim committed Apr 10, 2024
1 parent e7be7b4 commit 21b3b6a
Show file tree
Hide file tree
Showing 42 changed files with 588 additions and 564 deletions.
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

0 comments on commit 21b3b6a

Please sign in to comment.