hp-timing.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* High precision, low overhead timing functions. Generic version.
  2. Copyright (C) 1998, 2000 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #ifndef _HP_TIMING_H
  18. #define _HP_TIMING_H 1
  19. /* There are no generic definitions for the times. We could write something
  20. using the `gettimeofday' system call where available but the overhead of
  21. the system call might be too high.
  22. In case a platform supports timers in the hardware the following macros
  23. and types must be defined:
  24. - HP_TIMING_AVAIL: test for availability.
  25. - HP_TIMING_INLINE: this macro is non-zero if the functionality is not
  26. implemented using function calls but instead uses some inlined code
  27. which might simply consist of a few assembler instructions. We have to
  28. know this since we might want to use the macros here in places where we
  29. cannot make function calls.
  30. - hp_timing_t: This is the type for variables used to store the time
  31. values.
  32. - HP_TIMING_ZERO: clear `hp_timing_t' object.
  33. - HP_TIMING_NOW: place timestamp for current time in variable given as
  34. parameter.
  35. - HP_TIMING_DIFF_INIT: do whatever is necessary to be able to use the
  36. HP_TIMING_DIFF macro.
  37. - HP_TIMING_DIFF: compute difference between two times and store it
  38. in a third. Source and destination might overlap.
  39. - HP_TIMING_ACCUM: add time difference to another variable. This might
  40. be a bit more complicated to implement for some platforms as the
  41. operation should be thread-safe and 64bit arithmetic on 32bit platforms
  42. is not.
  43. - HP_TIMING_ACCUM_NT: this is the variant for situations where we know
  44. there are no threads involved.
  45. - HP_TIMING_PRINT: write decimal representation of the timing value into
  46. the given string. This operation need not be inline even though
  47. HP_TIMING_INLINE is specified.
  48. */
  49. /* Provide dummy definitions. */
  50. #define HP_TIMING_AVAIL (0)
  51. #define HP_TIMING_INLINE (0)
  52. typedef int hp_timing_t;
  53. #define HP_TIMING_ZERO(Var)
  54. #define HP_TIMING_NOW(var)
  55. #define HP_TIMING_DIFF_INIT()
  56. #define HP_TIMING_DIFF(Diff, Start, End)
  57. #define HP_TIMING_ACCUM(Sum, Diff)
  58. #define HP_TIMING_ACCUM_NT(Sum, Diff)
  59. #define HP_TIMING_PRINT(Buf, Len, Val)
  60. /* Since this implementation is not available we tell the user about it. */
  61. #define HP_TIMING_NONAVAIL 1
  62. #endif /* hp-timing.h */