Merge pull request 'improved' (#2) from planner_improve into main

Reviewed-on: http://alex-freenas.ddns.net:3000/M/VisualSapfor/pulls/2
This commit was merged in pull request #2.
This commit is contained in:
M
2023-12-03 19:29:23 +00:00
3 changed files with 41 additions and 5 deletions

View File

@@ -93,4 +93,18 @@ public:
printf("START %ld: %s\n", id, res.getCharArray());
return res;
}
virtual void copyResults(const String& pathRes) {
String resultPath(packageWorkspace + "/" + pathRes + "/" + getId());
Utils::Mkdir(resultPath);
Utils::Copy(workspace + "/out.txt", resultPath + "/out.txt");
Utils::Copy(workspace + "/err.txt", resultPath + "/err.txt");
if (Utils::Exists(workspace + "/sts.gz+")) {
String dvm_start = String::DQuotes(dvm_drv) + " pa " + String::DQuotes(String(getId()) + "/sts.gz+") + " " + String::DQuotes(resultPath + "/statistic.txt");
system(dvm_start.getCharArray());
}
}
};

View File

@@ -177,6 +177,10 @@ public:
set<T*> activeTaskSet;
bool ignoreCheck = true;
String pathRes("results");
Utils::Mkdir(pathRes);
string buf;
while (activeTasks) {
long oldActiveTasks = activeTasks;
vector<int> emptyKeys;
@@ -223,6 +227,8 @@ public:
busyKernels -= task->getKernels();
printf(" done task with %d kernels and id %ld\n", task->getKernels(), task->getId());
buf += to_string(task->getId()) + " " + string(task->printState().getCharArray()) + " " + to_string(task->getTotalTime()) + "\n";
task->copyResults(pathRes);
continue;
}
it++;
@@ -233,6 +239,11 @@ public:
}
changeState();
String outFile(pathRes + "/info.txt");
File tmp(outFile, String(buf.c_str()));
Utils::ZipFolder(pathRes, pathRes + ".zip");
}
virtual void Finalize() { }
@@ -241,6 +252,6 @@ public:
Utils::Sleep(1); //чтобы не было одинаковых по дате файлов.
String stateFile = packageWorkspace + "/state/" + getStatePrefix() + printState();
//printf("stateFile=<%s>\n", stateFile.getCharArray());
File(stateFile, Utils::getDate());
File tmp(stateFile, Utils::getDate());
}
};

View File

@@ -26,7 +26,8 @@ enum TaskState {
Queued, //16
NoSuchTask, //17
FailedToQueue, //18
AbortingByUser //19
AbortingByUser, //19
Unknown
};
enum TestType {
@@ -42,8 +43,9 @@ protected:
int maxtime;
int kernels; //получение зависит от типа задачи.
String workspace;
TaskState state;
TaskState state = Unknown;
std::chrono::system_clock::time_point start_time;
double total_time;
public:
String printState() {
@@ -88,6 +90,8 @@ public:
return String("FailedToQueue");
case AbortingByUser:
return String("AbortingByUser");
case Unknown:
return String("?");
default:
return "?";
}
@@ -95,6 +99,7 @@ public:
//-------------->>
void setStart() { start_time = std::chrono::system_clock::now(); }
double getTotalTime() const { return total_time; }
long getId() { return id; }
long setId(String* id_s) {
@@ -181,6 +186,10 @@ public:
}
virtual void analyseResults() {
auto end_time = std::chrono::system_clock::now();
std::chrono::duration<double> diff_time = end_time - start_time;
total_time = diff_time.count();
printf("%ld done with time %f\n", id, total_time);
state = Finished;
}
@@ -188,4 +197,6 @@ public:
String stateFile = workspace + "/TaskState";
File tmp(stateFile, printState());
}
virtual void copyResults(const String& path) { }
};