Add repeat field to Result

Save repeat field from Instruction in Result, as it will be useful
for calculating durations for InstructionSet.

Bug: 193388430
Test: dittobench_test
Signed-off-by: Robertas Norkus <robertasn@google.com>
Change-Id: Ieee06042155b9910e11470b5f3fc5fbc465bdf7e
diff --git a/include/ditto/result.h b/include/ditto/result.h
index a1bd9c4..d78eba1 100644
--- a/include/ditto/result.h
+++ b/include/ditto/result.h
@@ -28,11 +28,12 @@
 
 class Result {
  public:
-  explicit Result(const std::string& name);
+  explicit Result(const std::string& name, const int& repeat);
 
   void AddMeasurement(const std::string& type, const std::vector<int64_t>& samples);
   void AddSubResult(std::unique_ptr<Result> result);
   std::vector<int64_t> GetSamples(const std::string& measurement_name) const;
+  int GetRepeat() const;
   void Print(const ResultsOutput& results_output, const std::string& instruction_path);
 
  private:
@@ -56,6 +57,7 @@
   std::map<std::string, std::vector<int64_t>> samples_;
   std::map<std::string, Statistics> statistics_;
   std::vector<std::unique_ptr<Result>> sub_results_;
+  int repeat_;
 
   void PrintHistograms(const std::string& instruction_path);
   void PrintStatisticsTables();
diff --git a/src/instruction.cpp b/src/instruction.cpp
index ceeda91..2ad29e4 100644
--- a/src/instruction.cpp
+++ b/src/instruction.cpp
@@ -51,7 +51,7 @@
 }
 
 std::unique_ptr<Result> Instruction::CollectResults(const std::string& prefix) {
-  auto result = std::make_unique<Result>(prefix + name_);
+  auto result = std::make_unique<Result>(prefix + name_, repeat_);
   result->AddMeasurement("duration", TimespecToNs(time_sampler_.GetSamples()));
   return result;
 }
diff --git a/src/instruction_set.cpp b/src/instruction_set.cpp
index 89e8d7a..ee01100 100644
--- a/src/instruction_set.cpp
+++ b/src/instruction_set.cpp
@@ -103,7 +103,7 @@
 }
 
 std::unique_ptr<Result> InstructionSet::CollectResults(const std::string& prefix) {
-  auto result = std::make_unique<Result>(prefix + name_);
+  auto result = std::make_unique<Result>(prefix + name_, repeat_);
   result->AddMeasurement("duration", TimespecToNs(time_sampler_.GetSamples()));
   for (const auto& instruction : instructions_) {
     result->AddSubResult(instruction->CollectResults(""));
diff --git a/src/multithreading.cpp b/src/multithreading.cpp
index bf02438..dff737c 100644
--- a/src/multithreading.cpp
+++ b/src/multithreading.cpp
@@ -50,7 +50,7 @@
 }
 
 std::unique_ptr<Result> Multithreading::CollectResults(const std::string& prefix) {
-  auto result = std::make_unique<Result>(prefix + name_);
+  auto result = std::make_unique<Result>(prefix + name_, repeat_);
   result->AddMeasurement("duration", TimespecToNs(time_sampler_.GetSamples()));
   for (unsigned int i = 0; i < instructions_.size(); ++i) {
     result->AddSubResult(instructions_[i]->CollectResults(std::to_string(i) + "/"));
diff --git a/src/result.cpp b/src/result.cpp
index 5423ba1..af6affe 100644
--- a/src/result.cpp
+++ b/src/result.cpp
@@ -36,7 +36,7 @@
 
 namespace dittosuite {
 
-Result::Result(const std::string& name) : name_(name) {}
+Result::Result(const std::string& name, const int& repeat) : name_(name), repeat_(repeat) {}
 
 void Result::AddMeasurement(const std::string& name, const std::vector<int64_t>& samples) {
   samples_[name] = samples;
@@ -51,6 +51,10 @@
   return samples_.find(measurement_name)->second;
 }
 
+int Result::GetRepeat() const {
+  return repeat_;
+}
+
 // analyse the measurement with the given name, and store
 // the results in the statistics_ map
 void Result::AnalyseMeasurement(const std::string& name) {