/* Print parameter values as output header. */ static void printhdr(Context *x) { pmUnits units; char tbfr[26]; const char *u; printf("metric: %s\n", x->metric); if (opts.context != PM_CONTEXT_ARCHIVE) printf("host: %s\n", x->hostname); else { printf("archive: %s\n", source); printf("host: %s\n", x->hostname); printf("start: %s", pmCtime(&opts.origin.tv_sec, tbfr)); if (opts.finish.tv_sec != INT_MAX) printf("end: %s", pmCtime(&opts.finish.tv_sec, tbfr)); } printf("semantics: "); switch (x->desc.sem) { case PM_SEM_COUNTER: printf("cumulative counter"); if (! rawCounter) printf(" (converting to rate)"); break; case PM_SEM_INSTANT: printf("instantaneous value"); break; case PM_SEM_DISCRETE: printf("discrete instantaneous value"); break; default: printf("unknown"); } putchar('\n'); units = x->desc.units; u = pmUnitsStr(&units); printf("units: %s", *u == '\0' ? "none" : u); if ((! rawCounter) && (x->desc.sem == PM_SEM_COUNTER)) { printf(" (converting to "); if (units.dimTime == 0) units.scaleTime = PM_TIME_SEC; units.dimTime--; if ((units.dimSpace == 0) && (units.dimTime == 0) && (units.dimCount == 0)) printf("time utilization)"); else { u = pmUnitsStr(&units); printf("%s)", *u == '\0' ? "none" : u); } } putchar('\n'); /* sample count and interval */ if (opts.samples < 0) printf("samples: all\n"); else printf("samples: %d\n", opts.samples); if ((opts.samples > 1) && (opts.context != PM_CONTEXT_ARCHIVE || amode == PM_MODE_INTERP)) printf("interval: %1.2f sec\n", __pmtimevalToReal(&opts.interval)); }
void SamplingEngine::setStyle(Chart::Style style) { // Y-Axis title choice is difficult. A Utilisation plot by definition // is dimensionless and scaled to a percentage, so a label of just // "% utilization" makes sense ... there has been some argument in // support of "% time utilization" as a special case when the metrics // involve some aspect of time, but the base metrics in the common case // are counters in units of time (e.g. the CPU view), which after rate // conversion is indistinguishable from instantaneous or discrete // metrics of dimension time^0 which are units compatible ... so we're // opting for the simplest possible interpretation of utilization or // everything else. // switch (style) { case Chart::BarStyle: case Chart::AreaStyle: case Chart::LineStyle: case Chart::StackStyle: if (my.chart->style() == Chart::UtilisationStyle) my.scaleEngine->setAutoScale(true); my.chart->setYAxisTitle(pmUnitsStr(&my.units)); break; case Chart::UtilisationStyle: my.scaleEngine->setScale(false, 0.0, 100.0); my.chart->setYAxisTitle("% utilization"); break; default: break; } }
void SamplingItem::rescaleValues(pmUnits *new_units) { pmUnits *old_units = &ChartItem::my.units; pmAtomValue old_av, new_av; console->post("Chart::update change units from %s to %s", pmUnitsStr(old_units), pmUnitsStr(new_units)); for (int i = my.dataCount - 1; i >= 0; i--) { if (my.data[i] != qQNaN()) { old_av.d = my.data[i]; pmConvScale(PM_TYPE_DOUBLE, &old_av, old_units, &new_av, new_units); my.data[i] = new_av.d; } if (my.itemData[i] != qQNaN()) { old_av.d = my.itemData[i]; pmConvScale(PM_TYPE_DOUBLE, &old_av, old_units, &new_av, new_units); my.itemData[i] = new_av.d; } } }
bool SamplingEngine::isCompatible(pmDesc &desc) { console->post("SamplingEngine::isCompatible" " type=%d, units=%s", desc.type, pmUnitsStr(&desc.units)); if (desc.type == PM_TYPE_EVENT || desc.type == PM_TYPE_HIGHRES_EVENT) return false; normaliseUnits(desc); if (my.units.dimSpace != desc.units.dimSpace || my.units.dimTime != desc.units.dimTime || my.units.dimCount != desc.units.dimCount) return false; return true; }
/* scanner main function */ int yylex(void) { int c, d; /* current character */ int esc = 0; /* for escape processing */ static int ahead = 0; /* lookahead token */ int behind = 0; /* lookbehind token */ LexEntry1 *lt1; /* scans through lexbuf1 */ LexEntry2 *lt2; /* scans through lexbuf2 */ char *p, *q; int i; char nbuf[LEX_MAX+1]; /* for getting macro name */ /* token from previous invocation */ if (ahead) { c = ahead; ahead = 0; #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> TOKEN (ahead) \'%c\'\n", c); #endif return c; } /* scan token from input */ c = nextc(); while (c != EOF) { /* skip blanks */ while (isspace(c)) c = nextc(); /* scan C style comment */ if (c == '/') { if ((d = nextc()) != '*') prevc(d); else { c = nextc(); while (c != EOF) { d = nextc(); if ((c == '*') && (d == '/')) { c = nextc(); break; } c = d; } continue; } } /* scan C++ style comment */ if (c == '/') { if ((d = nextc()) != '/') prevc(d); else { do c = nextc(); while (( c != '\n') && (c != EOF)); continue; } } /* scan alphanumeric */ if (isalpha(c) || (c == '\'') || (c == '%')) { d = c; if (d == '\'') c = nextc(); i = 0; do { if (c == '$') { /* macro embedded in identifier */ int sts; if (!get_ident(nbuf)) return EOF; sts = varDeref(nbuf); if (sts == DEREF_ERROR) { /* error reporting in varDeref() */ lexSync(); return EOF; } else if (sts != DEREF_STRING) { synerr(); fprintf(stderr, "macro $%s not string valued as expected\n", nbuf); lexSync(); return EOF; } c = nextc(); } else { if (c == '\\') c = nextc(); token[i++] = c; c = nextc(); } } while ((isalpha(c) || isdigit(c) || c == '.' || c == '_' || c == '\\' || c == '$' || (d == '\'' && c != d)) && (i < LEX_MAX)); token[i] = '\0'; if (d == '\'') c = nextc(); /* * recognize keywords associated with units of space, time * and count, see unitab[] */ if (d != '\'') { lt2 = &unitab[0]; if (i > 0 && token[i-1] == 's') i--; do { if (strlen(lt2->key) == i && strncmp(token, lt2->key, i) == 0) { /* if looking ahead after '/', return UNIT_SLASH */ if (behind == '/') { prevs(&token[0]); prevc(c); #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \"/\"\n"); #endif return UNIT_SLASH; } prevc(c); yylval.u = noUnits; switch (lt2->token) { case SPACE_UNIT: yylval.u.dimSpace = 1; yylval.u.scaleSpace = lt2->scale; break; case TIME_UNIT: yylval.u.dimTime = 1; yylval.u.scaleTime = lt2->scale; break; case EVENT_UNIT: yylval.u.dimCount = 1; yylval.u.scaleCount = lt2->scale; break; } #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> UNITS \"%s\"\n", pmUnitsStr(&yylval.u)); #endif return lt2->token; } lt2++; } while (lt2->key); } /* if looking ahead, return previous token */ if (behind) { prevs(&token[0]); prevc(c); #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> TOKEN (behind) \'%c\'\n", behind); #endif return behind; } prevc(c); /* recognize aggregation and quantification */ if (d != '\'') { if ((p = strchr(token, '_')) != NULL) { *p = '\0'; lt1 = &quantab[0]; do { if (strcmp(&token[0], lt1->key) == 0) { c = lt1->token; q = p + 1; lt1 = &domtab[0]; do { if (strcmp(q, lt1->key) == 0) { ahead = lt1->token; #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \"%s\'\n", token); #endif return c; } lt1++; } while (lt1->key); break; } lt1++; } while (lt1->key); *p = '_'; } /* recognize other reserved word */ lt1 = &optab[0]; do { if (strcmp(&token[0], lt1->key) == 0) { #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> RESERVED-WORD \"%s\"\n", token); #endif return lt1->token; } lt1++; } while (lt1->key); } /* recognize identifier */ yylval.s = (char *) alloc(strlen(&token[0]) + 1); strcpy(yylval.s, &token[0]); #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> IDENT \"%s\"\n", token); #endif return IDENT; } /* if looking ahead, return preceding token */ if (behind) { prevc(c); #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> TOKEN (behind) \'%c\'\n", behind); #endif return behind; } /* special case for .[0-9]... number without leading [0-9] */ if (c == '.') { c = nextc(); if (isdigit(c)) { /* note prevc() implements a FIFO, not a stack! */ prevc('.'); /* push back period */ prevc(c); /* push back digit */ c = '0'; /* start with fake leading zero */ } else prevc(c); /* not a digit after period, push back */ } /* scan NUMBER */ if (isdigit(c)) { int flote = 0; i = 0; do { token[i++] = c; c = nextc(); if ((flote == 0) && (c == '.') && (i < LEX_MAX)) { c = nextc(); if (c == '.') prevc(c); /* INTERVAL token */ else { flote = 1; token[i++] = '.'; } } if ((flote <= 1) && (i < LEX_MAX) && ((c == 'e') || (c == 'E'))) { flote = 2; token[i++] = c; c = nextc(); } if ((flote <= 2) && (c == '-') && (i < LEX_MAX)) { flote = 3; token[i++] = c; c = nextc(); } } while (isdigit(c) && (i < LEX_MAX)); prevc(c); token[i] = '\0'; yylval.d = strtod(&token[0], NULL); #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> NUMBER %g\n", yylval.d); #endif return NUMBER; } /* scan string */ if (c == '"') { yylval.s = NULL; i = 0; c = nextc(); while ((c != '"') && (c != EOF) && (i < LEX_MAX)) { /* escape character */ if (c == '\\') { esc = 1; c = nextc(); switch (c) { case 'n': c = '\n'; break; case 't': c = '\t'; break; case 'v': c = '\v'; break; case 'b': c = '\b'; break; case 'r': c = '\r'; break; case 'f': c = '\f'; break; case 'a': c = '\a'; break; } } else esc = 0; /* macro embedded in string */ if (c == '$' && !esc) { int sts; if (!get_ident(nbuf)) return EOF; sts = varDeref(nbuf); if (sts == DEREF_ERROR) { /* error reporting in varDeref() */ lexSync(); return EOF; } else if (sts != DEREF_STRING) { synerr(); fprintf(stderr, "macro $%s not string valued as expected\n", nbuf); lexSync(); return EOF; } c = nextc(); } /* add character to string */ yylval.s = (char *) ralloc(yylval.s, i+2); yylval.s[i++] = c; c = nextc(); } if (i == 0) { /* special case for null string */ yylval.s = (char *) ralloc(yylval.s, 1); } yylval.s[i++] = '\0'; #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> STRING \"%s\"\n", yylval.s); #endif return STRING; } /* scan operator */ switch (c) { case ';': case '}': do d = nextc(); while (isspace(d)); if (d == '.') { while (lin) unwind(); } else prevc(d); #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> END-OF-RULE\n"); #endif return EOF; case '$': if (!get_ident(nbuf)) return EOF; switch (varDeref(nbuf)) { case DEREF_ERROR: lexSync(); return EOF; case DEREF_STRING: c = nextc(); continue; case DEREF_BOOL: #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> (boolean) macro $%s\n", nbuf); #endif return VAR; case DEREF_NUMBER: #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> (numeric) macro $%s\n", nbuf); #endif return VAR; } /*NOTREACHED*/ break; case '/': behind = c; c = nextc(); continue; case '-': if ((d = nextc()) == '>') { #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \"->\"\n"); #endif return ARROW; } prevc(d); break; case '=': if ((d = nextc()) == '=') { #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \"==\"\n"); #endif return EQ_REL; } prevc(d); break; case '!': if ((d = nextc()) == '=') { #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \"!=\"\n"); #endif return NEQ_REL; } prevc(d); #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \"!\"\n"); #endif return NOT; case '<': if ((d = nextc()) == '=') { #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \"<=\"\n"); #endif return LEQ_REL; } prevc(d); break; case '>': if ((d = nextc()) == '=') { #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \">=\"\n"); #endif return GEQ_REL; } prevc(d); break; case '&': if ((d = nextc()) == '&') { #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \"&&\"\n"); #endif return AND; } prevc(d); #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \"&\"\n"); #endif return SEQ; case '|': if ((d = nextc()) == '|') { #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \"||\"\n"); #endif return OR; } prevc(d); #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \"|\"\n"); #endif return ALT; case '.': if ((d = nextc()) == '.') { #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> OPERATOR \"..\"\n"); #endif return INTERVAL; } prevc(d); break; } #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) { if (c == EOF) fprintf(stderr, "yylex() -> EOF\n"); else fprintf(stderr, "yylex() -> TOKEN \'%c\' (0x%x)\n", c, c & 0xff); } #endif return c; } #if PCP_DEBUG if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "yylex() -> EOF\n"); #endif return EOF; }
int main(int argc, char **argv) { int c; int sts; int errflag = 0; static char *usage = "[-D debug] type value iunit ounit\n" "\n" "iunit and ounit are in the 6-integer format:\n" "dimspace:dimtime:dimcount:scalespace:scaletime:scalecount\n"; pmUnits iu; pmUnits ou; int type; int vbase; pmAtomValue iv; pmAtomValue ov; char *vp; char *q; __pmSetProgname(argv[0]); /* stop at type arg, so value may have leading "-" */ putenv("POSIXLY_CORRECT=yes"); while ((c = getopt(argc, argv, "D:")) != EOF) { switch (c) { case 'D': /* debug flag */ sts = __pmParseDebug(optarg); if (sts < 0) { fprintf(stderr, "%s: unrecognized debug flag specification (%s)\n", pmProgname, optarg); errflag++; } else pmDebug |= sts; break; case '?': default: errflag++; break; } } if (errflag || argc - optind != 4) { fprintf(stderr, "Usage: %s %s\n", pmProgname, usage); exit(1); } /* non-flag args are argv[optind] ... argv[argc-1] */ type = atoi(argv[optind]); optind++; if (strncmp(argv[optind], "0x", 2) == 0) { vp = &argv[optind][2]; vbase = 16; } else { vp = argv[optind]; vbase = 10; } q = vp; switch (type) { case PM_TYPE_32: iv.l = strtol(vp, &q, vbase); break; case PM_TYPE_U32: iv.ul = strtoul(vp, &q, vbase); break; case PM_TYPE_64: iv.ll = strtoll(vp, &q, vbase); break; case PM_TYPE_U64: iv.ull = strtoull(vp, &q, vbase); break; case PM_TYPE_FLOAT: sts = sscanf(vp, "%f", &iv.f); if (sts == 1) q = ""; break; case PM_TYPE_DOUBLE: sts = sscanf(vp, "%lf", &iv.d); if (sts == 1) q = ""; break; default: case PM_TYPE_STRING: iv.cp = vp; q = ""; break; case PM_TYPE_AGGREGATE: case PM_TYPE_AGGREGATE_STATIC: iv.vbp = (pmValueBlock *)malloc(PM_VAL_HDR_SIZE+strlen(vp)); iv.vbp->vlen = PM_VAL_HDR_SIZE+strlen(vp); iv.vbp->vtype = type; strncpy(iv.vbp->vbuf, vp, strlen(vp)); q = ""; break; case PM_TYPE_EVENT: // ignore the value, force 0 event records iv.vbp = (pmValueBlock *)malloc(sizeof(pmEventArray)-sizeof(pmEventRecord)); iv.vbp->vlen = sizeof(pmEventArray)-sizeof(pmEventRecord); iv.vbp->vtype = type; memset((void *)iv.vbp->vbuf, 0, sizeof(int)); q = ""; break; case PM_TYPE_HIGHRES_EVENT: // ignore the value, force 0 event records iv.vbp = (pmValueBlock *)malloc(sizeof(pmHighResEventArray)-sizeof(pmHighResEventRecord)); iv.vbp->vlen = sizeof(pmHighResEventArray)-sizeof(pmHighResEventRecord); iv.vbp->vtype = type; memset((void *)iv.vbp->vbuf, 0, sizeof(int)); q = ""; break; } optind++; if (*q != '\0') { fprintf(stderr, "Value botched @ %s\n", q); exit(1); } vp = argv[optind]; iu.dimSpace = strtol(vp, &q, 10); if (*q != ':') goto bad_in; vp = ++q; iu.dimTime = strtol(vp, &q, 10); if (*q != ':') goto bad_in; vp = ++q; iu.dimCount = strtol(vp, &q, 10); if (*q != ':') goto bad_in; vp = ++q; iu.scaleSpace = strtol(vp, &q, 10); if (*q != ':') goto bad_in; vp = ++q; iu.scaleTime = strtol(vp, &q, 10); if (*q != ':') goto bad_in; vp = ++q; iu.scaleCount = strtol(vp, &q, 10); if (*q != '\0') goto bad_in; optind++; vp = argv[optind]; ou.dimSpace = strtol(vp, &q, 10); if (*q != ':') goto bad_out; vp = ++q; ou.dimTime = strtol(vp, &q, 10); if (*q != ':') goto bad_out; vp = ++q; ou.dimCount = strtol(vp, &q, 10); if (*q != ':') goto bad_out; vp = ++q; ou.scaleSpace = strtol(vp, &q, 10); if (*q != ':') goto bad_out; vp = ++q; ou.scaleTime = strtol(vp, &q, 10); if (*q != ':') goto bad_out; vp = ++q; ou.scaleCount = strtol(vp, &q, 10); if (*q != '\0') goto bad_out; printf("type=%d input units=%s value=%s\n", type, pmUnitsStr(&iu), pmAtomStr(&iv, type)); if ((sts = pmConvScale(type, &iv, &iu, &ov, &ou)) < 0) printf("pmConvScale Error: %s\n", pmErrStr(sts)); else printf("output units=%s value=%s\n", pmUnitsStr(&ou), pmAtomStr(&ov, type)); exit(0); bad_in: fprintf(stderr, "Input units botch @ %s\n", q); exit(1); bad_out: fprintf(stderr, "Output units botch @ %s\n", q); exit(1); }
void SamplingEngine::redoScale(void) { bool rescale = false; // The 1,000 and 0.1 thresholds are just a heuristic guess. // // We're assuming lBound() plays no part in this, which is OK as // the upper bound of the y-axis range (hBound()) drives the choice // of appropriate units scaling. // if (my.scaleEngine->autoScale() && my.chart->axisScaleDiv(QwtPlot::yLeft)->upperBound() > 1000) { double scaled_max = my.chart->axisScaleDiv(QwtPlot::yLeft)->upperBound(); if (my.units.dimSpace == 1) { switch (my.units.scaleSpace) { case PM_SPACE_BYTE: my.units.scaleSpace = PM_SPACE_KBYTE; rescale = true; break; case PM_SPACE_KBYTE: my.units.scaleSpace = PM_SPACE_MBYTE; rescale = true; break; case PM_SPACE_MBYTE: my.units.scaleSpace = PM_SPACE_GBYTE; rescale = true; break; case PM_SPACE_GBYTE: my.units.scaleSpace = PM_SPACE_TBYTE; rescale = true; break; case PM_SPACE_TBYTE: my.units.scaleSpace = PM_SPACE_PBYTE; rescale = true; break; case PM_SPACE_PBYTE: my.units.scaleSpace = PM_SPACE_EBYTE; rescale = true; break; } if (rescale) { // logic here depends on PM_SPACE_* values being consecutive // integer values as the scale increases scaled_max /= 1024; while (scaled_max > 1000) { my.units.scaleSpace++; scaled_max /= 1024; if (my.units.scaleSpace == PM_SPACE_EBYTE) break; } } } else if (my.units.dimTime == 1) { switch (my.units.scaleTime) { case PM_TIME_NSEC: my.units.scaleTime = PM_TIME_USEC; rescale = true; scaled_max /= 1000; break; case PM_TIME_USEC: my.units.scaleTime = PM_TIME_MSEC; rescale = true; scaled_max /= 1000; break; case PM_TIME_MSEC: my.units.scaleTime = PM_TIME_SEC; rescale = true; scaled_max /= 1000; break; case PM_TIME_SEC: my.units.scaleTime = PM_TIME_MIN; rescale = true; scaled_max /= 60; break; case PM_TIME_MIN: my.units.scaleTime = PM_TIME_HOUR; rescale = true; scaled_max /= 60; break; } if (rescale) { // logic here depends on PM_TIME* values being consecutive // integer values as the scale increases while (scaled_max > 1000) { my.units.scaleTime++; if (my.units.scaleTime <= PM_TIME_SEC) scaled_max /= 1000; else scaled_max /= 60; if (my.units.scaleTime == PM_TIME_HOUR) break; } } } } if (rescale == false && my.scaleEngine->autoScale() && my.chart->axisScaleDiv(QwtPlot::yLeft)->upperBound() < 0.1) { double scaled_max = my.chart->axisScaleDiv(QwtPlot::yLeft)->upperBound(); if (my.units.dimSpace == 1) { switch (my.units.scaleSpace) { case PM_SPACE_KBYTE: my.units.scaleSpace = PM_SPACE_BYTE; rescale = true; break; case PM_SPACE_MBYTE: my.units.scaleSpace = PM_SPACE_KBYTE; rescale = true; break; case PM_SPACE_GBYTE: my.units.scaleSpace = PM_SPACE_MBYTE; rescale = true; break; case PM_SPACE_TBYTE: my.units.scaleSpace = PM_SPACE_GBYTE; rescale = true; break; case PM_SPACE_PBYTE: my.units.scaleSpace = PM_SPACE_TBYTE; rescale = true; break; case PM_SPACE_EBYTE: my.units.scaleSpace = PM_SPACE_PBYTE; rescale = true; break; } if (rescale) { // logic here depends on PM_SPACE_* values being consecutive // integer values (in reverse) as the scale decreases scaled_max *= 1024; while (scaled_max < 0.1) { my.units.scaleSpace--; scaled_max *= 1024; if (my.units.scaleSpace == PM_SPACE_BYTE) break; } } } else if (my.units.dimTime == 1) { switch (my.units.scaleTime) { case PM_TIME_USEC: my.units.scaleTime = PM_TIME_NSEC; rescale = true; scaled_max *= 1000; break; case PM_TIME_MSEC: my.units.scaleTime = PM_TIME_USEC; rescale = true; scaled_max *= 1000; break; case PM_TIME_SEC: my.units.scaleTime = PM_TIME_MSEC; rescale = true; scaled_max *= 1000; break; case PM_TIME_MIN: my.units.scaleTime = PM_TIME_SEC; rescale = true; scaled_max *= 60; break; case PM_TIME_HOUR: my.units.scaleTime = PM_TIME_MIN; rescale = true; scaled_max *= 60; break; } if (rescale) { // logic here depends on PM_TIME* values being consecutive // integer values (in reverse) as the scale decreases while (scaled_max < 0.1) { my.units.scaleTime--; if (my.units.scaleTime < PM_TIME_SEC) scaled_max *= 1000; else scaled_max *= 60; if (my.units.scaleTime == PM_TIME_NSEC) break; } } } } if (rescale) { // // need to rescale ... we transform all of the historical (raw) // data, new data will be taken care of by changing my.units. // for (int i = 0; i < my.chart->metricCount(); i++) samplingItem(i)->rescaleValues(&my.units); if (my.chart->my.style == Chart::UtilisationStyle) my.chart->setYAxisTitle("% utilization"); else my.chart->setYAxisTitle(pmUnitsStr(&my.units)); my.chart->replot(); } }
void __dumpExpr(int level, Expr *x) { int i; int j; int k; for (i = 0; i < level; i++) fprintf(stderr, ".. "); fprintf(stderr, "Expr dump @ " PRINTF_P_PFX "%p\n", x); if (x == NULL) return; for (i = 0; i < level; i++) fprintf(stderr, ".. "); fprintf(stderr, " op=%d (%s) arg1=" PRINTF_P_PFX "%p arg2=" PRINTF_P_PFX "%p parent=" PRINTF_P_PFX "%p\n", x->op, opStrings(x->op), x->arg1, x->arg2, x->parent); for (i = 0; i < level; i++) fprintf(stderr, ".. "); fprintf(stderr, " eval="); for (j = 0; fn_map[j].addr; j++) { if (x->eval == fn_map[j].addr) { fprintf(stderr, "%s", fn_map[j].name); break; } } if (fn_map[j].addr == NULL) fprintf(stderr, "" PRINTF_P_PFX "%p()", x->eval); fprintf(stderr, " metrics=" PRINTF_P_PFX "%p ring=" PRINTF_P_PFX "%p\n", x->metrics, x->ring); for (i = 0; i < level; i++) fprintf(stderr, ".. "); fprintf(stderr, " valid=%d cardinality[H,I,T]=[%d,%d,%d] tspan=%d\n", x->valid, x->hdom, x->e_idom, x->tdom, x->tspan); for (i = 0; i < level; i++) fprintf(stderr, ".. "); fprintf(stderr, " nsmpls=%d nvals=%d sem=", x->nsmpls, x->nvals); for (j = 0; sem_map[j].name; j++) { if (x->sem == sem_map[j].val) { fprintf(stderr, "%s", sem_map[j].name); break; } } if (sem_map[j].name == NULL) fprintf(stderr, "%d", x->sem); if (UNITS_UNKNOWN(x->units)) fprintf(stderr, " units=UNKNOWN\n"); else fprintf(stderr, " units=%s\n", pmUnitsStr(&x->units)); if (x->valid > 0) { if (x->sem == SEM_BOOLEAN || x->sem == SEM_CHAR || x->sem == SEM_NUMVAR || x->sem == SEM_NUMCONST || x->sem == PM_SEM_COUNTER || x->sem == PM_SEM_INSTANT || x->sem == PM_SEM_DISCRETE) { for (j = 0; j < x->nsmpls; j++) { for (i = 0; i < level; i++) fprintf(stderr, ".. "); fprintf(stderr, " smpls[%d].ptr " PRINTF_P_PFX "%p ", j, x->smpls[j].ptr); for (k = 0; k < x->tspan; k++) { if (x->tspan > 1 && x->sem != SEM_CHAR) { if (k > 0) fprintf(stderr, ", "); fprintf(stderr, "{%d} ", k); } if (x->sem == SEM_BOOLEAN) { char c = *((char *)x->smpls[j].ptr+k); if ((int)c == B_TRUE) fprintf(stderr, "true"); else if ((int)c == B_FALSE) fprintf(stderr, "false"); else if ((int)c == B_UNKNOWN) fprintf(stderr, "unknown"); else fprintf(stderr, "bogus (0x%x)", c & 0xff); } else if (x->sem == SEM_CHAR) { if (k == 0) fprintf(stderr, "\"%s\"", (char *)x->smpls[j].ptr); } else { double v = *((double *)x->smpls[j].ptr+k); int fp_bad = 0; #ifdef HAVE_FPCLASSIFY fp_bad = fpclassify(v) == FP_NAN; #else #ifdef HAVE_ISNAN fp_bad = isnan(v); #endif #endif if (fp_bad) fputc('?', stderr); else fprintf(stderr, "%g", v); } } fputc('\n', stderr); } } else if (x->sem == SEM_REGEX) { for (i = 0; i < level; i++) fprintf(stderr, ".. "); fprintf(stderr, " handle=" PRINTF_P_PFX "%p\n", x->ring); } } }