Changeset: 14b5709c40c6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=14b5709c40c6
Modified Files:
        clients/mapiclient/tachograph.c
        clients/mapiclient/tomograph.c
Branch: default
Log Message:

Simplify interface
- output directive only comes from -o argument
- internal re-naming
- minor output polishing, pending logo addition


diffs (truncated from 561 to 300 lines):

diff --git a/clients/mapiclient/tachograph.c b/clients/mapiclient/tachograph.c
--- a/clients/mapiclient/tachograph.c
+++ b/clients/mapiclient/tachograph.c
@@ -67,9 +67,12 @@
 
 static stream *conn = NULL;
 static char hostname[128];
-static char *basefilename = "tachograph";
-static char *cache= "cache";
-static char cachebuf[BUFSIZ]={0};
+static char *prefix = "tachograph";
+#ifdef NATIVE_WIN32
+static char *dirpath= "cache\\";
+#else
+static char *dirpath= "cache/";
+#endif
 static char *dbname;
 static int beat = 5000;
 static int delay = 0; // ms
@@ -507,25 +510,25 @@ initFiles(void)
 {
        char buf[BUFSIZ];
 
-       snprintf(buf,BUFSIZ,"%s%s_%s_%d.json", cachebuf, basefilename, dbname, 
queryid);
+       snprintf(buf,BUFSIZ,"%s%s_%d.json", dirpath, prefix, queryid);
        tachojson= fopen(buf,"w");
        if( tachojson == NULL){
                fprintf(stderr,"Could not create %s\n",buf);
                exit(-1);
        }
-       snprintf(buf,BUFSIZ,"%s%s_%s_%d_mal.csv",cachebuf, basefilename, 
dbname, queryid);
+       snprintf(buf,BUFSIZ,"%s%s_%d_mal.csv",dirpath, prefix, queryid);
        tachomal= fopen(buf,"w");
        if( tachomal == NULL){
                fprintf(stderr,"Could not create %s\n",buf);
                exit(-1);
        }
-       snprintf(buf,BUFSIZ,"%s%s_%s_%d_stmt.csv", cachebuf, basefilename, 
dbname, queryid);
+       snprintf(buf,BUFSIZ,"%s%s_%d_stmt.csv", dirpath, prefix, queryid);
        tachostmt= fopen(buf,"w");
        if( tachostmt == NULL){
                fprintf(stderr,"Could not create %s\n",buf);
                exit(-1);
        }
-       snprintf(buf,BUFSIZ,"%s%s_%s_%d.trace", cachebuf, basefilename, dbname, 
queryid);
+       snprintf(buf,BUFSIZ,"%s%s_%d.trace", dirpath, prefix, queryid);
        tachotrace= fopen(buf,"w");
        if( tachotrace == NULL){
                fprintf(stderr,"Could not create %s\n",buf);
@@ -592,7 +595,8 @@ update(EventRecord *ev)
        /* monitor top level function brackets, we restrict ourselves to SQL 
queries */
        if (ev->state == MDB_START && ev->fcn && strncmp(ev->fcn, "function", 
8) == 0) {
                if( capturing){
-                       fprintf(stderr,"We lost some events\n");
+                       fprintf(stderr,"Input garbled or we lost some 
events\n");
+                       eventdump();
                        resetTachograph();
                        capturing = 0;
                }
@@ -793,6 +797,7 @@ main(int argc, char **argv)
        int i = 0;
        FILE *trace = NULL;
        EventRecord event;
+       char *s;
 
        static struct option long_options[15] = {
                { "dbname", 1, 0, 'd' },
@@ -804,7 +809,6 @@ main(int argc, char **argv)
                { "beat", 1, 0, 'b' },
                { "interactive", 1, 0, 'i' },
                { "output", 1, 0, 'o' },
-               { "cache", 1, 0, 'c' },
                { "queries", 1, 0, 'q' },
                { "wait", 1, 0, 'w' },
                { "debug", 0, 0, 'D' },
@@ -862,13 +866,19 @@ main(int argc, char **argv)
                        host = optarg;
                        break;
                case 'o':
-                       basefilename = strdup(optarg);
-                       if( strstr(basefilename,".trace"))
-                               *strstr(basefilename,".trace") = 0;
-                       printf("-- Output directed towards %s\n", basefilename);
-                       break;
-               case 'c': // cache directory
-                       cache = strdup(optarg);
+                       //store the output files in a specific place
+                       prefix = strdup(optarg);
+#ifdef NATIVE_WIN32
+                       s= strrchr(prefix, (int) '\\');
+#else
+                       s= strrchr(prefix, (int) '/');
+#endif
+                       if( s ){
+                               dirpath= prefix;
+                               prefix = strdup(prefix);
+                               *(s+1) = 0;
+                               prefix += s-dirpath;
+                       } 
                        break;
                case '?':
                        usageTachograph();
@@ -882,21 +892,12 @@ main(int argc, char **argv)
                }
        }
 
-       if (cache)
-#ifdef NATIVE_WIN32
-               snprintf(cachebuf,BUFSIZ,"%s\\",cache);
-#else
-               snprintf(cachebuf,BUFSIZ,"%s/",cache);
-#endif
        if ( dbname == NULL){
                fprintf(stderr,"Database name missing\n");
                usageTachograph();
                exit(-1);
        }
 
-       if(debug)
-               printf("tachograph -d %s -c %s -o 
%s\n",dbname,cache,basefilename);
-
        if (dbname != NULL && strncmp(dbname, "mapi:monetdb://", 15) == 0) {
                uri = dbname;
                dbname = NULL;
@@ -958,17 +959,15 @@ main(int argc, char **argv)
        if( debug)
                fprintf(stderr,"-- %s\n",buf);
        doQ(buf);
-       if( cache){
 #ifdef NATIVE_WIN32
-               if( _mkdir(cache) < 0 && errno != EEXIST){
+       if( _mkdir(dirpath) < 0 && errno != EEXIST){
 #else
-               if( mkdir(cache,0755)  < 0 && errno != EEXIST) {
+       if( mkdir(dirpath,0755)  < 0 && errno != EEXIST) {
 #endif
-                       fprintf(stderr,"Failed to create cache '%s'\n",cache);
-                       exit(-1);
-               }
-       } 
-       snprintf(buf,BUFSIZ,"%s%s_%s.trace", cachebuf, basefilename,dbname);
+               fprintf(stderr,"Failed to create '%s'\n",dirpath);
+               exit(-1);
+       }
+       snprintf(buf,BUFSIZ,"%s%s.trace", dirpath, prefix);
        // keep a trace of the events received
        trace = fopen(buf,"w");
        if( trace == NULL){
diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c
--- a/clients/mapiclient/tomograph.c
+++ b/clients/mapiclient/tomograph.c
@@ -8,11 +8,11 @@
 
 /* (c) M Kersten, S Manegold
  * The easiest calling method is something like:
- * tomograph -d demo --atlas=10
+ * tomograph -d demo --atlast=10
  * which connects to the demo database server and
  * will collect the tomograph pages for at most 10 SQL queries
  * For each page a gnuplot file, a data file, and the event trace
- * are collected for more focused analysis.
+ * are collected for more focussed analysis.
  * 
 */
 
@@ -68,17 +68,17 @@
                        die(dbh, hdl);                  \
        } while (0)
 
-#define DBNAME (dbname?dbname:(inputfile?inputfile:"unknown"))
-
 static stream *conn = NULL;
 static char hostname[128];
-static char *basefilename = "tomograph";
 static char *dbname = NULL;
-static char *cache= "cache";
-static char cachebuf[BUFSIZ]={0};
+#ifdef NATIVE_WIN32
+static char *dirpath= "cache\\";
+#else
+static char *dirpath= "cache/";
+#endif
+static char *prefix = "tomograph";
 static FILE *tracefd;
 static lng startrange = 0, endrange = 0;
-static int systemcall = 1; // attempt system call
 static char *inputfile = NULL;
 static char *title = 0;
 static char *query = 0;
@@ -104,7 +104,7 @@ static int source[MAXTHREADS];
 
 /* color map management, fixed */
 /* see 
http://www.uni-hamburg.de/Wiss/FB/15/Sustainability/schneider/gnuplot/colors.htm
 */
-/* The initial dictionary is geared towards TPCH-use */
+/* The initial dictionary is geared towars TPCH-use */
 typedef struct COLOR {
        int freq;
        lng timeused;
@@ -410,7 +410,7 @@ showNumaHeatmap(void){
        char buf[BUFSIZ];
 
        
-       snprintf(buf,BUFSIZ,"%stomograph_%s_heatmap.csv",cachebuf,DBNAME);
+       snprintf(buf,BUFSIZ,"%s%s_heatmap.csv",dirpath,prefix);
        f= fopen(buf,"a");
        if( f == NULL){
                fprintf(stderr,"Can not create %s\n",buf);
@@ -451,9 +451,7 @@ usageTomograph(void)
        fprintf(stderr, "  -T | --title=<plot title>\n");
        fprintf(stderr, "  -r | --range=<starttime>-<endtime>[ms,s] \n");
        fprintf(stderr, "  -i | --input=<profiler event file > \n");
-       fprintf(stderr, "  -o | --output=<file prefix > (default 
'tomograph'\n");
-       fprintf(stderr, "  -c | --cache=<query pool location>\n");
-       fprintf(stderr, "  -s | --system=# (on= 1(default) off=0\n");
+       fprintf(stderr, "  -o | --output=<dir/file prefix > (default 
'cache/<dbname>'\n");
        fprintf(stderr, "  -b | --beat=<delay> in milliseconds (default 
5000)\n");
        fprintf(stderr, "  -A | --atlas=<number> maximum number of queries 
(default 1)\n");
        fprintf(stderr, "  -D | --debug\n");
@@ -481,19 +479,19 @@ stop_disconnect:
                createTomogram();
        // show follow up action only once
        if(atlaspage >= 1){
-               for (i = 0; systemcall && i< atlaspage;  i++){
-                       snprintf(buf, BUFSIZ, "gnuplot %s%s_%s_%02d.gpl;", 
cachebuf, basefilename, DBNAME, i);
+               for (i = 0; i < atlaspage;  i++){
+                       snprintf(buf, BUFSIZ, "gnuplot %s%s_%02d.gpl;", 
dirpath, prefix, i);
                        if( error == 0){
                                fprintf(stderr,"-- exec:%s\n",buf);
                                error = system(buf);
                                if( error){
                                        fprintf(stderr, "To finish the atlas 
make sure gnuplot is available and run:\n");
                                        for (j=i; j< atlaspage;  j++)
-                                               fprintf(stderr, "gnuplot 
%s%s_%s_%02d.gpl\n", cachebuf, basefilename, DBNAME,j);
+                                               fprintf(stderr, "gnuplot 
%s%s_%02d.gpl\n", dirpath, prefix, j);
                                }
                        }
 
-                       snprintf(buf, BUFSIZ, "%s%s_%s_%02d.pdf ", cachebuf, 
basefilename, DBNAME, i);
+                       snprintf(buf, BUFSIZ, "%s%s_%02d.pdf ", dirpath, 
prefix, i);
                        plen += snprintf(pages + plen, BSIZE -plen,"%s",buf);
                        if ( plen >= BSIZE-1){
                                error = -1;
@@ -502,15 +500,15 @@ stop_disconnect:
                }
 
 
-               if( systemcall && error == 0) {
-                       snprintf(buf, BSIZE, "gs -q -dNOPAUSE -sDEVICE=pdfwrite 
-sOUTPUTFILE=%s%s_%s.pdf -dBATCH %s",cachebuf,basefilename,DBNAME,pages);
+               if( error == 0) {
+                       snprintf(buf, BSIZE, "gs -q -dNOPAUSE -sDEVICE=pdfwrite 
-sOUTPUTFILE=%s%s.pdf -dBATCH %s",dirpath,prefix,pages);
                        fprintf(stderr,"-- exec:%s\n",buf);
                        error = system(buf);
                }
                if( error == 0) 
-                       fprintf(stderr,"-- done: %s%s_%s.pdf\n", cachebuf, 
basefilename,DBNAME);
+                       fprintf(stderr,"-- done: %s%s.pdf\n", dirpath, prefix);
                else
-                       fprintf(stderr, "gs -dNOPAUSE -sDEVICE=pdfwrite 
-sOUTPUTFILE=%s%s_%s.pdf -dBATCH %s\n", cachebuf, basefilename,DBNAME,pages);
+                       fprintf(stderr, "gs -dNOPAUSE -sDEVICE=pdfwrite 
-sOUTPUTFILE=%s%s.pdf -dBATCH %s\n", dirpath, prefix,pages);
        }
 
        if(dbh)
@@ -555,7 +553,7 @@ static void resetTomograph(void){
        static char buf[BUFSIZ];
        int i;
 
-       snprintf(buf,BUFSIZ,"%s%s_%s_%02d.trace", cachebuf, 
basefilename,DBNAME,atlaspage);
+       snprintf(buf,BUFSIZ,"%s%s_%02d.trace", dirpath, prefix,atlaspage);
 
        if( inputfile && strcmp(inputfile,buf) == 0 ){
                fprintf(stderr,"Should not overwrite existing trace file 
'%s'\n",buf);
@@ -727,7 +725,7 @@ dumpboxes(void)
        int i;
        int written = 0;
 
-       snprintf(buf, BUFSIZ, "%s%s_%s_%02d.dat", cachebuf, 
basefilename,DBNAME, atlaspage);
+       snprintf(buf, BUFSIZ, "%s%s_%02d.dat", dirpath, prefix,atlaspage);
        f = fopen(buf, "w");
        if(f == NULL){
                fprintf(stderr,"Could not create file '%s'\n",buf);
@@ -802,7 +800,7 @@ showmemory(void)
        mm = (mx - mn) / 50.0; /* 2% top & bottom margin */
        fprintf(gnudata, "set yrange [%f:%f]\n", mn - mm, mx + mm);
        fprintf(gnudata, "set ytics (\"%.*f\" %f, \"%.*f\" %f) nomirror\n", 
digits, min / scale, mn, digits, max / scale, mx);
-       fprintf(gnudata, "plot \"%s%s_%s_%02d.dat\" using 1:2 notitle with dots 
linecolor rgb \"blue\"\n", cachebuf, basefilename,DBNAME,atlaspage);
+       fprintf(gnudata, "plot \"%s%s_%02d.dat\" using 1:2 notitle with dots 
linecolor rgb \"blue\"\n", dirpath, prefix,atlaspage);
        fprintf(gnudata, "unset yrange\n");
 }
 
@@ -831,7 +829,7 @@ showcpu(void)
        fprintf(gnudata, "set rmarg 10\n");
        fprintf(gnudata, "set size 1,0.084\n");
        fprintf(gnudata, "set origin 0.0, 0.8\n");
-       fprintf(gnudata, "set ylabel \"CPU\"\n");
+       fprintf(gnudata, "set ylabel \"%d cores\"\n",cpus);
        fprintf(gnudata, "unset xtics\n");
        fprintf(gnudata, "unset ytics\n");
        fprintf(gnudata, "set ytics 0, %d\n",cpus <=8 ?4:8);
@@ -887,10 +885,10 @@ showio(void)
                                max = box[i].inblock;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to