Here's an alternative hack: do it all in mclient.

--- MapiClient.mx       13 Apr 2010 15:40:07 z  1.203
+++ MapiClient.mx       14 Apr 2010 11:16:21 z  
@@ -881,12 +881,19 @@
 RAWrenderer(MapiHdl hdl)
 {
        char *line;
+       size_t n;

        SQLqueryEcho(hdl);
        while ((line = fetch_line(hdl)) != 0) {
                if (*line == '=')
                        line++;
-               stream_printf(toConsole, "%s\n", line);
+               if (mode == XQUERY && mark &&
+                   (n = strlen(line)) > 5 &&
+                   strncmp(line + n - 5, " msec", 5) == 0) {
+                       stream_flush(toConsole);
+                       fprintf(stderr, "%s\n", line);
+               } else
+                       stream_printf(toConsole, "%s\n", line);
        }
 }


On 14-4-2010 12:39, Stefan Manegold wrote:
> On Tue, Apr 13, 2010 at 12:43:06PM +0000, Sjoerd Mullender wrote:
>> Update of /cvsroot/monetdb/clients/src/mapiclient
>> In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv15694
>>
>> Modified Files:
>>      MapiClient.mx 
>> Log Message:
>> Once again print timer information to stderr.
>> If you want to combine timer information with the regular output, you
>> can do
>>      mclient -t ... 2>&1
>> This works since the standard output is flushed before the timer
>> information is printed.
>> And if you only want timer information, you can do
>>      mclient -t ... >/dev/null
>>
> 
> I briefly tried to do the same for break-down timings given by pathfinder
> (MonetDB/XQuery), but the changes (see diff below) don't help, mainly since
> the break-down timings are printed in MIL, and even fprintf(stderr(), ...)
> in MIL goes to stdout due to
> MonetDB/src/gdk/gdk.mx:2737:#define GDKerr            GDKout
> 
> which is probably required because MAPI only used one stream.
> 
> I'm not sure whether it's worth to persue this fruther, e.g., by making
> mclient aware of the pathfinder/XQuery break-down timings and have re-direct
> them to (its) stderr ...
> 
> Stefan
> 
> ========
> Index: pathfinder/compiler/include/mil.h
> ===================================================================
> RCS file: /cvsroot/monetdb/pathfinder/compiler/include/mil.h,v
> retrieving revision 1.89
> diff -u -r1.89 mil.h
> --- pathfinder/compiler/include/mil.h 7 Jan 2010 15:24:27 -0000       1.89
> +++ pathfinder/compiler/include/mil.h 14 Apr 2010 10:33:26 -0000
> @@ -385,6 +385,7 @@
>  
>      , m_print        /**< MIL print() function */
>      , m_printf       /**< MIL printf() function */
> +    , m_printerr     /**< MIL fprintf(stderr(),...) function */
>  
>      , m_col_name     /**< assign BAT column name (for debugging only) */
>  
> @@ -1014,6 +1015,7 @@
>  
>  PFmil_t * PFmil_print (const PFmil_t *);
>  PFmil_t * PFmil_printf (const PFmil_t *);
> +PFmil_t * PFmil_printerr (const PFmil_t *);
>  PFmil_t * PFmil_col_name (const PFmil_t *, const PFmil_t *);
>  PFmil_t * PFmil_comment (const char *, ...)
>        __attribute__ ((format (printf, 1, 2)));
> Index: pathfinder/compiler/compile.c
> ===================================================================
> RCS file: /cvsroot/monetdb/pathfinder/compiler/compile.c,v
> retrieving revision 1.186
> diff -u -r1.186 compile.c
> --- pathfinder/compiler/compile.c     7 Jan 2010 15:24:27 -0000       1.186
> +++ pathfinder/compiler/compile.c     14 Apr 2010 10:33:26 -0000
> @@ -801,7 +801,7 @@
>      /* make runtime timing available */
>      if (status->timing) {
>          mroot = PFmil_seq (mroot,
> -                           PFmil_printf (
> +                           PFmil_printerr (
>                                 PFmil_arg (PFmil_lit_str ("\nShred  % 10.3f 
> msec"
>                                                           "\nQuery  % 10.3f 
> msec"
>                                                           "\nPrint  % 10.3f 
> msec\n"),
> @@ -1082,7 +1082,7 @@
>          if (!strncmp ("timing", genType, 6))
>              /* add timing information */
>              mroot = PFmil_seq (mroot,
> -                               PFmil_printf (
> +                               PFmil_printerr (
>                                     PFmil_arg (PFmil_lit_str ("\nTrans  % 
> 10.3f msec"
>                                                               "\nShred  % 
> 10.3f msec"
>                                                               "\nQuery  % 
> 10.3f msec"
> Index: pathfinder/compiler/mil/mil.c
> ===================================================================
> RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/mil.c,v
> retrieving revision 1.86
> diff -u -r1.86 mil.c
> --- pathfinder/compiler/mil/mil.c     7 Jan 2010 15:24:28 -0000       1.86
> +++ pathfinder/compiler/mil/mil.c     14 Apr 2010 10:33:26 -0000
> @@ -1896,6 +1896,12 @@
>  }
>  
>  PFmil_t *
> +PFmil_printerr (const PFmil_t *args)
> +{
> +    return wire1 (m_printerr, args);
> +}
> +
> +PFmil_t *
>  PFmil_col_name (const PFmil_t *bat, const PFmil_t *name)
>  {
>      return wire2 (m_col_name, bat, name);
> Index: pathfinder/compiler/mil/mil_dce.c
> ===================================================================
> RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/mil_dce.c,v
> retrieving revision 1.34
> diff -u -r1.34 mil_dce.c
> --- pathfinder/compiler/mil/mil_dce.c 7 Jan 2010 15:24:28 -0000       1.34
> +++ pathfinder/compiler/mil/mil_dce.c 14 Apr 2010 10:33:27 -0000
> @@ -474,6 +474,7 @@
>          case m_error:
>          case m_print:
>          case m_printf:
> +        case m_printerr:
>          case m_break:
>          case m_use:
>          case m_update_tape:
> Index: pathfinder/compiler/mil/milprint.c
> ===================================================================
> RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milprint.c,v
> retrieving revision 1.101
> diff -u -r1.101 milprint.c
> --- pathfinder/compiler/mil/milprint.c        7 Jan 2010 15:24:28 -0000       
> 1.101
> +++ pathfinder/compiler/mil/milprint.c        14 Apr 2010 10:33:27 -0000
> @@ -28,6 +28,7 @@
>                   | 'ERROR (' expression ')'                 <m_error>
>                   | 'print (' args ')'                       <m_print>
>                   | 'printf (' args ')'                      <m_printf>
> +                 | 'printerr (' args ')'                    <m_printerr>
>                   | 'col_name (' expr ',' expr ')'           <m_col_name>
>                   | 'destroy_ws (' expression ')'            <m_destroy_ws>
>                   | 'end_ws (' expression ',' expression ')' <m_end_ws>
> @@ -673,6 +674,13 @@
>              milprintf (")");
>              break;
>  
> +        /* statement: 'fprintf ( stderr (), ' expression ')' */
> +        case m_printerr:
> +            milprintf ("fprintf ( stderr (),");
> +            print_args (n->child[0]);
> +            milprintf (")");
> +            break;
> +
>          case m_col_name:
>              print_expression (n->child[0]);
>              milprintf (".%s (", ID[n->kind]);
> Index: pathfinder/compiler/mil/milprint_summer.c
> ===================================================================
> RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milprint_summer.c,v
> retrieving revision 1.438
> diff -u -r1.438 milprint_summer.c
> --- pathfinder/compiler/mil/milprint_summer.c 12 Jan 2010 09:22:14 -0000      
> 1.438
> +++ pathfinder/compiler/mil/milprint_summer.c 14 Apr 2010 10:33:27 -0000
> @@ -11616,7 +11616,7 @@
>          "  ERROR(err); -(try);\n"\
>          "} else if (genType.startsWith(\"timing\")) {\n"\
>          "  time_print := usec() - time_print;\n"\
> -        "  printf(\"\\nTrans  %% 10.3f msec\\nShred  %% 10.3f msec\\nQuery  
> %% 10.3f msec\\n" LASTPHASE " %% 10.3f msec\\n\","\
> +        "  fprintf(stderr(),\"\\nTrans  %% 10.3f msec\\nShred  %% 10.3f 
> msec\\nQuery  %% 10.3f msec\\n" LASTPHASE " %% 10.3f msec\\n\","\
>          "      dbl(time_compile)/1000.0, dbl(time_shred)/1000.0, 
> dbl(time_exec - time_shred)/1000.0, time_print/1000.0);\n}"
>  
>  const char* PFstopMIL(int statement_type) {
> Index: pathfinder/runtime/pathfinder.mx
> ===================================================================
> RCS file: /cvsroot/monetdb/pathfinder/runtime/pathfinder.mx,v
> retrieving revision 1.480
> diff -u -r1.480 pathfinder.mx
> --- pathfinder/runtime/pathfinder.mx  12 Apr 2010 09:20:51 -0000      1.480
> +++ pathfinder/runtime/pathfinder.mx  14 Apr 2010 10:33:27 -0000
> @@ -6336,7 +6336,7 @@
>              /* execute query */
>              xquery = p+1;
>  if (p[1] == '4' && p[2] == '2' && p[3] == '\n' && p[4] == 0 && genType == 
> buf && output[2] == 0) { /* use '42' as latency query test */ 
> -    stream_printf(GDKout, "42\n\nTrans       0.000 msec\nShred       0.000 
> msec\nQuery       0.000 msec\nPrint       0.000 msec\n"); 
> +    stream_printf(GDKerr, "42\n\nTrans       0.000 msec\nShred       0.000 
> msec\nQuery       0.000 msec\nPrint       0.000 msec\n"); 
>  } else {
>              err = xquery_change_genType(ctx, genType);
>              if (err == NULL) 
> ========
> 
>>
>> Index: MapiClient.mx
>> ===================================================================
>> RCS file: /cvsroot/monetdb/clients/src/mapiclient/MapiClient.mx,v
>> retrieving revision 1.201
>> retrieving revision 1.202
>> diff -u -d -r1.201 -r1.202
>> --- MapiClient.mx    29 Mar 2010 18:45:15 -0000      1.201
>> +++ MapiClient.mx    13 Apr 2010 12:43:04 -0000      1.202
>> @@ -332,10 +332,11 @@
>>  static void
>>  timerEnd(void)
>>  {
>> +    stream_flush(toConsole);
>>      t1 = gettime();
>>      if (mark && specials == NOmodifier) {
>> -            stream_printf(toConsole, "%s %7ld.%03ld msec %s\n", mark, 
>> (long) ((t1 - t0) / 1000), (long) ((t1 - t0) % 1000), mark2 ? mark2 : "");
>> -            stream_flush(toConsole);
>> +            fprintf(stderr, "%s %7ld.%03ld msec %s\n", mark, (long) ((t1 - 
>> t0) / 1000), (long) ((t1 - t0) % 1000), mark2 ? mark2 : "");
>> +            fflush(stderr);
>>      }
>>  }
>>  
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Monetdb-checkins mailing list
>> monetdb-check...@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/monetdb-checkins
> 


-- 
Sjoerd Mullender

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Monetdb-developers mailing list
Monetdb-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/monetdb-developers

Reply via email to