Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/torch7.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Bottou <leon@bottou.org>2013-04-06 02:50:32 +0400
committerLeon Bottou <leon@bottou.org>2013-08-11 01:37:09 +0400
commitb416e79b8a43147b3e5656f40625a12d194007ef (patch)
tree1085b2ec7923e712ebf9f514034a48441c916456 /utils.c
parent962e1df4a7035141ee115e7d2543dc2db0f92fce (diff)
ported package torch to win
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/utils.c b/utils.c
index bbd70e8..6fd9eb4 100644
--- a/utils.c
+++ b/utils.c
@@ -1,7 +1,11 @@
#include "general.h"
#include "utils.h"
-#include <sys/time.h>
+#ifdef WIN32
+# include <time.h>
+#else
+# include <sys/time.h>
+#endif
#ifdef _OPENMP
#include <omp.h>
@@ -68,20 +72,29 @@ static int torch_isatty(lua_State *L)
return 1;
}
+static double real_time()
+{
+#ifdef LUA_WIN
+ time_t ltime;
+ time(&ltime);
+ return (double)(ltime);
+#else
+ struct timeval current;
+ gettimeofday(&current, NULL);
+ return (current.tv_sec + current.tv_usec/1000000.0);
+#endif
+}
+
static int torch_lua_tic(lua_State* L)
{
- struct timeval tv;
- gettimeofday(&tv,NULL);
- double ttime = (double)tv.tv_sec + (double)(tv.tv_usec)/1000000.0;
+ double ttime = real_time();
lua_pushnumber(L,ttime);
return 1;
}
static int torch_lua_toc(lua_State* L)
{
- struct timeval tv;
- gettimeofday(&tv,NULL);
- double toctime = (double)tv.tv_sec + (double)(tv.tv_usec)/1000000.0;
+ double toctime = real_time();
lua_Number tictime = luaL_checknumber(L,1);
lua_pushnumber(L,toctime-tictime);
return 1;