Changeset: 78546e443dd3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=78546e443dd3
Modified Files:
        clients/mapiclient/mclient.1
        clients/mapiclient/mclient.c
Branch: Mar2018
Log Message:

mclient, timerHuman(): report all timing on stderr rather than stdout,
as per feature request / bug 6536 .


diffs (96 lines):

diff --git a/clients/mapiclient/mclient.1 b/clients/mapiclient/mclient.1
--- a/clients/mapiclient/mclient.1
+++ b/clients/mapiclient/mclient.1
@@ -159,6 +159,7 @@ The \fItimer\fP command controls the for
 The default mode is \fBnone\fP which turns off timing reporting.
 The timer mode \fBclock\fP reports the wall-clock time in a human friendly way.
 The timer mode \fBperformance\fP shows the timing components in millisecond 
resolution.
+All timings are reported on stderr.
 .br
 \fBNote\fP that the client-measured wall-clock time is reported per query
 \fBonly\fP when options \fB--interactive\fP or \fB--echo\fP are used,
@@ -167,12 +168,6 @@ script to the server. Otherwise, when mc
 large(r) batch(es), only the total wall-clock time per batch is measured and
 reported. The server-measured detailed performance timings are alsways
 measured and reported per query.
-.br
-\fBNote\fP that timermode \fBnone\fP (\fB--timer=none\fP) should be used with 
formatting options
-.B csv,
-.B tab,
-.B xml,
-in order to not have the output(-format) compromized/invalidated by the extra 
timing output.
 .TP
 \fB\-\-user\fP\fB=\fP\fIuser\fP (\fB\-u\fP \fIuser\fP)
 Specify the user to connect as.
@@ -211,12 +206,6 @@ In addition to plain \fBcsv\fP, two othe
 \fBcsv=\fP\fIc\fP uses \fIc\fP as column separator; \fBcsv+\fP\fIc\fP
 uses \fIc\fP as column separator and produces a single header line in
 addition to the data.
-.br
-\fBNote\fP that timermode \fBnone\fP (\fB--timer=none\fP) should be used with 
formatting options
-.B csv,
-.B tab,
-.B xml,
-in order to not have the output(-format) compromized/invalidated by the extra 
timing output.
 .TP
 \fB\-\-echo\fP (\fB\-e\fP)
 Echo the query.
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -275,35 +275,47 @@ timerHuman(int64_t sqloptimizer, int64_t
         */
 
        if (timermode == T_CLOCK && (!singleinstr != !total)) { /* (singleinstr 
XOR total) */
+               fflush(stderr);
+               mnstr_flush(toConsole);
                if (t / 1000 < 1000) {
-                       mnstr_printf(toConsole, "clk: %" PRId64 ".%03d ms\n", t 
/ 1000, (int) (t % 1000));
+                       fprintf(stderr, "clk: %" PRId64 ".%03d ms\n", t / 1000, 
(int) (t % 1000));
+                       fflush(stderr);
                        return;
                }
                t /= 1000;
                if (t / 1000 < 60) {
-                       mnstr_printf(toConsole, "clk: %" PRId64 ".%03d sec\n", 
t / 1000, (int) (t % 1000));
+                       fprintf(stderr, "clk: %" PRId64 ".%03d sec\n", t / 
1000, (int) (t % 1000));
+                       fflush(stderr);
                        return;
                }
                t /= 1000;
                if (t / 60 < 60) {
-                       mnstr_printf(toConsole, "clk: %" PRId64 ":%02d min\n", 
t / 60, (int) (t % 60));
+                       fprintf(stderr, "clk: %" PRId64 ":%02d min\n", t / 60, 
(int) (t % 60));
+                       fflush(stderr);
                        return;
                }
                t /= 60;
-               mnstr_printf(toConsole, "clk: %" PRId64 ":%02d h\n", t / 60, 
(int) (t % 60));
+               fprintf(stderr, "clk: %" PRId64 ":%02d h\n", t / 60, (int) (t % 
60));
+               fflush(stderr);
                return;
        }
        /* for performance measures we use milliseconds as the base */
        if (timermode == T_PERF) {
+               if ((!singleinstr != !total) || !total) {
+                       fflush(stderr);
+                       mnstr_flush(toConsole);
+               }
                if (!singleinstr != !total) /* (singleinstr XOR total) */
-                       mnstr_printf(toConsole, "clk:%" PRId64 ".%03d ", t / 
1000, (int) (t % 1000));
+                       fprintf(stderr, "clk:%" PRId64 ".%03d ", t / 1000, 
(int) (t % 1000));
                if (!total)
-                       mnstr_printf(toConsole, "sql:%" PRId64 ".%03d opt:%" 
PRId64 ".%03d run:%" PRId64 ".%03d ",
+                       fprintf(stderr, "sql:%" PRId64 ".%03d opt:%" PRId64 
".%03d run:%" PRId64 ".%03d ",
                                 sqloptimizer / 1000, (int) (sqloptimizer % 
1000),
                                 maloptimizer / 1000, (int) (maloptimizer % 
1000),
                                 querytime / 1000, (int) (querytime % 1000));
-               if ((!singleinstr != !total) || !total)
-                       mnstr_printf(toConsole, "ms\n");
+               if ((!singleinstr != !total) || !total) {
+                       fprintf(stderr, "ms\n");
+                       fflush(stderr);
+               }
                return;
        }
        return;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to