Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 32e9ba81 authored by EYRAUD-DUBOIS Lionel's avatar EYRAUD-DUBOIS Lionel

analysis of utilisation

parent 68db106f
#include "schedAction.h"
#include "util.h"
#include <iostream>
using namespace std;
......@@ -6,6 +7,20 @@ using namespace std;
void ActionSequence::add(SchedAction* a) {
actions.push_back(a);
}
void ActionSequence::remove(SchedAction* a) {
auto it = actions.begin();
while(it != actions.end()) {
if (a == *it) break;
++it;
}
if(it != actions.end())
actions.erase(it);
else {
cerr << "Warning: unable to remove action " << a << " from list of actions" << endl;
}
}
void ActionSequence::onSchedule(int i, int w, double s, double f) {
for (std::vector<SchedAction*>::iterator it = actions.begin() ; it != actions.end(); ++it) {
(*it)->onSchedule(i, w, s, f);
......@@ -50,3 +65,37 @@ ExportToFile::~ExportToFile() {
output.close();
}
UtilAnalysis::UtilAnalysis(Instance* _ins, string saveFile) :
ins(_ins), repartition(_ins->nbWorkerTypes,
std::vector<int>(ins->nbTaskTypes, 0)),
output(saveFile) {
}
UtilAnalysis::~UtilAnalysis(){
output.close();
}
void UtilAnalysis::onSchedule(int i, int w, double s, double f) {
repartition[getType(w, ins->nbWorkers, NULL)][ins->taskTypes[i]] += 1;
}
std::vector<std::vector<int> > UtilAnalysis::getRepartition() {
return repartition;
}
void UtilAnalysis::reset() {
for(auto &v: repartition)
for(auto &n: v)
n = 0;
}
void UtilAnalysis::write(string prefix) {
for(int i = 0; i < (int) repartition.size(); i++) {
for(int j = 0; j < (int) repartition[i].size(); j++) {
output << prefix << " " << i << " " << j << " "
<< repartition[i][j] << " "
<< repartition[i][j] * ins->execTimes[i][j] << endl;
}
}
reset();
}
......@@ -20,6 +20,7 @@ class ActionSequence : public SchedAction {
public:
ActionSequence() {}
void add(SchedAction *a);
void remove(SchedAction* a);
void onSchedule(int i, int w, double s, double f);
void onTaskPush(int t);
int chooseTask(int wType, double now);
......@@ -36,6 +37,18 @@ public:
~ExportToFile();
};
class UtilAnalysis : public SchedAction {
Instance* ins;
std::vector<std::vector<int> > repartition;
std::ofstream output;
public:
UtilAnalysis(Instance* _ins, std::string saveFile);
~UtilAnalysis();
void onSchedule(int i, int w, double s, double f);
std::vector<std::vector<int> > getRepartition();
void reset();
void write(std::string prefix);
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment