Skip to content

Commit c2b3ed6

Browse files
authored
Merge pull request #566 from NotRequiem/dev
Improved NVRAM check speed; fixed spoofed AMD manufacturer checks
2 parents dce6a9a + 7eca664 commit c2b3ed6

File tree

5 files changed

+270
-220
lines changed

5 files changed

+270
-220
lines changed

auxiliary/benchmark.cpp

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* - License: MIT
2121
*/
2222

23-
#include "../src/vmaware.hpp"
23+
#include "vmaware.hpp"
2424
#include <iostream>
2525
#include <string>
2626
#include <cmath>
@@ -35,7 +35,7 @@
3535

3636
const std::string bold = "\033[1m";
3737
const std::string ansi_exit = "\x1B[0m";
38-
const std::string red = "\x1B[38;2;239;75;75m";
38+
const std::string red = "\x1B[38;2;239;75;75m";
3939
const std::string green = "\x1B[38;2;94;214;114m";
4040
const std::string orange = "\x1B[38;2;255;180;5m";
4141

@@ -103,34 +103,6 @@ int main(void) {
103103
std::string vm_brand, vm_type;
104104
uint8_t vm_percent;
105105

106-
/* ================================================ NO MEMOIZATION CATEGORY ================================================ */
107-
108-
// VMAwareBenchmark VM::detect(VM::NO_MEMO)
109-
start = VMAwareBenchmark::get_timestamp();
110-
is_detected = VM::detect(VM::NO_MEMO);
111-
end = VMAwareBenchmark::get_timestamp();
112-
const double detect_time_no_memo = VMAwareBenchmark::get_elapsed(start, end);
113-
114-
// VMAwareBenchmark VM::brand()
115-
start = VMAwareBenchmark::get_timestamp();
116-
vm_brand = VM::brand(VM::NO_MEMO);
117-
end = VMAwareBenchmark::get_timestamp();
118-
const double brand_time_no_memo = VMAwareBenchmark::get_elapsed(start, end);
119-
120-
// VMAwareBenchmark VM::type()
121-
start = VMAwareBenchmark::get_timestamp();
122-
vm_type = VM::type(VM::NO_MEMO);
123-
end = VMAwareBenchmark::get_timestamp();
124-
const double type_time_no_memo = VMAwareBenchmark::get_elapsed(start, end);
125-
126-
// VMAwareBenchmark VM::percentage()
127-
start = VMAwareBenchmark::get_timestamp();
128-
vm_percent = VM::percentage(VM::NO_MEMO);
129-
end = VMAwareBenchmark::get_timestamp();
130-
const double percent_time_no_memo = VMAwareBenchmark::get_elapsed(start, end);
131-
132-
/* ================================================ DEFAULT CATEGORY ================================================ */
133-
134106
// VMAwareBenchmark VM::detect()
135107
start = VMAwareBenchmark::get_timestamp();
136108
is_detected = VM::detect();
@@ -165,25 +137,21 @@ int main(void) {
165137
<< "VM::brand(): " << VMAwareBenchmark::format_duration(brand_time) << "\n"
166138
<< "VM::type(): " << VMAwareBenchmark::format_duration(type_time) << "\n"
167139
<< "VM::percentage(): " << VMAwareBenchmark::format_duration(percent_time) << "\n\n"
168-
<< "Benchmark Results (not cached):\n"
169-
<< "VM::detect(VM::NO_MEMO): " << VMAwareBenchmark::format_duration(detect_time_no_memo) << "\n"
170-
<< "VM::brand(VM::NO_MEMO): " << VMAwareBenchmark::format_duration(brand_time_no_memo) << "\n"
171-
<< "VM::type(VM::NO_MEMO): " << VMAwareBenchmark::format_duration(type_time_no_memo) << "\n"
172-
<< "VM::percentage(VM::NO_MEMO): " << VMAwareBenchmark::format_duration(percent_time_no_memo) << "\n\n";
140+
<< "Benchmark Results (not cached):\n";
173141

174142
for (const VM::enum_flags technique_enum : VM::technique_vector) {
175143
start = VMAwareBenchmark::get_timestamp();
176144

177-
VM::check(technique_enum, VM::NO_MEMO);
145+
VM::check(technique_enum);
178146

179147
end = VMAwareBenchmark::get_timestamp();
180148
const double technique_time = VMAwareBenchmark::get_elapsed(start, end);
181-
182-
std::cout <<
183-
"VM::" <<
184-
VM::flag_to_string(technique_enum) <<
185-
": " <<
186-
VMAwareBenchmark::format_duration(technique_time) <<
149+
150+
std::cout <<
151+
"VM::" <<
152+
VM::flag_to_string(technique_enum) <<
153+
": " <<
154+
VMAwareBenchmark::format_duration(technique_time) <<
187155
"\n";
188156
}
189157

0 commit comments

Comments
 (0)