From 9db902b8d9c1da80dbd9fc24039aca8f478e5883 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 9 Jan 2006 23:03:15 +0000 Subject: [PATCH] upper case CPU usage svn path=/trunk/boinc/; revision=9204 --- apps/upper_case.C | 117 ++++++++++++++++------------------------- checkin_notes | 6 +++ doc/create_project.php | 2 +- 3 files changed, 51 insertions(+), 74 deletions(-) diff --git a/apps/upper_case.C b/apps/upper_case.C index e3666f42ec..d51b7c2d75 100755 --- a/apps/upper_case.C +++ b/apps/upper_case.C @@ -20,7 +20,7 @@ // read "in", convert to UC, write to "out" // command line options: // -run_slow: sleep 1 second after each character, useful for debugging -// -cpu_time: chew up some CPU cycles after each character, +// -cpu_time N: use about N CPU seconds // -signal: raise SIGHUP signal (for testing signal handler) // -exit: exit with status -10 (for testing exit handler) // @@ -67,7 +67,7 @@ double xDelta=0.03, yDelta=0.07; bool run_slow; bool raise_signal; bool random_exit; -bool cpu_time; +double cpu_time; APP_INIT_DATA uc_aid; int do_checkpoint(MFILE& mf, int nchars) { @@ -91,7 +91,6 @@ int do_checkpoint(MFILE& mf, int nchars) { } static void use_some_cpu() { -#if 1 double j = 3.14159; int i, n = 0; for (i=0; i<20000000; i++) { @@ -99,26 +98,8 @@ static void use_some_cpu() { j *= n+j-3.14159; j /= (float)n; } -#endif - boinc_sleep(5.0); } -//#define TEST_INT_UPLOAD - -#ifdef TEST_INT_UPLOAD -#define UPLOAD_FILE_NAME "int_upload" - -int write_upload_file() { - std::string physname; - int retval = boinc_resolve_filename_s(UPLOAD_FILE_NAME, physname); - if (retval) return retval; - FILE* f = boinc_fopen(physname.c_str(), "w"); - fprintf(f, "blah blah\nfoobar\n"); - fclose(f); - return 0; -} -#endif - #ifdef _WIN32 extern int main(int argc, char** argv); @@ -134,44 +115,15 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR Args, int WinMode } #endif -int main(int argc, char **argv) { +void worker() { int c, nchars = 0, retval, i; double fsize; char resolved_name[512]; MFILE out; FILE* state, *in; - int flags = - BOINC_DIAG_DUMPCALLSTACKENABLED | - BOINC_DIAG_HEAPCHECKENABLED | - BOINC_DIAG_REDIRECTSTDERR; - - boinc_init_diagnostics(flags); - - retval = boinc_init(); - if (retval) exit(retval); - - // NOTE: if you change output here, remember to change the output that - // test_uc.py pattern-matches against. - - for (i=0; i= fsize/2) { - string tmpname=UPLOAD_FILE_NAME; - retval = boinc_upload_status(tmpname); - fprintf(stderr, "upload status %d\n", retval); - } -#endif - if (cpu_time) { - use_some_cpu(); - } - if (run_slow) { boinc_sleep(1.); } @@ -263,15 +197,52 @@ int main(int argc, char **argv) { fprintf(stderr, "APP: upper_case flush failed %d\n", retval); exit(1); } + if (cpu_time) { + double start = dtime(); + while (dtime() < start + cpu_time) { + use_some_cpu(); + } + } + if (random_exit) exit(-10); fprintf(stderr, "APP: upper_case ending, wrote %d chars\n", nchars); -#ifdef BOINC_APP_GRAPHICS - boinc_finish_opengl(); -#endif boinc_finish(0); +} - return 0; +int main(int argc, char **argv) { + int i, retval; + + boinc_init_diagnostics( + BOINC_DIAG_DUMPCALLSTACKENABLED | + BOINC_DIAG_HEAPCHECKENABLED | + BOINC_DIAG_REDIRECTSTDERR + ); + + // NOTE: if you change output here, remember to change the output that + // test_uc.py pattern-matches against. + + for (i=0; i
  • Basic API
  • Diagnostics API -
  • Ggraphics API +
  • Graphics API
  • Trickle messages API
  • Intermediate upload API