- 0 ノート
-
Get time
目次 |
このページを編集する際は,編集に関する方針に従ってください.
編集
概要
編集
- gcc-4.1.0/gcc/timevar.cにて定義
- 現在までの経過時間をミリ秒単位で取得
引数
編集
- struct timevar_time_def *now
- 経過時間をこれに格納する
実装
編集
185 /* Fill the current times into TIME. The definition of this function 186 also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and 187 HAVE_WALL_TIME macros. */ 188 189 static void 190 get_time (struct timevar_time_def *now) 191 {
- nowの値を初期化
192 now->user = 0; 193 now->sys = 0; 194 now->wall = 0; 195 now->ggc_mem = timevar_ggc_mem_total; 196
- timevar_initが呼ばれていなければ終了
197 if (!timevar_enable) 198 return; 199
- nowに値をいれていく
200 {
201 #ifdef USE_TIMES
202 struct tms tms;
203 now->wall = times (&tms) * ticks_to_msec;
204 now->user = tms.tms_utime * ticks_to_msec;
205 now->sys = tms.tms_stime * ticks_to_msec;
206 #endif
- getrusageは資源の使用量を取得する関数
207 #ifdef USE_GETRUSAGE 208 struct rusage rusage; 209 getrusage (RUSAGE_SELF, &rusage); 210 now->user = rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6; 211 now->sys = rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6; 212 #endif 213 #ifdef USE_CLOCK 214 now->user = clock () * clocks_to_msec; 215 #endif 216 }
217 }