@@ -24,7 +24,7 @@ profile_start(proftime_T *tm)
2424# ifdef MSWIN
2525 QueryPerformanceCounter (tm );
2626# else
27- gettimeofday (tm , NULL );
27+ PROF_GET_TIME (tm );
2828# endif
2929}
3030
@@ -40,12 +40,12 @@ profile_end(proftime_T *tm)
4040 QueryPerformanceCounter (& now );
4141 tm -> QuadPart = now .QuadPart - tm -> QuadPart ;
4242# else
43- gettimeofday (& now , NULL );
44- tm -> tv_usec = now .tv_usec - tm -> tv_usec ;
43+ PROF_GET_TIME (& now );
44+ tm -> tv_fsec = now .tv_fsec - tm -> tv_fsec ;
4545 tm -> tv_sec = now .tv_sec - tm -> tv_sec ;
46- if (tm -> tv_usec < 0 )
46+ if (tm -> tv_fsec < 0 )
4747 {
48- tm -> tv_usec += 1000000 ;
48+ tm -> tv_fsec += TV_FSEC_SEC ;
4949 -- tm -> tv_sec ;
5050 }
5151# endif
@@ -60,11 +60,11 @@ profile_sub(proftime_T *tm, proftime_T *tm2)
6060# ifdef MSWIN
6161 tm -> QuadPart -= tm2 -> QuadPart ;
6262# else
63- tm -> tv_usec -= tm2 -> tv_usec ;
63+ tm -> tv_fsec -= tm2 -> tv_fsec ;
6464 tm -> tv_sec -= tm2 -> tv_sec ;
65- if (tm -> tv_usec < 0 )
65+ if (tm -> tv_fsec < 0 )
6666 {
67- tm -> tv_usec += 1000000 ;
67+ tm -> tv_fsec += TV_FSEC_SEC ;
6868 -- tm -> tv_sec ;
6969 }
7070# endif
@@ -85,7 +85,7 @@ profile_msg(proftime_T *tm)
8585 QueryPerformanceFrequency (& fr );
8686 sprintf (buf , "%10.6lf" , (double )tm -> QuadPart / (double )fr .QuadPart );
8787# else
88- sprintf (buf , "%3ld.%06ld" , (long )tm -> tv_sec , (long )tm -> tv_usec );
88+ sprintf (buf , PROF_TIME_FORMAT , (long )tm -> tv_sec , (long )tm -> tv_fsec );
8989# endif
9090 return buf ;
9191}
@@ -102,7 +102,7 @@ profile_float(proftime_T *tm)
102102 QueryPerformanceFrequency (& fr );
103103 return (float_T )tm -> QuadPart / (float_T )fr .QuadPart ;
104104# else
105- return (float_T )tm -> tv_sec + (float_T )tm -> tv_usec / 1000000.0 ;
105+ return (float_T )tm -> tv_sec + (float_T )tm -> tv_fsec / ( float_T ) TV_FSEC_SEC ;
106106# endif
107107}
108108
@@ -123,12 +123,12 @@ profile_setlimit(long msec, proftime_T *tm)
123123 QueryPerformanceFrequency (& fr );
124124 tm -> QuadPart += (LONGLONG )((double )msec / 1000.0 * (double )fr .QuadPart );
125125# else
126- long usec ;
126+ long fsec ;
127127
128- gettimeofday (tm , NULL );
129- usec = (long )tm -> tv_usec + (long )msec * 1000 ;
130- tm -> tv_usec = usec % 1000000L ;
131- tm -> tv_sec += usec / 1000000L ;
128+ PROF_GET_TIME (tm );
129+ fsec = (long )tm -> tv_fsec + (long )msec * ( TV_FSEC_SEC / 1000 ) ;
130+ tm -> tv_fsec = fsec % ( long ) TV_FSEC_SEC ;
131+ tm -> tv_sec += fsec / ( long ) TV_FSEC_SEC ;
132132# endif
133133 }
134134}
@@ -149,9 +149,9 @@ profile_passed_limit(proftime_T *tm)
149149# else
150150 if (tm -> tv_sec == 0 ) // timer was not set
151151 return FALSE;
152- gettimeofday (& now , NULL );
152+ PROF_GET_TIME (& now );
153153 return (now .tv_sec > tm -> tv_sec
154- || (now .tv_sec == tm -> tv_sec && now .tv_usec > tm -> tv_usec ));
154+ || (now .tv_sec == tm -> tv_sec && now .tv_fsec > tm -> tv_fsec ));
155155# endif
156156}
157157
@@ -164,7 +164,7 @@ profile_zero(proftime_T *tm)
164164# ifdef MSWIN
165165 tm -> QuadPart = 0 ;
166166# else
167- tm -> tv_usec = 0 ;
167+ tm -> tv_fsec = 0 ;
168168 tm -> tv_sec = 0 ;
169169# endif
170170}
@@ -189,10 +189,11 @@ profile_divide(proftime_T *tm, int count, proftime_T *tm2)
189189# ifdef MSWIN
190190 tm2 -> QuadPart = tm -> QuadPart / count ;
191191# else
192- double usec = (tm -> tv_sec * 1000000.0 + tm -> tv_usec ) / count ;
192+ double fsec = (tm -> tv_sec * (float_T )TV_FSEC_SEC + tm -> tv_fsec )
193+ / count ;
193194
194- tm2 -> tv_sec = floor (usec / 1000000.0 );
195- tm2 -> tv_usec = vim_round (usec - (tm2 -> tv_sec * 1000000.0 ));
195+ tm2 -> tv_sec = floor (fsec / ( float_T ) TV_FSEC_SEC );
196+ tm2 -> tv_fsec = vim_round (fsec - (tm2 -> tv_sec * ( float_T ) TV_FSEC_SEC ));
196197# endif
197198 }
198199}
@@ -213,11 +214,11 @@ profile_add(proftime_T *tm, proftime_T *tm2)
213214# ifdef MSWIN
214215 tm -> QuadPart += tm2 -> QuadPart ;
215216# else
216- tm -> tv_usec += tm2 -> tv_usec ;
217+ tm -> tv_fsec += tm2 -> tv_fsec ;
217218 tm -> tv_sec += tm2 -> tv_sec ;
218- if (tm -> tv_usec >= 1000000 )
219+ if (tm -> tv_fsec >= TV_FSEC_SEC )
219220 {
220- tm -> tv_usec -= 1000000 ;
221+ tm -> tv_fsec -= TV_FSEC_SEC ;
221222 ++ tm -> tv_sec ;
222223 }
223224# endif
@@ -237,7 +238,7 @@ profile_self(proftime_T *self, proftime_T *total, proftime_T *children)
237238#else
238239 if (total -> tv_sec < children -> tv_sec
239240 || (total -> tv_sec == children -> tv_sec
240- && total -> tv_usec <= children -> tv_usec ))
241+ && total -> tv_fsec <= children -> tv_fsec ))
241242 return ;
242243#endif
243244 profile_add (self , total );
@@ -274,7 +275,7 @@ profile_equal(proftime_T *tm1, proftime_T *tm2)
274275# ifdef MSWIN
275276 return (tm1 -> QuadPart == tm2 -> QuadPart );
276277# else
277- return (tm1 -> tv_usec == tm2 -> tv_usec && tm1 -> tv_sec == tm2 -> tv_sec );
278+ return (tm1 -> tv_fsec == tm2 -> tv_fsec && tm1 -> tv_sec == tm2 -> tv_sec );
278279# endif
279280}
280281
@@ -288,7 +289,7 @@ profile_cmp(const proftime_T *tm1, const proftime_T *tm2)
288289 return (int )(tm2 -> QuadPart - tm1 -> QuadPart );
289290# else
290291 if (tm1 -> tv_sec == tm2 -> tv_sec )
291- return tm2 -> tv_usec - tm1 -> tv_usec ;
292+ return tm2 -> tv_fsec - tm1 -> tv_fsec ;
292293 return tm2 -> tv_sec - tm1 -> tv_sec ;
293294# endif
294295}
@@ -551,16 +552,16 @@ prof_func_line(
551552 {
552553 fprintf (fd , "%5d " , count );
553554 if (prefer_self && profile_equal (total , self ))
554- fprintf (fd , " " );
555+ fprintf (fd , PROF_TIME_BLANK );
555556 else
556557 fprintf (fd , "%s " , profile_msg (total ));
557558 if (!prefer_self && profile_equal (total , self ))
558- fprintf (fd , " " );
559+ fprintf (fd , PROF_TIME_BLANK );
559560 else
560561 fprintf (fd , "%s " , profile_msg (self ));
561562 }
562563 else
563- fprintf (fd , " " );
564+ fprintf (fd , " %s%s" , PROF_TIME_BLANK , PROF_TIME_BLANK );
564565}
565566
566567 static void
@@ -575,7 +576,7 @@ prof_sort_list(
575576 ufunc_T * fp ;
576577
577578 fprintf (fd , "FUNCTIONS SORTED ON %s TIME\n" , title );
578- fprintf (fd , "count total (s) self (s) function\n" );
579+ fprintf (fd , "%s function\n" , PROF_TOTALS_HEADER );
579580 for (i = 0 ; i < 20 && i < st_len ; ++ i )
580581 {
581582 fp = sorttab [i ];
@@ -858,7 +859,7 @@ func_dump_profile(FILE *fd)
858859 fprintf (fd , "Total time: %s\n" , profile_msg (& fp -> uf_tm_total ));
859860 fprintf (fd , " Self time: %s\n" , profile_msg (& fp -> uf_tm_self ));
860861 fprintf (fd , "\n" );
861- fprintf (fd , "count total (s) self (s) \n" );
862+ fprintf (fd , "%s \n" , PROF_TOTALS_HEADER );
862863
863864 for (i = 0 ; i < fp -> uf_lines .ga_len ; ++ i )
864865 {
@@ -948,7 +949,7 @@ script_dump_profile(FILE *fd)
948949 fprintf (fd , "Total time: %s\n" , profile_msg (& si -> sn_pr_total ));
949950 fprintf (fd , " Self time: %s\n" , profile_msg (& si -> sn_pr_self ));
950951 fprintf (fd , "\n" );
951- fprintf (fd , "count total (s) self (s) \n" );
952+ fprintf (fd , "%s \n" , PROF_TOTALS_HEADER );
952953
953954 sfd = mch_fopen ((char * )si -> sn_name , "r" );
954955 if (sfd == NULL )
0 commit comments