summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/luaprofiler/clocks.c
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2009-03-27 15:30:55 +0000
committerTaco Hoekwater <taco@elvenkind.com>2009-03-27 15:30:55 +0000
commit178de0871d690556af74f3768c11bc812b07f347 (patch)
treea939c31adc90d6207848effaec87dd78ec00e658 /Build/source/texk/web2c/luatexdir/luaprofiler/clocks.c
parent4865b23b5199697829e4e6633f2f697b4634c462 (diff)
Import of luatex 0.37.0 (autoreconf has not been run yet!)
git-svn-id: svn://tug.org/texlive/trunk@12529 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/luaprofiler/clocks.c')
-rw-r--r--Build/source/texk/web2c/luatexdir/luaprofiler/clocks.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/luatexdir/luaprofiler/clocks.c b/Build/source/texk/web2c/luatexdir/luaprofiler/clocks.c
new file mode 100644
index 00000000000..e693c48535f
--- /dev/null
+++ b/Build/source/texk/web2c/luatexdir/luaprofiler/clocks.c
@@ -0,0 +1,63 @@
+/*
+** LuaProfiler
+** Copyright Kepler Project 2005-2007 (http://www.keplerproject.org/luaprofiler)
+** $Id: clocks.c,v 1.4 2007/08/22 19:23:53 carregal Exp $
+*/
+
+/*****************************************************************************
+clocks.c:
+ Module to register the time (seconds) between two events
+
+Design:
+ 'lprofC_start_timer()' marks the first event
+ 'lprofC_get_seconds()' gives you the seconds elapsed since the timer
+ was started
+*****************************************************************************/
+
+#include <stdio.h>
+#include "clocks.h"
+
+/*
+ Here you can choose what time function you are going to use.
+ These two defines ('TIMES' and 'CLOCK') correspond to the usage of
+ functions times() and clock() respectively.
+ Which one is better? It depends on your needs:
+ TIMES - returns the clock ticks since the system was up
+ (you may use it if you want to measure a system
+ delay for a task, like time spent to get input from keyboard)
+ CLOCK - returns the clock ticks dedicated to the program
+ (this should be prefered in a multithread system and is
+ the default choice)
+
+ note: I guess TIMES don't work for win32
+*/
+
+#ifdef TIMES
+
+ #include <sys/times.h>
+
+ static struct tms t;
+
+ #define times(t) times(t)
+
+#else /* ifdef CLOCK */
+
+ #define times(t) clock()
+
+#endif
+
+
+void lprofC_start_timer(clock_t *time_marker) {
+ *time_marker = times(&t);
+}
+
+static clock_t get_clocks(clock_t time_marker) {
+ return times(&t) - time_marker;
+}
+
+float lprofC_get_seconds(clock_t time_marker) {
+clock_t clocks;
+ clocks = get_clocks(time_marker);
+ return (float)clocks / (float)CLOCKS_PER_SEC;
+}
+