Skip to content

Commit 4018093

Browse files
committed
add timing support
1 parent 03f27c8 commit 4018093

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The following list of options can be used inside the config.txt file:
2121
- `tests-exclude` = `<decimal (support up to 378) or case insensitive API name>[,...]`
2222
- `disable-video` = `<boolean>`[^1]
2323
- `disable-verbose` = `<boolean>`[^1]
24+
- `disable-timing` = `<boolean>`[^1]
2425

2526
[^1]: boolean value can be 1 or 0
2627

src/main.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ extern "C" {
2828
// defined in util/output.h file, used privately here only
2929
extern "C" BOOL output_video;
3030
extern "C" BOOL output_verbose;
31+
extern "C" BOOL output_timing;
3132
// Initialize the actual default values here if the config file is either successfully loaded before reading inputs or it failed to load.
3233
static void init_default_values()
3334
{
@@ -191,6 +192,9 @@ int load_conf_file(const char *file_path)
191192
if (strcmp("disable-verbose", current_key) == 0) {
192193
output_verbose = !strtoul(strtok(NULL, NEWLINE_DELIMITER), NULL, 10);
193194
}
195+
if (strcmp("disable-timing", current_key) == 0) {
196+
output_timing = !strtoul(strtok(NULL, NEWLINE_DELIMITER), NULL, 10);
197+
}
194198
}
195199

196200
free(buffer);
@@ -219,10 +223,25 @@ static void run_tests()
219223
print("%zu test(s) will be excluded.", tests_to_run_excluded.count());
220224
}
221225
}
226+
ULONGLONG frequency;
227+
if (output_timing) {
228+
frequency = KeQueryPerformanceFrequency();
229+
}
230+
ULONGLONG tick_start, tick_end;
222231
print("-------------------------------------------------------------");
223232
for (int i = 0; i < kernel_api_tests_size; i++) {
224233
if (tests_to_run.test(i)) {
234+
if (output_timing) {
235+
tick_start = KeQueryPerformanceCounter();
236+
}
225237
kernel_api_tests[i].func(i + 1, kernel_api_tests[i].name);
238+
if (output_timing) {
239+
tick_end = KeQueryPerformanceCounter();
240+
ULONGLONG total_ms = ((tick_end - tick_start) * 1000) / frequency;
241+
ULONGLONG total_seconds = total_ms / 1000;
242+
ULONGLONG remainder_ms = total_ms % 1000;
243+
print("%03u - %s: Test completed in %llu.%03llu seconds", i + 1, kernel_api_tests[i].name, total_seconds, remainder_ms);
244+
}
226245
}
227246
}
228247
print("------------------------ End of Tests -----------------------");

src/util/output.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
BOOL output_video = FALSE; // NOTE: Must be set to a default of FALSE until config file is loaded and before video initialization.
1313
BOOL output_verbose = TRUE;
14+
BOOL output_timing = TRUE;
1415

1516
static HANDLE output_filehandle = INVALID_HANDLE_VALUE;
1617

0 commit comments

Comments
 (0)