return exstring(ex, sfstruse(fp));
}
+#ifndef WIN32
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/times.h>
+#include <sys/param.h>
+
+
+
+#ifndef HZ
+#define HZ 60
+#endif
+typedef struct tms mytime_t;
+#define GET_TIME(S) times(&(S))
+#define DIFF_IN_SECS(S,T) ((S.tms_utime + S.tms_stime - T.tms_utime - T.tms_stime)/(double)HZ)
+
+#else
+
+#include <time.h>
+
+typedef clock_t mytime_t;
+#define GET_TIME(S) S = clock()
+#define DIFF_IN_SECS(S,T) ((S - T) / (double)CLOCKS_PER_SEC)
+
+#endif
+
+static mytime_t T;
+
+void gvstart_timer(void)
+{
+ GET_TIME(T);
+}
+
+double gvelapsed_sec(void)
+{
+ mytime_t S;
+ double rv;
+
+ GET_TIME(S);
+ rv = DIFF_IN_SECS(S, T);
+ return rv;
+}
+
extern char *toUpper(Expr_t * pgm, char *, Sfio_t*);
extern int deleteObj(Agraph_t * g, Agobj_t * obj);
extern char *colorx (Expr_t* ex, char* incolor, char* fmt, Sfio_t* fp);
+ extern void gvstart_timer(void);
+ extern double gvelapsed_sec(void);
#endif
int argc;
char **argv;
int state; /* > 0 : continue; <= 0 finish */
+ int verbose;
} options;
static Sfio_t *openOut(char *name)
case 'q':
setTraceLevel (ERROR_ERROR); /* Don't emit warning messages */
break;
+ case 'v':
+ opts->verbose = 1;
+ break;
case 'V':
sfprintf(sfstderr, "%s version %s (%s)\n",
Info[0], Info[1], Info[2]);
opts->state = 1;
opts->readAhead = 1;
setErrorId (opts->cmdName);
+ opts->verbose = 0;
/* estimate number of file names */
nfiles = 0;
goto finish;
}
+ if (opts->verbose)
+ gvstart_timer ();
prog = parseProg(opts->program, opts->useFile);
if (!prog) {
rv = 1;
else
incoreGraphs = 0;
+ if (opts->verbose)
+ sfprintf (sfstderr, "Parse/compile/init: %.2f secs.\n", gvelapsed_sec());
/* do begin */
if (xprog->begin_stmt)
exeval(xprog->prog, xprog->begin_stmt, state);
else
ing = newIng(0, opts->inFiles, &ingDisc);
+ if (opts->verbose) gvstart_timer ();
for (state->curgraph = nextGraph(ing); state->curgraph; state->curgraph = nextg) {
+ if (opts->verbose) sfprintf (sfstderr, "Read graph: %.2f secs.\n", gvelapsed_sec());
state->infname = fileName(ing);
if (opts->readAhead)
nextg = state->nextgraph = nextGraph(ing);
state->curobj = (Agobj_t *) state->curgraph;
if (xprog->endg_stmt)
exeval(xprog->prog, xprog->endg_stmt, state);
+ if (opts->verbose) sfprintf (sfstderr, "Finish graph: %.2f secs.\n", gvelapsed_sec());
/* if $O == $G and $T is empty, delete $T */
if ((state->outgraph == state->curgraph) &&
state->target = 0;
state->outgraph = 0;
+ if (opts->verbose) gvstart_timer ();
if (!opts->readAhead)
nextg = nextGraph(ing);
+ if (opts->verbose && nextg) sfprintf (sfstderr, "Read graph: %.2f secs.\n", gvelapsed_sec());
}
}