-
Notifications
You must be signed in to change notification settings - Fork 3
/
standard_util.cpp
36 lines (27 loc) · 1018 Bytes
/
standard_util.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
#include "standard_util.h"
long long timeit(std::function<void()> func) {
auto begin = std::chrono::high_resolution_clock::now();
func();
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count();
return duration;
}
// TODO
// Make platform independant
/*void files_in_directory(const std::string &dir, std::vector<const std::string> &files) {
HANDLE dir_handle;
WIN32_FIND_DATA file_data;
if ((dir_handle = FindFirstFile((dir + "/*").c_str(), &file_data)) == INVALID_HANDLE_VALUE) {
return;
}
else {
do {
const std::string file_name = file_data.cFileName;
const std::string full_file_name = dir + "/" + file_name;
const bool is_directory = (file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
if (file_name[0] == '.') continue;
if (is_directory) continue;
files.push_back(full_file_name);
} while (FindNextFile(dir_handle, &file_data));
}
}*/