소스 검색

new function "clock"

Roberto Ierusalimschy 27 년 전
부모
커밋
abc6eac404
2개의 변경된 파일15개의 추가작업 그리고 4개의 파일을 삭제
  1. 7 1
      liolib.c
  2. 8 3
      manual.tex

+ 7 - 1
liolib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: liolib.c,v 1.16 1998/03/06 18:47:42 roberto Exp roberto $
+** $Id: liolib.c,v 1.17 1998/03/24 20:14:25 roberto Exp roberto $
 ** Standard I/O (and system) library
 ** See Copyright Notice in lua.h
 */
@@ -282,6 +282,11 @@ static void io_getenv (void)
 }
 
 
+static void io_clock (void) {
+  lua_pushnumber(((double)clock())/CLOCKS_PER_SEC);
+}
+
+
 static void io_date (void)
 {
   time_t t;
@@ -378,6 +383,7 @@ static struct luaL_reg iolib[] = {
 {"tmpname",   io_tmpname},
 {"getenv",   io_getenv},
 {"date",     io_date},
+{"clock",     io_clock},
 {"exit",     io_exit},
 {"debug",    io_debug},
 {"print_stack", errorfb}

+ 8 - 3
manual.tex

@@ -1,4 +1,4 @@
-% $Id: manual.tex,v 1.8 1998/04/02 16:09:16 roberto Exp roberto $
+% $Id: manual.tex,v 1.9 1998/05/18 22:26:03 roberto Exp roberto $
 
 \documentstyle[fullpage,11pt,bnf]{article}
 
@@ -38,7 +38,7 @@ Waldemar Celes
 \tecgraf\ --- Computer Science Department --- PUC-Rio
 }
 
-\date{\small \verb$Date: 1998/04/02 16:09:16 $}
+\date{\small \verb$Date: 1998/05/18 22:26:03 $}
 
 \maketitle
 
@@ -2600,7 +2600,12 @@ formatted according to the given string \verb|format|,
 following the same rules of the ANSI C function \verb|strftime|.
 When called without arguments,
 it returns a reasonable date and time representation that depends on
-the host system.
+the host system and the locale.
+
+\subsubsection*{\ff \T{clock ()}}\Deffunc{clock}
+
+This function returns an approximation of the amount of CPU time
+used by the program, in seconds.
 
 \subsubsection*{\ff \T{exit ([code])}}\Deffunc{exit}