|
1 |
| -/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. |
| 1 | +/* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 2 |
|
3 | 3 | This program is free software; you can redistribute it and/or modify
|
4 | 4 | it under the terms of the GNU General Public License as published by
|
@@ -117,6 +117,75 @@ void init_timers(void)
|
117 | 117 |
|
118 | 118 | to_pico_data[TIMER_NAME_TICK].m_v0= tick_v0;
|
119 | 119 | to_pico_data[TIMER_NAME_TICK].m_factor= tick_to_pico;
|
| 120 | + |
| 121 | + /* |
| 122 | + Depending on the platform and build options, |
| 123 | + some timers may not be available. |
| 124 | + Pick best replacements. |
| 125 | + */ |
| 126 | + |
| 127 | + /* |
| 128 | + For STAGE and STATEMENT, a timer with a fixed frequency is better. |
| 129 | + The prefered timer is nanosecond, or lower resolutions. |
| 130 | + */ |
| 131 | + |
| 132 | + if (nanosec_to_pico != 0) |
| 133 | + { |
| 134 | + /* Normal case. */ |
| 135 | + stage_timer= TIMER_NAME_NANOSEC; |
| 136 | + statement_timer= TIMER_NAME_NANOSEC; |
| 137 | + } |
| 138 | + else if (microsec_to_pico != 0) |
| 139 | + { |
| 140 | + /* Windows. */ |
| 141 | + stage_timer= TIMER_NAME_MICROSEC; |
| 142 | + statement_timer= TIMER_NAME_MICROSEC; |
| 143 | + } |
| 144 | + else if (millisec_to_pico != 0) |
| 145 | + { |
| 146 | + /* Robustness, no known cases. */ |
| 147 | + stage_timer= TIMER_NAME_MILLISEC; |
| 148 | + statement_timer= TIMER_NAME_MILLISEC; |
| 149 | + } |
| 150 | + else if (tick_to_pico != 0) |
| 151 | + { |
| 152 | + /* Robustness, no known cases. */ |
| 153 | + stage_timer= TIMER_NAME_TICK; |
| 154 | + statement_timer= TIMER_NAME_TICK; |
| 155 | + } |
| 156 | + else |
| 157 | + { |
| 158 | + /* Robustness, no known cases. */ |
| 159 | + stage_timer= TIMER_NAME_CYCLE; |
| 160 | + statement_timer= TIMER_NAME_CYCLE; |
| 161 | + } |
| 162 | + |
| 163 | + /* |
| 164 | + For IDLE, a timer with a fixed frequency is critical, |
| 165 | + as the CPU clock may slow down a lot if the server is completely idle. |
| 166 | + The prefered timer is microsecond, or lower resolutions. |
| 167 | + */ |
| 168 | + |
| 169 | + if (microsec_to_pico != 0) |
| 170 | + { |
| 171 | + /* Normal case. */ |
| 172 | + idle_timer= TIMER_NAME_MICROSEC; |
| 173 | + } |
| 174 | + else if (millisec_to_pico != 0) |
| 175 | + { |
| 176 | + /* Robustness, no known cases. */ |
| 177 | + idle_timer= TIMER_NAME_MILLISEC; |
| 178 | + } |
| 179 | + else if (tick_to_pico != 0) |
| 180 | + { |
| 181 | + /* Robustness, no known cases. */ |
| 182 | + idle_timer= TIMER_NAME_TICK; |
| 183 | + } |
| 184 | + else |
| 185 | + { |
| 186 | + /* Robustness, no known cases. */ |
| 187 | + idle_timer= TIMER_NAME_CYCLE; |
| 188 | + } |
120 | 189 | }
|
121 | 190 |
|
122 | 191 | ulonglong get_timer_raw_value(enum_timer_name timer_name)
|
|
0 commit comments