mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-06-01 01:54:00 +00:00
Extract argument parsing, timer out of main
This commit is contained in:
@@ -11,6 +11,10 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
namespace prog_opts = boost::program_options;
|
||||
|
||||
/**
|
||||
* @brief LLM sampling parameters.
|
||||
*/
|
||||
@@ -69,4 +73,5 @@ struct ApplicationOptions {
|
||||
PipelineOptions pipeline;
|
||||
};
|
||||
|
||||
std::optional<ApplicationOptions> ParseArguments(const int argc, char** argv);
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_DATA_MODEL_APPLICATION_OPTIONS_H_
|
||||
|
||||
39
tooling/pipeline/includes/services/timer.h
Normal file
39
tooling/pipeline/includes/services/timer.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_TIMER_H_
|
||||
#define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_TIMER_H_
|
||||
|
||||
#include <chrono>
|
||||
|
||||
/**
|
||||
* @file services/timer.h
|
||||
* @brief Simple timer utility for measuring elapsed time.
|
||||
*/
|
||||
class Timer {
|
||||
std::chrono::steady_clock::time_point start_time =
|
||||
std::chrono::steady_clock::now();
|
||||
|
||||
public:
|
||||
Timer(const Timer&) = delete;
|
||||
Timer& operator=(const Timer&) = delete;
|
||||
Timer(Timer&&) = delete;
|
||||
Timer& operator=(Timer&&) = delete;
|
||||
Timer() = default;
|
||||
~Timer() = default;
|
||||
|
||||
[[nodiscard]] int64_t Elapsed() const {
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now() - start_time)
|
||||
.count();
|
||||
}
|
||||
|
||||
[[nodiscard]] int64_t Reset() {
|
||||
auto previous_elapsed = Elapsed();
|
||||
start_time = std::chrono::steady_clock::now();
|
||||
return previous_elapsed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_TIMER_H_
|
||||
Reference in New Issue
Block a user