From 217f59ec36b20273641a81ce5ddea6bff584f131 Mon Sep 17 00:00:00 2001 From: Fabian Posch Date: Wed, 8 Jan 2025 16:59:15 +0100 Subject: [PATCH] optimize artifact library and add fields for reduced reference data --- include/artifact.hpp | 43 ++++++++++++++++++++++++++--------- src/artifact.cpp | 54 -------------------------------------------- 2 files changed, 32 insertions(+), 65 deletions(-) delete mode 100644 src/artifact.cpp diff --git a/include/artifact.hpp b/include/artifact.hpp index 3e51842..4e9ae8f 100644 --- a/include/artifact.hpp +++ b/include/artifact.hpp @@ -25,6 +25,7 @@ #define __PIPELINE_ARTIFACT_H__ #include +#include #include #include #include @@ -77,7 +78,7 @@ class Artifact { * @brief Construct a new blank Artifact * */ - Artifact(); + Artifact() = default; /** * @brief Get the type of the artifact the object is holding. @@ -186,7 +187,7 @@ struct testcase_t { class SimConfigArtifact: public Artifact { public: - SimConfigArtifact(); + SimConfigArtifact() = default; SimConfigArtifact(bool has_reference) { this->has_reference_ = has_reference; }; /** @@ -202,7 +203,7 @@ class SimConfigArtifact: public Artifact { * * @param testcase */ - void add_testcase(testcase_t testcase); + inline void add_testcase(testcase_t testcase) { this->testcases.emplace_back(testcase); }; /** @@ -267,7 +268,7 @@ class SignalListArtifact: public Artifact { * * @param testcase */ - void add_signal(signal_t signal); + inline void add_signal(signal_t signal) { this->signals.emplace_back(signal); }; /** @@ -297,22 +298,27 @@ class SimOutputArtifact: public Artifact { public: SimOutputArtifact() {}; - SimOutputArtifact(const std::vector& sim_log, const std::vector& error_log); + SimOutputArtifact(const std::vector& sim_log, const std::vector& error_log) { + this->sim_log = sim_log; + this->sim_err_log = error_log; + has_content_ = true; + }; /** * @brief Get the content of the artifact * * @return std::vector Vector of all generated simulator output lines */ - std::pair&, std::vector&> get_content() { return {sim_log, sim_err_log}; }; - + inline std::pair&, std::vector&> get_content() { return {sim_log, sim_err_log}; }; + inline std::vector& get_output_token_timings() { return output_token_timings; }; + inline void set_output_token_timings(std::vector timings) { this->output_token_timings = timings; }; /** * @brief Add a log line to the artifact * * @param log_line */ - void add_log_output(std::string log_line); + inline void add_log_output(std::string log_line) { this->sim_log.emplace_back(log_line); has_content_ = true; }; /** @@ -320,7 +326,18 @@ class SimOutputArtifact: public Artifact { * * @param log_line */ - void add_err_output(std::string log_line); + inline void add_err_output(std::string log_line) { this->sim_err_log.emplace_back(log_line); has_content_ = true; }; + + inline void clear_logs() { + // save the size + size_ = this->sim_err_log.size() + this->sim_log.size(); + + this->sim_err_log.clear(); + this->sim_log.clear(); + has_content_ = false; + }; + + inline void add_output_token_timing(uint32_t timing) { this->output_token_timings.emplace_back(timing); }; /** @@ -328,7 +345,7 @@ class SimOutputArtifact: public Artifact { * * @return ArtifactType Will return the SIM_OUTPUT artifact type. */ - ArtifactType get_type() override { return ArtifactType::SIM_OUTPUT; }; + inline ArtifactType get_type() override { return ArtifactType::SIM_OUTPUT; }; /** @@ -336,7 +353,8 @@ class SimOutputArtifact: public Artifact { * * @return long The size of the log lines vector */ - long get_size() override { return sim_log.size(); }; + inline long get_size() override { if (has_content_) {return sim_log.size();} else {return size_;} }; + inline void set_size(long size) { if (!has_content_) this->size_ = size; }; const bool& fault_timing_deviation = fault_timing_deviation_; const bool& fault_value = fault_value_; @@ -360,6 +378,7 @@ class SimOutputArtifact: public Artifact { std::vector sim_log; std::vector sim_err_log; + std::vector output_token_timings; bool fault_timing_deviation_ = false; bool fault_value_ = false; bool fault_coding_ = false; @@ -368,6 +387,8 @@ class SimOutputArtifact: public Artifact { bool fault_token_count_ = false; int output_tokens_; + long size_ = 0; + bool has_content_ = false; }; }; diff --git a/src/artifact.cpp b/src/artifact.cpp deleted file mode 100644 index 8a4358f..0000000 --- a/src/artifact.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -/************************************************************************* - * - * Copyright (c) 2023 Fabian Posch - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - ************************************************************************** - */ - -#include "artifact.hpp" -#include "yaml.h" - -namespace pl { - -Artifact::Artifact() {} - -void SimConfigArtifact::add_testcase(testcase_t testcase) { - this->testcases.emplace_back(testcase); -} - -SimConfigArtifact::SimConfigArtifact() {} - -void SignalListArtifact::add_signal(signal_t signal) { - this->signals.emplace_back(signal); -} - -void SimOutputArtifact::add_log_output(std::string log_line) { - this->sim_log.emplace_back(log_line); -} - -void SimOutputArtifact::add_err_output(std::string log_line) { - this->sim_err_log.emplace_back(log_line); -} - -SimOutputArtifact::SimOutputArtifact(const std::vector& sim_log, const std::vector& error_log) { - this->sim_log = sim_log; - this->sim_err_log = error_log; -} - -}