-
Notifications
You must be signed in to change notification settings - Fork 0
/
taskGenerator.cpp
43 lines (35 loc) · 1.05 KB
/
taskGenerator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "taskGeneratorClass.hpp"
int main(int argc, char** argv)
{
taskGenerator task_generator;
srand(time(NULL));
// default parameters
int utilizationPercent = 100;
int numberOfTasks = 10;
string outputName = "output_default";
int precision = 20;
if (argc % 2 == 0) throw logic_error("Bad number of parameters (was odd, need even)");
// parse arguments
for (int i = 1; i < argc; i += 2)
{
string command = argv[i];
if (command == "-u") utilizationPercent = atoi(argv[i+1]);
else if (command == "-n") numberOfTasks = atoi(argv[i+1]);
else if (command == "-o") outputName = argv[i+1];
else if (command == "-p") precision = atoi(argv[i+1]);
else throw logic_error("parameter command : '" + command + "' not recognized");
}
vector<Task> tasks;
while(tasks.empty())
{
tasks = task_generator.generateTasks(utilizationPercent, numberOfTasks, precision);
}
ofstream outfile;
outfile.open (outputName.c_str());
for (unsigned int t = 0; t < tasks.size(); ++t)
{
outfile << tasks[t].asString() << endl;
}
outfile.close();
return 0;
}