home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / POV-Ray 3.0.2 / src / MacSource / Profiling.c < prev    next >
Encoding:
Text File  |  1996-10-07  |  2.9 KB  |  105 lines  |  [TEXT/CWIE]

  1. /*==============================================================================
  2. Project:    POV
  3.  
  4. Version:    3
  5.  
  6. File:        Profiling.c
  7.  
  8. Description:
  9.     General purpose encapsulation of profiler on/off code,
  10.     for different compiler platforms.
  11. ------------------------------------------------------------------------------
  12. Author:
  13.     Eduard [esp] Schwan
  14. ------------------------------------------------------------------------------
  15.     from Persistence of Vision(tm) Ray Tracer
  16.     Copyright 1996 Persistence of Vision Team
  17. ------------------------------------------------------------------------------
  18.     NOTICE: This source code file is provided so that users may experiment
  19.     with enhancements to POV-Ray and to port the software to platforms other 
  20.     than those supported by the POV-Ray Team.  There are strict rules under
  21.     which you are permitted to use this file.  The rules are in the file
  22.     named POVLEGAL.DOC which should be distributed with this file. If 
  23.     POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  24.     Team Coordinator by leaving a message in CompuServe's Graphics Developer's
  25.     Forum.  The latest version of POV-Ray may be found there as well.
  26.  
  27.     This program is based on the popular DKB raytracer version 2.12.
  28.     DKBTrace was originally written by David K. Buck.
  29.     DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  30. ------------------------------------------------------------------------------
  31. Change History:
  32. ==============================================================================*/
  33.  
  34. // ---------------------------------------------------------------
  35. // Debug with profiler
  36. //
  37. #if defined(__MWERKS__)
  38.   #include <profiler.h>
  39. #elif defined(THINK_C)
  40.   #include <profile.h>
  41. #elif defined(applec)
  42.   // um... MPW 3.3 needs...
  43. #endif
  44.  
  45. // protect user from himself :-)
  46. static short int    gProfilerOn = 0;
  47.  
  48. // ---------------------------------------------------------------------
  49. void StartProfiling(void)
  50. {
  51.     // is it already on?
  52.     if (gProfilerOn)
  53.         {
  54.         return;
  55.         }
  56.  
  57.     // Turn ON profiling for POV-Ray engine
  58. #if defined(__MWERKS__)
  59.   #if __profile__
  60.     // Initalize the metrowerks profiler
  61.     ProfilerInit(collectSummary, bestTimeBase, 300, 100);
  62.   #endif
  63. #elif defined(THINK_C)
  64.   #if __option(profile)
  65.     // Initialize the Symantec C profiler
  66.     InitProfile(300, 100);
  67.     
  68.     /* Open a file for the Think C profile output to go into */
  69.     freopen("POV.SC.Profile.Report", "w", stdout);
  70.   #endif
  71. #endif
  72.     gProfilerOn = 1;
  73. }
  74.  
  75.  
  76. // ---------------------------------------------------------------------
  77. void StopProfiling(void)
  78. {
  79.     // is it already off?
  80.     if (!gProfilerOn)
  81.         {
  82.         return;
  83.         }
  84.  
  85.     // Turn OFF profiling for POV-Ray engine
  86. #if defined(__MWERKS__)
  87.   #if __profile__
  88.     // Dump out the profiler data to a file
  89.     ProfilerDump("\pOptimization Profiler Info");
  90.     // Stop the profiler
  91.     ProfilerTerm();
  92.   #endif
  93. #elif defined(THINK_C)
  94.   #if __option(profile)
  95.     // Dump Think C's profiler report
  96.     DumpProfile();
  97.     SetAppQuit(); // no reason to stick around.
  98.   #endif
  99. #endif
  100.  
  101.     gProfilerOn = 0;
  102. }
  103.  
  104.  
  105.