2
0

timer.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*************************************************************************
  2. * *
  3. * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
  4. * All rights reserved. Email: [email protected] Web: www.q12.org *
  5. * *
  6. * This library is free software; you can redistribute it and/or *
  7. * modify it under the terms of EITHER: *
  8. * (1) The GNU Lesser General Public License as published by the Free *
  9. * Software Foundation; either version 2.1 of the License, or (at *
  10. * your option) any later version. The text of the GNU Lesser *
  11. * General Public License is included with this library in the *
  12. * file LICENSE.TXT. *
  13. * (2) The BSD-style license that is included with this library in *
  14. * the file LICENSE-BSD.TXT. *
  15. * *
  16. * This library is distributed in the hope that it will be useful, *
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
  19. * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
  20. * *
  21. *************************************************************************/
  22. #ifndef _ODE_TIMER_H_
  23. #define _ODE_TIMER_H_
  24. #include <ode/odeconfig.h>
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /* stop watch objects */
  29. typedef struct dStopwatch {
  30. double time; /* total clock count */
  31. unsigned long cc[2]; /* clock count since last `start' */
  32. } dStopwatch;
  33. ODE_API void dStopwatchReset (dStopwatch *);
  34. ODE_API void dStopwatchStart (dStopwatch *);
  35. ODE_API void dStopwatchStop (dStopwatch *);
  36. ODE_API double dStopwatchTime (dStopwatch *); /* returns total time in secs */
  37. /* code timers */
  38. ODE_API void dTimerStart (const char *description); /* pass a static string here */
  39. ODE_API void dTimerNow (const char *description); /* pass a static string here */
  40. ODE_API void dTimerEnd(void);
  41. /* print out a timer report. if `average' is nonzero, print out the average
  42. * time for each slot (this is only meaningful if the same start-now-end
  43. * calls are being made repeatedly.
  44. */
  45. ODE_API void dTimerReport (FILE *fout, int average);
  46. /* resolution */
  47. /* returns the timer ticks per second implied by the timing hardware or API.
  48. * the actual timer resolution may not be this great.
  49. */
  50. ODE_API double dTimerTicksPerSecond(void);
  51. /* returns an estimate of the actual timer resolution, in seconds. this may
  52. * be greater than 1/ticks_per_second.
  53. */
  54. ODE_API double dTimerResolution(void);
  55. #ifdef __cplusplus
  56. }
  57. #endif
  58. #endif