comparison src/ex_cmds2.c @ 1496:29c09fa57168 v7.1.211

updated for version 7.1-211
author vimboss
date Sun, 06 Jan 2008 19:07:36 +0000
parents 6d95d8976b00
children 8d8dc7e07999
comparison
equal deleted inserted replaced
1495:04265ffbda1f 1496:29c09fa57168
893 893
894 QueryPerformanceFrequency(&fr); 894 QueryPerformanceFrequency(&fr);
895 sprintf(buf, "%10.6lf", (double)tm->QuadPart / (double)fr.QuadPart); 895 sprintf(buf, "%10.6lf", (double)tm->QuadPart / (double)fr.QuadPart);
896 # else 896 # else
897 sprintf(buf, "%3ld.%06ld", (long)tm->tv_sec, (long)tm->tv_usec); 897 sprintf(buf, "%3ld.%06ld", (long)tm->tv_sec, (long)tm->tv_usec);
898 #endif 898 # endif
899 return buf; 899 return buf;
900 } 900 }
901 901
902 # endif /* FEAT_PROFILE || FEAT_RELTIME */ 902 /*
903 903 * Put the time "msec" past now in "tm".
904 # if defined(FEAT_PROFILE) || defined(PROTO) 904 */
905 /* 905 void
906 * Functions for profiling. 906 profile_setlimit(msec, tm)
907 */ 907 long msec;
908 static void script_do_profile __ARGS((scriptitem_T *si)); 908 proftime_T *tm;
909 static void script_dump_profile __ARGS((FILE *fd)); 909 {
910 static proftime_T prof_wait_time; 910 if (msec <= 0) /* no limit */
911 profile_zero(tm);
912 else
913 {
914 # ifdef WIN3264
915 LARGE_INTEGER fr;
916
917 QueryPerformanceCounter(tm);
918 QueryPerformanceFrequency(&fr);
919 tm->QuadPart += (double)msec / 1000.0 * (double)fr.QuadPart;
920 # else
921 long usec;
922
923 gettimeofday(tm, NULL);
924 usec = (long)tm->tv_usec + (long)msec * 1000;
925 tm->tv_usec = usec % 1000000L;
926 tm->tv_sec += usec / 1000000L;
927 # endif
928 }
929 }
930
931 /*
932 * Return TRUE if the current time is past "tm".
933 */
934 int
935 profile_passed_limit(tm)
936 proftime_T *tm;
937 {
938 proftime_T now;
939
940 # ifdef WIN3264
941 if (tm->QuadPart == 0) /* timer was not set */
942 return FALSE;
943 QueryPerformanceCounter(&now);
944 return (now.QuadPart > tm->QuadPart);
945 # else
946 if (tm->tv_sec == 0) /* timer was not set */
947 return FALSE;
948 gettimeofday(&now, NULL);
949 return (now.tv_sec > tm->tv_sec
950 || (now.tv_sec == tm->tv_sec && now.tv_usec > tm->tv_usec));
951 # endif
952 }
911 953
912 /* 954 /*
913 * Set the time in "tm" to zero. 955 * Set the time in "tm" to zero.
914 */ 956 */
915 void 957 void
921 # else 963 # else
922 tm->tv_usec = 0; 964 tm->tv_usec = 0;
923 tm->tv_sec = 0; 965 tm->tv_sec = 0;
924 # endif 966 # endif
925 } 967 }
968
969 # endif /* FEAT_PROFILE || FEAT_RELTIME */
970
971 # if defined(FEAT_PROFILE) || defined(PROTO)
972 /*
973 * Functions for profiling.
974 */
975 static void script_do_profile __ARGS((scriptitem_T *si));
976 static void script_dump_profile __ARGS((FILE *fd));
977 static proftime_T prof_wait_time;
926 978
927 /* 979 /*
928 * Add the time "tm2" to "tm". 980 * Add the time "tm2" to "tm".
929 */ 981 */
930 void 982 void