2 * Name : time_running_app
3 * Author : Chris Koeritz
6 * A simple test of how long it takes to run a fairly heavy application.
8 * Copyright (c) 2003-$now By Author. This program is free software; you can
9 * redistribute it and/or modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either version 2 of
11 * the License or (at your option) any later version. This is online at:
12 * http://www.fsf.org/copyleft/gpl.html
13 * Please send any updates to: fred@gruntose.com
16 #include <basis/astring.h>
17 #include <basis/environment.cpp>
18 #include <basis/functions.h>
19 #include <structures/set.h>
20 #include <timely/time_stamp.h>
21 #include <application/hoople_main.h>
22 #include <loggers/console_logger.h>
23 #include <loggers/file_logger.h>
24 #include <structures/static_memory_gremlin.h>
28 using namespace application;
29 using namespace basis;
30 using namespace loggers;
31 using namespace filesystem;
32 using namespace textual;
33 using namespace timely;
36 #define BASE_LOG(to_print) EMERGENCY_LOG(program_wide_logger::get(), astring(to_print))
38 #define LOG(to_print) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(to_print))
40 class time_running_app : public application_shell
43 time_running_app() : application_shell() {}
44 DEFINE_CLASS_NAME("time_running_app");
48 int time_running_app::execute()
53 int test_runs = 10000;
55 time_stamp start; // start of test.
56 astring bins = environment::get("FEISTY_MEOW_DIR") + "/production/binaries";
57 astring app = bins + "/example_application";
59 int real_stdout = dup(1);
61 freopen("/dev/null", "w", stdout);
62 for (int i = 0; i < test_runs; i++) {
63 // run the app; sorry about the relative path; change to this dir first.
64 int ret = system(app.s());
66 // restore real stdout.
68 LOG(astring("got an error running the app: ") + app);
72 time_stamp completion_time; // end of test.
73 // restore real stdout.
76 double durat = completion_time.value() - start.value();
77 double secs = durat / 1000.0; // convert to seconds.
78 LOG(a_sprintf("test run took %0.2f milliseconds or %0.2f seconds or %0.2f minutes.", durat, secs, secs / 60.0));
79 LOG(a_sprintf("individual call takes %0.0f milliseconds.", durat / double(test_runs)));
84 HOOPLE_MAIN(time_running_app, )
86 #ifdef __BUILD_STATIC_APPLICATION__
87 // static dependencies found by buildor_gen_deps.sh:
88 #endif // __BUILD_STATIC_APPLICATION__