summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds2.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2008-01-06 19:07:36 +0000
committerBram Moolenaar <Bram@vim.org>2008-01-06 19:07:36 +0000
commit76929293e03d4595c95171fc82be05a64673d42e (patch)
treee13452e87e1ca9773bf648f3a8438eb716ac2f82 /src/ex_cmds2.c
parent6203ff97b715e0112f90587f9ce576ef0e7798bc (diff)
updated for version 7.1-211v7.1.211
Diffstat (limited to 'src/ex_cmds2.c')
-rw-r--r--src/ex_cmds2.c66
1 files changed, 59 insertions, 7 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index dbbd8eca68..2eeb7527d3 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -895,19 +895,61 @@ profile_msg(tm)
sprintf(buf, "%10.6lf", (double)tm->QuadPart / (double)fr.QuadPart);
# else
sprintf(buf, "%3ld.%06ld", (long)tm->tv_sec, (long)tm->tv_usec);
-#endif
+# endif
return buf;
}
-# endif /* FEAT_PROFILE || FEAT_RELTIME */
+/*
+ * Put the time "msec" past now in "tm".
+ */
+ void
+profile_setlimit(msec, tm)
+ long msec;
+ proftime_T *tm;
+{
+ if (msec <= 0) /* no limit */
+ profile_zero(tm);
+ else
+ {
+# ifdef WIN3264
+ LARGE_INTEGER fr;
+
+ QueryPerformanceCounter(tm);
+ QueryPerformanceFrequency(&fr);
+ tm->QuadPart += (double)msec / 1000.0 * (double)fr.QuadPart;
+# else
+ long usec;
+
+ gettimeofday(tm, NULL);
+ usec = (long)tm->tv_usec + (long)msec * 1000;
+ tm->tv_usec = usec % 1000000L;
+ tm->tv_sec += usec / 1000000L;
+# endif
+ }
+}
-# if defined(FEAT_PROFILE) || defined(PROTO)
/*
- * Functions for profiling.
+ * Return TRUE if the current time is past "tm".
*/
-static void script_do_profile __ARGS((scriptitem_T *si));
-static void script_dump_profile __ARGS((FILE *fd));
-static proftime_T prof_wait_time;
+ int
+profile_passed_limit(tm)
+ proftime_T *tm;
+{
+ proftime_T now;
+
+# ifdef WIN3264
+ if (tm->QuadPart == 0) /* timer was not set */
+ return FALSE;
+ QueryPerformanceCounter(&now);
+ return (now.QuadPart > tm->QuadPart);
+# else
+ if (tm->tv_sec == 0) /* timer was not set */
+ return FALSE;
+ gettimeofday(&now, NULL);
+ return (now.tv_sec > tm->tv_sec
+ || (now.tv_sec == tm->tv_sec && now.tv_usec > tm->tv_usec));
+# endif
+}
/*
* Set the time in "tm" to zero.
@@ -924,6 +966,16 @@ profile_zero(tm)
# endif
}
+# endif /* FEAT_PROFILE || FEAT_RELTIME */
+
+# if defined(FEAT_PROFILE) || defined(PROTO)
+/*
+ * Functions for profiling.
+ */
+static void script_do_profile __ARGS((scriptitem_T *si));
+static void script_dump_profile __ARGS((FILE *fd));
+static proftime_T prof_wait_time;
+
/*
* Add the time "tm2" to "tm".
*/