This repository has been archived by the owner on Nov 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imgsoa.cpp
42 lines (35 loc) · 1.55 KB
/
imgsoa.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
/* Main source file for the SOA version */
#include "common.hpp"
#include "common_hst.hpp"
#include "imagesoa.cpp"
#include "progargs.cpp"
#include <chrono>
using namespace std;
int main(int argc, char *argv[]) {
argvalidation(argc);
Datastruct data_files = argparsing(string(argv[1]), string(argv[2]), string(argv[3]));//analyzes if data provided is valid
filesystem::directory_iterator it(data_files.in);
for (auto &entry: it) {
auto start = chrono::high_resolution_clock::now();
Header header = read_header(entry.path());
Image image = read_pixels(entry.path(), header.img_start, header.img_width, header.img_height);
long loadtime = stop_chrono(start);
filesystem::path new_file = data_files.out;
new_file /= entry.path().filename();
start = chrono::high_resolution_clock::now();
if(strcmp(argv[3], "histo") != 0) {
open_file(new_file);
}
image = perform_op(image, reinterpret_cast<string &>(argv[3]), new_file, header);
auto opertime = stop_chrono(start);
start = chrono::high_resolution_clock::now();
if (strcmp(argv[3], "histo") != 0) {
write_bmp(new_file, header, image);
}
auto storetime = stop_chrono(start);
long total = loadtime + opertime + storetime;
std::cout << "----------------------\n";
cout << "File: " << entry << " (time: " << total << ")" << "\n";//print the total time and the particular times
print_data(string(argv[3]), loadtime, opertime, storetime);
}
}