From 654767cf95a532448618a09f386262ffda396377 Mon Sep 17 00:00:00 2001 From: Michael Gary Date: Fri, 9 Aug 2002 23:34:11 +0000 Subject: [PATCH] Fixed errors in uc_cpu/test_time.php svn path=/trunk/boinc/; revision=287 --- api/boinc_api.C | 5 +++++ apps/uc_cpu.C | 23 +++++++++++++++++++++-- test/test_time.php | 10 ++++++---- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/api/boinc_api.C b/api/boinc_api.C index e4b97f9eeb..91af3a03bc 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -82,6 +82,11 @@ int boinc_finish(int status) { return 0; } +int boinc_get_init_data(APP_INIT_DATA& app_init_data) { + app_init_data = aid; + return 0; +} + // resolve XML soft links // int boinc_resolve_filename(char *virtual_name, char *physical_name) { diff --git a/apps/uc_cpu.C b/apps/uc_cpu.C index febc1537a8..9f59926dd6 100644 --- a/apps/uc_cpu.C +++ b/apps/uc_cpu.C @@ -30,10 +30,16 @@ #define CHECKPOINT_FILE "uc_slow_state" +time_t my_start_time; + int do_checkpoint(MFILE& mf, int nchars) { int retval; char resolved_name[512],res_name2[512]; + FILE *app_time = fopen("../../app.time", "w"), + *client_time = fopen("../../client.time", "w"); + APP_INIT_DATA aid; + boinc_get_init_data(aid); boinc_resolve_filename( "temp", resolved_name ); FILE* f = fopen(resolved_name, "w"); if (!f) return 1; @@ -50,16 +56,29 @@ int do_checkpoint(MFILE& mf, int nchars) { if (retval) return retval; // hopefully atomic part ends here + // print our own information about cpu time + fprintf(app_time, "%f\n", difftime(time(0), my_start_time)); + fflush(app_time); + fclose(app_time); + + // print what the client thinks is our cpu time + fprintf(client_time, "%f\n", aid.wu_cpu_time + boinc_cpu_time()); + fflush(client_time); + fclose(client_time); + return 0; } int main() { - int c, nchars = 0, retval, n, i; + int c, nchars = 0, retval, n; + unsigned long int i; double j; char resolved_name[512]; MFILE out, time_file; FILE* state, *in; + my_start_time = time(0); + boinc_init(); boinc_resolve_filename( "in", resolved_name ); @@ -91,7 +110,7 @@ int main() { n = 0; j = 3.14159; - for(i=0; i<10000000; i++) { + for(i=0; i<200000000; i++) { n++; j *= n+j-3.14159; j /= (float)n; diff --git a/test/test_time.php b/test/test_time.php index 1173dc0762..913d690dc6 100644 --- a/test/test_time.php +++ b/test/test_time.php @@ -6,8 +6,10 @@ include_once("init.inc"); + $app_time = 0; check_env_vars(); clear_db(); + clear_data_dirs(); create_keys(); init_client_dirs("prefs1.xml"); copy_to_download_dir("small_input"); @@ -15,13 +17,13 @@ add_core_client(null); add_user("prefs.xml"); add_app("uc_cpu", null, null); - create_work("-appname uc_cpu -rsc_fpops 4500000000 -rsc_iops 500000000 -wu_name uccpu_wu -wu_template uccpu_wu -result_template uccpu_result -nresults 1 small_input"); + create_work("-appname uc_cpu -rsc_fpops 4500000000.0 -rsc_iops 500000000.0 -wu_name uccpu_wu -wu_template uccpu_wu -result_template uccpu_result -nresults 1 small_input"); start_feeder(); - run_client("-exit_after 12"); - $app_time = get_time("app_time"); + run_client("-exit_after 400"); + $app_time += get_time("app.time"); PassThru("cp client_state.xml client_state.xml.one"); run_client("-exit_when_idle"); - $app_time += get_time("app_time"); + $app_time += get_time("app.time"); compare_file("uccpu_wu_0_0", "uc_small_correct_output"); compare_time($app_time); ?>