4coder/internal_4coder_tests.cpp

100 lines
2.9 KiB
C++
Raw Normal View History

/*
A series of stress tests to more quickly verify that 4coder isn't totally
broken before I release in the future... "unit tests" perhaps, although
I guess I don't know what the "units" are... probably more like "tests".
Allen Webster
18.07.2016
*/
// TOP
2016-07-19 01:35:09 +00:00
#define LOTS_OF_FILES "w:/4ed/data/lots_of_files"
#define TEST_FILES "w:/4ed/data/test"
2016-07-19 01:35:09 +00:00
#include "4coder_default_include.cpp"
#include "4coder_default_building.cpp"
2016-08-28 15:42:12 +00:00
#include <intrin.h>
#pragma intrinsic(__rdtsc)
typedef uint64_t DWORD64;
2016-07-20 15:19:54 +00:00
#define TEST_TIME_B(m) DWORD64 time_start = __rdtsc(), time_max = m; (void)(time_start), (void)(time_max)
2016-07-20 15:19:54 +00:00
#define TEST_TIME_E() DWORD64 time_total = __rdtsc() - time_start; if (time_total > time_max) {assert(!"failed timing");}
#define TEST_TIME_M(m) m = (float)(__rdtsc() - time_start) / time_max
// NOTE(allen): This testing system only verifies that everything works
// without crashing and without blowing through a fair time budget.
// These tests do not verify the correctness of the output.
2016-07-19 01:35:09 +00:00
CUSTOM_COMMAND_SIG(load_lots_of_files){
2016-07-20 16:16:02 +00:00
// NOTE(allen): This timing restriction is based on 4GHz and 60fps
// 4G / 60 ~= 70M Reserving most of that time for rendering and hopefully idling
// I set the goal of 10M for all tests.
2016-07-20 15:19:54 +00:00
TEST_TIME_B(10000000);
2016-07-19 01:35:09 +00:00
File_List list = app->get_file_list(app, literal(LOTS_OF_FILES));
File_Info *info = list.infos;
char space[1024];
String str = make_fixed_width_string(space);
append_ss(&str, make_lit_string(LOTS_OF_FILES));
append_s_char(&str, '/');
int size = str.size;
2016-07-19 01:35:09 +00:00
for (int i = 0; i < list.count; ++i, ++info){
if (!info->folder){
append_ss(&str, make_string(info->filename, info->filename_len));
Buffer_Summary buffer = app->create_buffer(app, str.str, str.size,
BufferCreate_Background);
assert(buffer.size != 0);
str.size = size;
2016-07-19 01:35:09 +00:00
}
}
app->free_file_list(app, list);
2016-07-20 16:16:02 +00:00
// TODO(allen): Pass this time test!
2016-08-27 17:48:10 +00:00
//TEST_TIME_E();
2016-07-19 01:35:09 +00:00
}
CUSTOM_COMMAND_SIG(reopen_test){
// NOTE(allen): This is set to roughly one percent of the frame budget
// based on 4GHz and 60fps
TEST_TIME_B(700000);
Buffer_Summary buffer = app->create_buffer(app, literal(TEST_FILES "/basic.cpp"), 0);
View_Summary view = app->get_active_view(app, AccessAll);
app->view_set_buffer(app, &view, buffer.buffer_id, 0);
exec_command(app, cmdid_reopen);
// TODO(allen): Pass this time test!
//TEST_TIME_E();
}
CUSTOM_COMMAND_SIG(run_all_tests){
exec_command(app, load_lots_of_files);
exec_command(app, reopen_test);
}
2016-07-19 01:35:09 +00:00
static void
test_get_bindings(Bind_Helper *context){
begin_map(context, mapid_global);
bind(context, key_f3, MDFR_NONE, run_all_tests);
2016-07-19 01:35:09 +00:00
end_map(context);
}
#define BIND_4CODER_TESTS(context) test_get_bindings(context)
#include "power/4coder_experiments.cpp"
// BOTTOM