SimulationOutput.h
1 
11 #ifndef WRENCH_SIMULATIONOUTPUT_H
12 #define WRENCH_SIMULATIONOUTPUT_H
13 
14 
15 #include <typeinfo>
16 #include <typeindex>
17 #include <iostream>
18 
19 #include "wrench/simulation/SimulationTimestamp.h"
20 #include "wrench/simulation/SimulationTrace.h"
21 
22 namespace wrench {
23 
28 
29  public:
30 
38  template <class T> std::vector<SimulationTimestamp<T> *> getTrace() {
39  std::type_index type_index = std::type_index(typeid(T));
40 
41  // Is the trace empty?
42  if (this->traces.find(type_index) == this->traces.end()) {
43  return {};
44  }
45 
46  std::vector<SimulationTimestamp<T> *> non_generic_vector;
47  SimulationTrace<T> *trace = (SimulationTrace<T> *)(this->traces[type_index]);
48  for (auto ts : trace->getTrace()) {
49  non_generic_vector.push_back((SimulationTimestamp<T> *)ts);
50  }
51  return non_generic_vector;
52  }
53 
54  void dumpWorkflowExecutionJSON(Workflow *workflow, std::string file_path, bool generate_host_utilization_layout = false);
55  void dumpWorkflowGraphJSON(wrench::Workflow *workflow, std::string file_path);
56  void dumpHostEnergyConsumptionJSON(std::string file_path);
57  void dumpPlatformGraphJSON(std::string file_path);
58 
59  /***********************/
61  /***********************/
62 
69  template <class T> void addTimestamp(T *timestamp) {
70  std::type_index type_index = std::type_index(typeid(T));
71  if (this->traces.find(type_index) == this->traces.end()) {
72  this->traces[type_index] = new SimulationTrace<T>();
73  }
74  ((SimulationTrace<T> *)(this->traces[type_index]))->addTimestamp(new SimulationTimestamp<T>(timestamp));
75  }
76 
77  /***********************/
79  /***********************/
80 
81 
82  /***********************/
84  /***********************/
85  ~SimulationOutput() {
86  for (auto t : this->traces) {
87  delete t.second;
88  }
89  this->traces.clear();
90  }
91  /***********************/
93  /***********************/
94 
95  private:
96  std::map<std::type_index, GenericSimulationTrace*> traces;
97  };
98 
99 };
100 
101 
102 #endif //WRENCH_SIMULATIONOUTPUT_H
void dumpWorkflowExecutionJSON(Workflow *workflow, std::string file_path, bool generate_host_utilization_layout=false)
Writes WorkflowTask execution history for each task to a file, formatted as a JSON array...
Definition: SimulationOutput.cpp:317
A time-stamped simulation event stored in SimulationOutput.
Definition: SimulationTimestamp.h:26
void dumpHostEnergyConsumptionJSON(std::string file_path)
Writes a JSON file containing host energy consumption information as a JSON array. The JSON array has the following format:
Definition: SimulationOutput.cpp:524
A workflow (to be executed by a WMS)
Definition: Workflow.h:30
A class that contains post-mortem simulation-generated data.
Definition: SimulationOutput.h:27
void dumpWorkflowGraphJSON(wrench::Workflow *workflow, std::string file_path)
Writes a JSON graph representation of the Workflow to a file. A node is added for each WorkflowTask ...
Definition: SimulationOutput.cpp:405
void dumpPlatformGraphJSON(std::string file_path)
Writes a JSON file containing all hosts, network links, and the routes between each host...
Definition: SimulationOutput.cpp:660
std::vector< SimulationTimestamp< T > * > getTrace()
Retrieve a copy of a simulation output trace once the simulation has completed.
Definition: SimulationOutput.h:38
Definition: TerminalOutput.cpp:15