aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-05-20 19:21:35 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-05-20 19:21:35 -0300
commitabc6eac404da8181ad945ac6950f61a65ba7dfa5 (patch)
tree6342898657f7dde13896fdfe3d5b9e6ef39d4d22
parent054e0b888a45bc143b8e4cb7a6b77eba0350bb49 (diff)
downloadlua-abc6eac404da8181ad945ac6950f61a65ba7dfa5.tar.gz
lua-abc6eac404da8181ad945ac6950f61a65ba7dfa5.tar.bz2
lua-abc6eac404da8181ad945ac6950f61a65ba7dfa5.zip
new function "clock"
-rw-r--r--liolib.c8
-rw-r--r--manual.tex11
2 files changed, 15 insertions, 4 deletions
diff --git a/liolib.c b/liolib.c
index 03a74d75..e963073f 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 1.16 1998/03/06 18:47:42 roberto Exp roberto $ 2** $Id: liolib.c,v 1.17 1998/03/24 20:14:25 roberto Exp roberto $
3** Standard I/O (and system) library 3** Standard I/O (and system) library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -282,6 +282,11 @@ static void io_getenv (void)
282} 282}
283 283
284 284
285static void io_clock (void) {
286 lua_pushnumber(((double)clock())/CLOCKS_PER_SEC);
287}
288
289
285static void io_date (void) 290static void io_date (void)
286{ 291{
287 time_t t; 292 time_t t;
@@ -378,6 +383,7 @@ static struct luaL_reg iolib[] = {
378{"tmpname", io_tmpname}, 383{"tmpname", io_tmpname},
379{"getenv", io_getenv}, 384{"getenv", io_getenv},
380{"date", io_date}, 385{"date", io_date},
386{"clock", io_clock},
381{"exit", io_exit}, 387{"exit", io_exit},
382{"debug", io_debug}, 388{"debug", io_debug},
383{"print_stack", errorfb} 389{"print_stack", errorfb}
diff --git a/manual.tex b/manual.tex
index ba31de32..eaf85fac 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,4 +1,4 @@
1% $Id: manual.tex,v 1.8 1998/04/02 16:09:16 roberto Exp roberto $ 1% $Id: manual.tex,v 1.9 1998/05/18 22:26:03 roberto Exp roberto $
2 2
3\documentstyle[fullpage,11pt,bnf]{article} 3\documentstyle[fullpage,11pt,bnf]{article}
4 4
@@ -38,7 +38,7 @@ Waldemar Celes
38\tecgraf\ --- Computer Science Department --- PUC-Rio 38\tecgraf\ --- Computer Science Department --- PUC-Rio
39} 39}
40 40
41\date{\small \verb$Date: 1998/04/02 16:09:16 $} 41\date{\small \verb$Date: 1998/05/18 22:26:03 $}
42 42
43\maketitle 43\maketitle
44 44
@@ -2600,7 +2600,12 @@ formatted according to the given string \verb|format|,
2600following the same rules of the ANSI C function \verb|strftime|. 2600following the same rules of the ANSI C function \verb|strftime|.
2601When called without arguments, 2601When called without arguments,
2602it returns a reasonable date and time representation that depends on 2602it returns a reasonable date and time representation that depends on
2603the host system. 2603the host system and the locale.
2604
2605\subsubsection*{\ff \T{clock ()}}\Deffunc{clock}
2606
2607This function returns an approximation of the amount of CPU time
2608used by the program, in seconds.
2604 2609
2605\subsubsection*{\ff \T{exit ([code])}}\Deffunc{exit} 2610\subsubsection*{\ff \T{exit ([code])}}\Deffunc{exit}
2606 2611