diff --git a/lib/modules/LR.pmod/parser.pike b/lib/modules/LR.pmod/parser.pike index 60873657d50356a48b3c1cfd66ae079da6f4b66a..a95da3d68248f0e2e314216d6c1d5b2557351d3c 100644 --- a/lib/modules/LR.pmod/parser.pike +++ b/lib/modules/LR.pmod/parser.pike @@ -1,5 +1,5 @@ /* - * $Id: parser.pike,v 1.19 1998/11/22 00:13:59 grubba Exp $ + * $Id: parser.pike,v 1.20 1999/10/10 00:49:11 noring Exp $ * * A BNF-grammar in Pike. * Compiles to a LALR(1) state-machine. @@ -9,7 +9,7 @@ //. //. File: parser.pike -//. RCSID: $Id: parser.pike,v 1.19 1998/11/22 00:13:59 grubba Exp $ +//. RCSID: $Id: parser.pike,v 1.20 1999/10/10 00:49:11 noring Exp $ //. Author: Henrik Grubbstr�m (grubba@infovav.se) //. //. Synopsis: LALR(1) parser and compiler. @@ -1127,7 +1127,7 @@ int compile() /* First make LR(0) states */ #ifdef LR_PROFILE - werror(sprintf("LR0: %d\n", gauge { + werror(sprintf("LR0: %f\n", gauge { #endif /* LR_PROFILE */ while (state = s_q->next()) { @@ -1154,7 +1154,7 @@ int compile() } #ifdef LR_PROFILE - werror(sprintf("Master items: %d\n", gauge { + werror(sprintf("Master items: %f\n", gauge { #endif /* LR_PROFILE */ /* Mark Transition and Reduction master items */ @@ -1180,7 +1180,7 @@ int compile() /* Probably OK so far */ #ifdef LR_PROFILE - werror(sprintf("LA sets: %d\n", gauge { + werror(sprintf("LA sets: %f\n", gauge { #endif /* LR_PROFILE */ /* Calculate look-ahead sets (DR and relation) */ @@ -1216,7 +1216,7 @@ int compile() #endif /* LR_PROFILE */ #ifdef LR_PROFILE - werror(sprintf("Handle shift: %d\n", gauge { + werror(sprintf("Handle shift: %f\n", gauge { #endif /* LR_PROFILE */ /* Handle SHIFT-conflicts */ @@ -1227,7 +1227,7 @@ int compile() #endif /* LR_PROFILE */ #ifdef LR_PROFILE - werror(sprintf("Check shift: %d\n", gauge { + werror(sprintf("Check shift: %f\n", gauge { #endif /* LR_PROFILE */ /* Check the shift sets */ @@ -1249,7 +1249,7 @@ int compile() #endif /* LR_PROFILE */ #ifdef LR_PROFILE - werror(sprintf("Lookback sets: %d\n", gauge { + werror(sprintf("Lookback sets: %f\n", gauge { #endif /* LR_PROFILE */ /* Compute lookback-sets */ @@ -1318,7 +1318,7 @@ int compile() #endif /* LR_PROFILE */ #ifdef LR_PROFILE - werror(sprintf("Handle follow: %d\n", gauge { + werror(sprintf("Handle follow: %f\n", gauge { #endif /* LR_PROFILE */ /* Handle follow-conflicts */ @@ -1329,7 +1329,7 @@ int compile() #endif /* LR_PROFILE */ #ifdef LR_PROFILE - werror(sprintf("Compute LA: %d\n", gauge { + werror(sprintf("Compute LA: %f\n", gauge { #endif /* LR_PROFILE */ /* Compute the lookahead (LA) */ @@ -1353,7 +1353,7 @@ int compile() /* Probably OK from this point onward */ #ifdef LR_PROFILE - werror(sprintf("Check conflicts: %d\n", gauge { + werror(sprintf("Check conflicts: %f\n", gauge { #endif /* LR_PROFILE */ /* Check for conflicts */ @@ -1400,7 +1400,7 @@ int compile() #endif /* LR_PROFILE */ #ifdef LR_PROFILE - werror(sprintf("Compile actions: %d\n", gauge { + werror(sprintf("Compile actions: %f\n", gauge { #endif /* LR_PROFILE */ /* Compile action tables */ diff --git a/src/language.yacc b/src/language.yacc index cdd883721edbf40bdeafa6dd32f625a9ce0496af..93c78275075d9a2d4e00dcfbf2e8fb6d776144dc 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -182,7 +182,7 @@ /* This is the grammar definition of Pike. */ #include "global.h" -RCSID("$Id: language.yacc,v 1.125 1999/10/09 23:28:58 hubbe Exp $"); +RCSID("$Id: language.yacc,v 1.126 1999/10/10 00:49:12 noring Exp $"); #ifdef HAVE_MEMORY_H #include <memory.h> #endif @@ -1830,20 +1830,22 @@ comma_expr_or_maxint: /* empty */ { $$=mkintnode(0x7fffffff); } gauge: F_GAUGE catch_arg { #ifdef HAVE_GETHRVTIME - $$=mkopernode("`-", + $$=mkefuncallnode("abs", mkopernode("`/", mkopernode("`-", mkefuncallnode("gethrvtime",0), mknode(F_ARG_LIST,$2, mkefuncallnode("gethrvtime",0))), - mkintnode(1000)), 0); + mkfloatnode((FLOAT_TYPE)1000000.0))); #else - $$=mkopernode("`-", - mkopernode("`-", - mknode(F_INDEX,mkefuncallnode("rusage",0), - mkintnode(GAUGE_RUSAGE_INDEX)), - mknode(F_ARG_LIST,$2, - mknode(F_INDEX,mkefuncallnode("rusage",0), - mkintnode(GAUGE_RUSAGE_INDEX)))),0); + $$=mkefuncallnode("abs", + mkopernode("`/", + mkopernode("`-", + mknode(F_INDEX,mkefuncallnode("rusage",0), + mkintnode(GAUGE_RUSAGE_INDEX)), + mknode(F_ARG_LIST,$2, + mknode(F_INDEX,mkefuncallnode("rusage",0), + mkintnode(GAUGE_RUSAGE_INDEX)))), + mkfloatnode((FLOAT_TYPE)1000.0))); #endif }; diff --git a/src/testsuite.in b/src/testsuite.in index 27a2696a22b68c86429a95a234f66657fd23b3ff..f804eca3eab63d914c15d65b555ddcd0ac1c15a8 100644 --- a/src/testsuite.in +++ b/src/testsuite.in @@ -1,4 +1,4 @@ -test_true([["$Id: testsuite.in,v 1.200 1999/10/04 20:47:53 hubbe Exp $"]]) +test_true([["$Id: testsuite.in,v 1.201 1999/10/10 00:49:13 noring Exp $"]]) cond([[all_constants()->_verify_internals]], [[ @@ -170,7 +170,7 @@ test_compile_error([[ int constant; ]]) test_compile_error([[ int import; ]]) test_compile_error([[ int inherit; ]]) test_compile_error([[ int catch; ]]) -test_compile_error([[ int gauge; ]]) +test_compile_error([[ float gauge; ]]) test_compile_error([[ int lambda; ]]) test_compile_error([[ int sscanf; ]]) test_compile_error([[ int switch; ]]) @@ -195,13 +195,13 @@ test_compile_error_low([[ -test_compile([[int x=(gauge { return; },1);]]) +test_compile([[float x=(gauge { return; },1.0);]]) cond( [[ master()->resolv("Gmp")->mpz ]], [[ test_compile_error([[object x = Gmp.mpz(17); constant y = x;]]) ]]) test_any([[object(Stdio.File) f; f=Stdio.File(); return 1]],1) -test_compile([[int t=gauge { string foo; };]]) +test_compile([[float t=gauge { string foo; };]]) test_compile_any([[class { object(Stdio.FILE) f; void create() { f=Stdio.FILE(); }}]]) test_eq([[compile_string("#define A(X) (X)\nint x() { return A \n\t(1); }")()->x()]],1) diff --git a/tutorial/tutorial.wmml b/tutorial/tutorial.wmml index 2c2ccdfedb348fe31af89c750dcdb042f39ee2f7..30cab216119f52e2b7ce4831a892b3ffd4541fd1 100644 --- a/tutorial/tutorial.wmml +++ b/tutorial/tutorial.wmml @@ -3485,10 +3485,10 @@ The syntax for gauge is the same as the syntax for catch: <example language=pike meta=statements> gauge { statements } </example> -However, gauge simply returns how many milliseconds the code took to execute. +However, gauge simply returns how many seconds the code took to execute. This can be used to find out how fast your code actually is.. :) Only CPU time used by the Pike process is measured. This means that if it takes -two seconds to execute but only uses 50% CPU, this function will return 1000. +two seconds to execute but only uses 50 % CPU, this function will return 1.0. </section> </anchor>