9
3

my_rdtsc.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc.
  2. Use is subject to license terms.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  13. /*
  14. rdtsc3 -- multi-platform timer code
  15. pgulutzan@mysql.com, 2005-08-29
  16. modified 2008-11-02
  17. */
  18. #ifndef MY_RDTSC_H
  19. #define MY_RDTSC_H
  20. /**
  21. Characteristics of a timer.
  22. */
  23. struct my_timer_unit_info
  24. {
  25. /** Routine used for the timer. */
  26. ulonglong routine;
  27. /** Overhead of the timer. */
  28. ulonglong overhead;
  29. /** Frequency of the timer. */
  30. ulonglong frequency;
  31. /** Resolution of the timer. */
  32. ulonglong resolution;
  33. };
  34. /**
  35. Characteristics of all the supported timers.
  36. @sa my_timer_init().
  37. */
  38. struct my_timer_info
  39. {
  40. /** Characteristics of the cycle timer. */
  41. struct my_timer_unit_info cycles;
  42. /** Characteristics of the nanosecond timer. */
  43. struct my_timer_unit_info nanoseconds;
  44. /** Characteristics of the microsecond timer. */
  45. struct my_timer_unit_info microseconds;
  46. /** Characteristics of the millisecond timer. */
  47. struct my_timer_unit_info milliseconds;
  48. /** Characteristics of the tick timer. */
  49. struct my_timer_unit_info ticks;
  50. };
  51. typedef struct my_timer_info MY_TIMER_INFO;
  52. C_MODE_START
  53. /**
  54. A cycle timer.
  55. @return the current timer value, in cycles.
  56. */
  57. ulonglong my_timer_cycles(void);
  58. /**
  59. A namoseconds timer.
  60. @return the current timer value, in nanoseconds.
  61. */
  62. ulonglong my_timer_nanoseconds(void);
  63. /**
  64. A microseconds timer.
  65. @return the current timer value, in microseconds.
  66. */
  67. ulonglong my_timer_microseconds(void);
  68. /**
  69. A millisecond timer.
  70. @return the current timer value, in milliseconds.
  71. */
  72. ulonglong my_timer_milliseconds(void);
  73. /**
  74. A ticks timer.
  75. @return the current timer value, in ticks.
  76. */
  77. ulonglong my_timer_ticks(void);
  78. /**
  79. Timer initialization function.
  80. @param [out] mti the timer characteristics.
  81. */
  82. void my_timer_init(MY_TIMER_INFO *mti);
  83. C_MODE_END
  84. #define MY_TIMER_ROUTINE_ASM_X86 1
  85. #define MY_TIMER_ROUTINE_ASM_X86_64 2
  86. #define MY_TIMER_ROUTINE_RDTSCLL 3
  87. #define MY_TIMER_ROUTINE_ASM_X86_WIN 4
  88. #define MY_TIMER_ROUTINE_RDTSC 5
  89. #define MY_TIMER_ROUTINE_ASM_IA64 6
  90. #define MY_TIMER_ROUTINE_ASM_PPC 7
  91. #define MY_TIMER_ROUTINE_SGI_CYCLE 8
  92. #define MY_TIMER_ROUTINE_GETHRTIME 9
  93. #define MY_TIMER_ROUTINE_READ_REAL_TIME 10
  94. #define MY_TIMER_ROUTINE_CLOCK_GETTIME 11
  95. #define MY_TIMER_ROUTINE_NXGETTIME 12
  96. #define MY_TIMER_ROUTINE_GETTIMEOFDAY 13
  97. #define MY_TIMER_ROUTINE_QUERYPERFORMANCECOUNTER 14
  98. #define MY_TIMER_ROUTINE_GETTICKCOUNT 15
  99. #define MY_TIMER_ROUTINE_TIME 16
  100. #define MY_TIMER_ROUTINE_TIMES 17
  101. #define MY_TIMER_ROUTINE_FTIME 18
  102. #define MY_TIMER_ROUTINE_ASM_PPC64 19
  103. #define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC64 20
  104. #define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC32 21
  105. #define MY_TIMER_ROUTINE_ASM_SUNPRO_I386 22
  106. #define MY_TIMER_ROUTINE_ASM_GCC_SPARC64 23
  107. #define MY_TIMER_ROUTINE_ASM_GCC_SPARC32 24
  108. #define MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME 25
  109. #define MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME 26
  110. #define MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64 27
  111. #define MY_TIMER_ROUTINE_ASM_S390 28
  112. #endif