diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-05-20 19:21:35 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-05-20 19:21:35 -0300 |
| commit | abc6eac404da8181ad945ac6950f61a65ba7dfa5 (patch) | |
| tree | 6342898657f7dde13896fdfe3d5b9e6ef39d4d22 | |
| parent | 054e0b888a45bc143b8e4cb7a6b77eba0350bb49 (diff) | |
| download | lua-abc6eac404da8181ad945ac6950f61a65ba7dfa5.tar.gz lua-abc6eac404da8181ad945ac6950f61a65ba7dfa5.tar.bz2 lua-abc6eac404da8181ad945ac6950f61a65ba7dfa5.zip | |
new function "clock"
Diffstat (limited to '')
| -rw-r--r-- | liolib.c | 8 | ||||
| -rw-r--r-- | manual.tex | 11 |
2 files changed, 15 insertions, 4 deletions
| @@ -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 | ||
| 285 | static void io_clock (void) { | ||
| 286 | lua_pushnumber(((double)clock())/CLOCKS_PER_SEC); | ||
| 287 | } | ||
| 288 | |||
| 289 | |||
| 285 | static void io_date (void) | 290 | static 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} |
| @@ -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|, | |||
| 2600 | following the same rules of the ANSI C function \verb|strftime|. | 2600 | following the same rules of the ANSI C function \verb|strftime|. |
| 2601 | When called without arguments, | 2601 | When called without arguments, |
| 2602 | it returns a reasonable date and time representation that depends on | 2602 | it returns a reasonable date and time representation that depends on |
| 2603 | the host system. | 2603 | the host system and the locale. |
| 2604 | |||
| 2605 | \subsubsection*{\ff \T{clock ()}}\Deffunc{clock} | ||
| 2606 | |||
| 2607 | This function returns an approximation of the amount of CPU time | ||
| 2608 | used 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 | ||
