00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <basis/chaos.h>
00021 #include <basis/istring.h>
00022 #include <mathematics/averager.cpp>
00023 #include <mechanisms/time_stamp.h>
00024 #include <mfc_ext/debugging_console_window.h>
00025 #include <mfc_ext/tiny_app.cpp>
00026 #include <mfc_ext/tiny_shell.h>
00027 #include <opsystem/event_extensions.h>
00028 #include <data_struct/static_memory_gremlin.h>
00029 #include <textual/string_manipulation.h>
00030 #include <win_ext/debugger.h>
00031
00032 const int PRINT_TIMER = 37;
00033
00034
00035 const int PRINT_INTERVAL = 10;
00036
00037
00038
00039 const int RUN_TIME = 30 * SECOND_ms;
00040
00041
00042
00043 const int MIN_RANDS = 7;
00044 const int MAX_RANDS = 88;
00045
00046
00047
00048 const int MIN_REPRINTS = 10;
00049 const int MAX_REPRINTS = 60;
00050
00051 class test_debugging_console : public tiny_shell
00052 {
00053 public:
00054 test_debugging_console();
00055
00056 IMPLEMENT_CLASS_NAME("test_debugging_console");
00057
00058 int execute();
00059
00060
00061 void OnTimer(u_int wparam);
00062
00063 DECLARE_MESSAGE_MAP();
00064
00065 time_stamp _start_time;
00066 time_stamp _quitting_time;
00067 long _operations;
00068 long _bytes;
00069 averager<double> _log_times;
00070 };
00071
00072 BEGIN_MESSAGE_MAP(test_debugging_console, tiny_shell)
00073
00074 ON_WM_TIMER()
00075
00076 END_MESSAGE_MAP()
00077
00078 test_debugging_console::test_debugging_console()
00079 : tiny_shell("Test Debugging Console", "t_debugging_console"),
00080 _operations(0),
00081 _bytes(0)
00082 {}
00083
00084 int test_debugging_console::execute()
00085 {
00086 SetTimer(PRINT_TIMER, PRINT_INTERVAL, NIL);
00087
00088 _start_time.reset();
00089 _quitting_time.reset(RUN_TIME);
00090 return 0;
00091 }
00092
00093 void test_debugging_console::OnTimer(u_int wparam)
00094 {
00095 static istring to_print;
00096 to_print.reset();
00097 for (int i = 0; i < randomizer().inclusive(MIN_RANDS, MAX_RANDS); i++)
00098 to_print += string_manipulation::make_random_name() + " ";
00099 time_stamp log_start;
00100 int repeats = randomizer().inclusive(MIN_REPRINTS, MAX_REPRINTS);
00101 for (int j = 0; j < repeats; j++) {
00102 log(to_print);
00103 _operations++;
00104 }
00105 time_stamp log_end;
00106 _bytes += repeats * to_print.length();
00107 _log_times.add(log_end.value() - log_start.value(), repeats);
00108 if (time_stamp() > _quitting_time) {
00109
00110 KillTimer(wparam);
00111 log("");
00112 log("");
00113 log("test complete:");
00114 log(istring(istring::SPRINTF, "\trun time: %f sec",
00115 (time_stamp().value() - _start_time.value()) / 1000));
00116 log(istring(istring::SPRINTF, "\toperations: %d",
00117 _operations));
00118 log(istring(istring::SPRINTF, "\tbytes logged: %d",
00119 _bytes));
00120 log(istring(istring::SPRINTF, "\taverage log() duration: %f ms",
00121 _log_times.average()));
00122
00123 event_extensions::poll(200);
00124 istring win_contents;
00125 if (!console().get_contents(win_contents)) {
00126 log("failed to get clipboard!");
00127 } else {
00128
00129
00130
00131
00132
00133 log(isprintf("win content was %d characters long.",
00134 win_contents.length()));
00135 }
00136
00137 }
00138 }
00139
00140
00141
00142 HOOPLE_MAIN(test_debugging_console, )
00143