-
Notifications
You must be signed in to change notification settings - Fork 18
/
Model Synthesis.cpp
56 lines (49 loc) · 2.28 KB
/
Model Synthesis.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
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2021 Paul Merrell
#include <iostream>
#include "src/third_party/xmlParser.h"
#include "src/parseInput/parseInput.h"
#include "src/OutputGenerator.h"
#include "src/synthesizer.h"
#include <chrono>
#include <vector>
#include <map>
using namespace std;
using namespace std::chrono;
int main() {
XMLNode xMainNode = XMLNode::openFileHelper("samples.xml", "samples");
int numSamples = xMainNode.nChildNode();
int numIterations = 2;
microseconds inputTime{0}, synthesisTime{0}, outputTime{0};
for (int i = 0; i < numSamples; i++) {
InputSettings* settings = parseInput(xMainNode.getChildNode(i), inputTime);
Synthesizer synthesizer(settings, synthesisTime);
for (int iteration = 0; iteration < numIterations; iteration++) {
cout << settings->name << " " << iteration << endl;
synthesizer.synthesize(synthesisTime);
string outputPath;
if (settings->type == "simpletiled" || settings->type == "overlapping") {
string extra = (i + 1) < 10 ? "0" : "";
outputPath = "outputs/" + extra + to_string(i + 1) + " " + settings->name + " " + settings->subset + " " + to_string(iteration) + ".png";
} else {
outputPath = "outputs/" + to_string(i + 1) + " " + to_string(iteration) + " " + settings->name;
}
generateOutput(*settings, synthesizer.getModel(), outputPath, outputTime);
}
delete settings;
}
// Report computation times.
double inputTimeMs = inputTime.count() / 1000.0;
double synthesisTimeMs = synthesisTime.count() / 1000.0;
double outputTimeMs = outputTime.count() / 1000.0;
double totalTimeMs = inputTimeMs + synthesisTimeMs + outputTimeMs;
cout << "Input: " << inputTimeMs << " ms" << endl;
cout << "Synthesize: " << synthesisTimeMs << " ms" << endl;
cout << "Output: " << outputTimeMs << " ms" << endl;
cout << "Total: " << totalTimeMs << " ms" << endl << endl;
const int successes = numSamples * numIterations;
cout << "Per Success" << endl;
cout << "Synthesize: " << synthesisTimeMs / successes << " ms" << endl;
cout << "Output: " << outputTimeMs / successes << " ms" << endl;
cout << "Total: " << totalTimeMs / successes << " ms" << endl;
return 0;
}