Changeset 4802 for nanovis/branches/1.1


Ignore:
Timestamp:
Dec 1, 2014, 7:09:11 AM (5 years ago)
Author:
ldelgass
Message:

Stats log fixes, also bump version

Location:
nanovis/branches/1.1
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • nanovis/branches/1.1

  • nanovis/branches/1.1/Command.cpp

    r4612 r4802  
    769769    }
    770770#ifdef KEEPSTATS
    771     int f;
    772 
    773771    /* Use the initial client key value pairs as the parts for a generating
    774772     * a unique file name. */
    775     f = NanoVis::getStatsFile(objv[1]);
     773    int f = NanoVis::getStatsFile(objv[1]);
    776774    if (f < 0) {
    777775        Tcl_AppendResult(interp, "can't open stats file: ",
     
    787785        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
    788786        /* server */
    789         objPtr = Tcl_NewStringObj("server", 6);
     787        objPtr = Tcl_NewStringObj("renderer", 8);
    790788        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
    791789        objPtr = Tcl_NewStringObj("nanovis", 7);
     
    794792        objPtr = Tcl_NewStringObj("pid", 3);
    795793        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
    796         Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj(getpid()));
     794        Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewLongObj((long)NanoVis::stats.pid));
    797795        /* machine */
    798         objPtr = Tcl_NewStringObj("machine", 7);
     796        objPtr = Tcl_NewStringObj("host", 4);
    799797        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
    800798        gethostname(buf, BUFSIZ-1);
     
    809807    /* date */
    810808    Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj("date", 4));
    811     strcpy(buf, ctime(&NanoVis::startTime.tv_sec));
     809    strcpy(buf, ctime(&NanoVis::stats.start.tv_sec));
    812810    buf[strlen(buf) - 1] = '\0';
    813811    Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj(buf, -1));
    814812    /* date_secs */
    815813    Tcl_ListObjAppendElement(interp, listObjPtr,
    816                 Tcl_NewStringObj("date_secs", 9));
     814                             Tcl_NewStringObj("date_secs", 9));
    817815    Tcl_ListObjAppendElement(interp, listObjPtr,
    818                 Tcl_NewLongObj(NanoVis::startTime.tv_sec));
     816                             Tcl_NewLongObj(NanoVis::stats.start.tv_sec));
    819817    /* Client arguments. */
    820818    if (Tcl_ListObjGetElements(interp, objv[1], &numItems, &items) != TCL_OK) {
  • nanovis/branches/1.1/nanovis.cpp

    r4612 r4802  
    9191#define FALSE   0
    9292
    93 typedef struct {
    94     pid_t pid;
    95     size_t nFrames;            /**< # of frames sent to client. */
    96     size_t nBytes;             /**< # of bytes for all frames. */
    97     size_t nCommands;          /**< # of commands executed */
    98     double cmdTime;            /**< Elasped time spend executing
    99                                 * commands. */
    100     struct timeval start;      /**< Start of elapsed time. */
    101 } Stats;
    102 
    103 static Stats stats;
    104 
    10593// STATIC MEMBER DATA
    10694
     
    10997FILE *NanoVis::recfile = NULL;
    11098
     99NanoVis::Stats NanoVis::stats;
    111100int NanoVis::statsFile = -1;
    112101
     
    114103bool NanoVis::debugFlag = false;
    115104bool NanoVis::axisOn = true;
    116 struct timeval NanoVis::startTime;
    117105
    118106int NanoVis::winWidth = NPIX;
     
    253241{
    254242    Tcl_DString ds;
    255     Tcl_Obj **objv;
    256     int objc;
    257     int i;
    258243    char fileName[33];
     244    char pidstr[200];
    259245    const char *path;
    260246    md5_state_t state;
     
    266252        return statsFile;
    267253    }
    268     if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) {
    269         return -1;
    270     }
    271     Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewStringObj("pid", 3));
    272     Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewIntObj(getpid()));
     254    /* By itself the client's key/value pairs aren't unique.  Add in the
     255     * process id of this render server. */
     256    sprintf(pidstr, "%ld", (long)stats.pid);
     257
     258    /* Create an md5 hash of the key/value pairs and use it as the file name. */
    273259    string = Tcl_GetStringFromObj(objPtr, &length);
    274 
    275260    md5_init(&state);
    276     md5_append(&state, (const md5_byte_t *)string, length);
     261    md5_append(&state, (const md5_byte_t *)string, strlen(string));
     262    md5_append(&state, (const md5_byte_t *)pidstr, strlen(pidstr));
    277263    md5_finish(&state, digest);
    278     for (i = 0; i < 16; i++) {
     264    for (int i = 0; i < 16; i++) {
    279265        sprintf(fileName + i * 2, "%02x", digest[i]);
    280266    }
     
    315301    Tcl_DString ds;
    316302    int result;
    317     int f;
    318303
    319304    {
     
    323308        gettimeofday(&tv, NULL);
    324309        finish = CVT2SECS(tv);
    325         tv = stats.start;
     310        tv = NanoVis::stats.start;
    326311        start = CVT2SECS(tv);
    327312    }
     
    353338    /* pid */
    354339    Tcl_DStringAppendElement(&ds, "pid");
    355     sprintf(buf, "%d", getpid());
     340    sprintf(buf, "%d", NanoVis::stats.pid);
    356341    Tcl_DStringAppendElement(&ds, buf);
    357342    /* host */
     
    362347    /* date */
    363348    Tcl_DStringAppendElement(&ds, "date");
    364     strcpy(buf, ctime(&stats.start.tv_sec));
     349    strcpy(buf, ctime(&NanoVis::stats.start.tv_sec));
    365350    buf[strlen(buf) - 1] = '\0';
    366351    Tcl_DStringAppendElement(&ds, buf);
    367352    /* date_secs */
    368353    Tcl_DStringAppendElement(&ds, "date_secs");
    369     sprintf(buf, "%ld", stats.start.tv_sec);
     354    sprintf(buf, "%ld", NanoVis::stats.start.tv_sec);
    370355    Tcl_DStringAppendElement(&ds, buf);
    371356    /* num_frames */
    372357    Tcl_DStringAppendElement(&ds, "num_frames");
    373     sprintf(buf, "%lu", (unsigned long int)stats.nFrames);
     358    sprintf(buf, "%lu", (unsigned long int)NanoVis::stats.nFrames);
    374359    Tcl_DStringAppendElement(&ds, buf);
    375360    /* frame_bytes */
    376361    Tcl_DStringAppendElement(&ds, "frame_bytes");
    377     sprintf(buf, "%lu", (unsigned long int)stats.nBytes);
     362    sprintf(buf, "%lu", (unsigned long int)NanoVis::stats.nBytes);
    378363    Tcl_DStringAppendElement(&ds, buf);
    379364    /* num_commands */
    380365    Tcl_DStringAppendElement(&ds, "num_commands");
    381     sprintf(buf, "%lu", (unsigned long int)stats.nCommands);
     366    sprintf(buf, "%lu", (unsigned long int)NanoVis::stats.nCommands);
    382367    Tcl_DStringAppendElement(&ds, buf);
    383368    /* cmd_time */
    384369    Tcl_DStringAppendElement(&ds, "cmd_time");
    385     sprintf(buf, "%g", stats.cmdTime);
     370    sprintf(buf, "%g", NanoVis::stats.cmdTime);
    386371    Tcl_DStringAppendElement(&ds, buf);
    387372    /* session_time */
     
    418403    }
    419404    Tcl_DStringAppend(&ds, "\n", -1);
    420     f = NanoVis::getStatsFile(NULL);
     405    int f = NanoVis::getStatsFile(NULL);
    421406    result = NanoVis::writeToStatsFile(f, Tcl_DStringValue(&ds),
    422407                                       Tcl_DStringLength(&ds));
     
    495480    std::string cmd(str);
    496481    cmd.erase(cmd.find_last_not_of(" \n\r\t")+1);
    497     TRACE("command %lu: '%s'", stats.nCommands+1, cmd.c_str());
     482    TRACE("command %lu: '%s'", NanoVis::stats.nCommands+1, cmd.c_str());
    498483#endif
    499484
     
    511496    finish = CVT2SECS(tv);
    512497
    513     stats.cmdTime += finish - start;
    514     stats.nCommands++;
     498    NanoVis::stats.cmdTime += finish - start;
     499    NanoVis::stats.nCommands++;
    515500    TRACE("Leave status=%d", result);
    516501    return result;
     
    19811966
    19821967    openlog("nanovis", LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER);
    1983     gettimeofday(&NanoVis::startTime, NULL);
    1984     stats.start = NanoVis::startTime;
     1968    memset(&NanoVis::stats, 0, sizeof(NanoVis::Stats));
     1969    NanoVis::stats.pid = getpid();
     1970    gettimeofday(&NanoVis::stats.start, NULL);
    19851971
    19861972    /* Initialize GLUT here so it can parse and remove GLUT-specific
  • nanovis/branches/1.1/nanovis.h

    r4617 r4802  
    2020#include <md5.h>
    2121#include <GL/glew.h>
     22#include <sys/types.h> // For pid_t
     23#include <sys/time.h>  // For struct timeval
    2224
    2325#include <math.h>
     
    3335#include "config.h"
    3436
    35 #define NANOVIS_VERSION         "1.1.1"
     37#define NANOVIS_VERSION         "1.1.2"
    3638
    3739//defines for the image based flow visualization
     
    8082    };
    8183
     84    typedef struct {
     85        pid_t pid;
     86        size_t nFrames;            /**< # of frames sent to client. */
     87        size_t nBytes;             /**< # of bytes for all frames. */
     88        size_t nCommands;          /**< # of commands executed */
     89        double cmdTime;            /**< Elasped time spend executing
     90                                    * commands. */
     91        struct timeval start;      /**< Start of elapsed time. */
     92    } Stats;
     93
    8294    typedef std::string TransferFunctionId;
    8395    typedef std::string VolumeId;
     
    161173
    162174    static FILE *stdin, *logfile, *recfile;
     175    static Stats stats;
    163176    static int statsFile;
    164177    static unsigned int flags;
    165178    static bool debugFlag;
    166179    static bool axisOn;
    167     static struct timeval startTime;       ///< Start of elapsed time.
    168180
    169181    static int winWidth;        ///< Width of the render window
Note: See TracChangeset for help on using the changeset viewer.