a tall order?

Discussion in 'AutoCAD' started by C Witt, Jul 15, 2004.

  1. C Witt

    C Witt Guest

    I'd prefer to do this one myself, but don't even know were to start..

    With help from the NG, I can track the "time" it takes for each of my
    lisp to run.. but I want to take it a step further (a big step)..

    I want to "save" this info:
    What lisp was used?
    How long did it take?
    What drawing was it in (full drawing path)?
    --------------------------

    to a file.. (one that can be "added" to each time a lisp is run)..

    But I'm left with HOW?

    Hope there is someone who can help.
     
    C Witt, Jul 15, 2004
    #1
  2. C Witt

    John Guest

    AUGI had a program that allowed pretty much what you are talking about. I
    think it was called AUGI Gauge. Check there sight for the current version.

    John
    I'd prefer to do this one myself, but don't even know were to start..

    With help from the NG, I can track the "time" it takes for each of my
    lisp to run.. but I want to take it a step further (a big step)..

    I want to "save" this info:
    What lisp was used?
    How long did it take?
    What drawing was it in (full drawing path)?
    --------------------------

    to a file.. (one that can be "added" to each time a lisp is run)..

    But I'm left with HOW?

    Hope there is someone who can help.
     
    John, Jul 15, 2004
    #2
  3. C Witt

    C Witt Guest

    what is there site?

    John
     
    C Witt, Jul 15, 2004
    #3
  4. C Witt

    ECCAD Guest

    This will get you started:
    ;;
    ;; Lisp File, Time Reporting
    ;;
    (defun report ( time lispfile / data Fexist o_fil rep_fil )
    (if (= drive nil)(setq drive "C:"))
    (setq o_fil (strcat drive "/reports/lisptime.txt"))
    (setq Fexist nil)
    (setq Fexist (findfile o_fil))
    (if (= Fexist nil)
    (setq rep_fil (open o_fil "w")); open for write if non-existing
    (setq rep_fil (open o_fil "a")); open for append otherwise
    ); end if
    (setq fx_name (strcase (getvar "DWGPREFIX"))); Drive/Path
    (setq fx_name (strcat fx_name (strcase (getvar "DWGNAME")))); This Drawing Name
    (write-line fx_name rep_fil)
    (setq data (strcat "Time: " (rtos time) " Lisp: " lispfile))
    (write-line data rep_fil)
    (close rep_fil)
    (setq rep_fil nil o_fil nil)
    (princ)
    ); end function report

    Call: (report time lispfilename)

    Bob
     
    ECCAD, Jul 15, 2004
    #4
  5. C Witt

    C Witt Guest

    thank you.

    I'll give'r a try asap.
     
    C Witt, Jul 15, 2004
    #5
  6. C Witt

    C Witt Guest

    the line (close rep_fil)
    keeps spitting out this error:
    error: bad argument type: streamp nil

    ideas?
     
    C Witt, Jul 15, 2004
    #6
  7. C Witt

    ECCAD Guest

    Cause:
    (setq o_fil (strcat drive "/reports/lisptime.txt"))
    Fix:
    Place a 'real' path on your system in the line shown.

    Bob
     
    ECCAD, Jul 15, 2004
    #7
  8. C Witt

    MP Guest

    well, eccad beat me to it
    (naturally)
    but in the spirit of when it rains it pours,
    here's part of what you want
    just for the sake of comparison

    (defun LogLispTime(routinename TimeToRun / AddFile FileHandle *error*
    logFileName today)
    (defun *error*(msg)
    (if filehandle
    (progn
    (close filehandle)
    (setq filehandle nil)
    (gc)
    )
    )
    )
    (setq today(menucmd "M=$(edtime,$(getvar,date),M-DD-YY)"))

    ;change to your location
    (setq logFileName"drive:\\folder\\logfile.txt");or whatever file name you
    want

    (setq FileHandle (open LogfileName "a"))
    (if FileHandle
    (progn
    (defun AddFile (str)
    (write-line str FileHandle)
    );end defun

    (addfile "Lisp time log"); or whatever
    (addfile today)
    (addfile (strcat "Routine: " Routinename))
    ;(addfile (strcat "Used by: "(Getvar "LOGINNAME")))
    (addfile (strcat "Running in: "(Getvar"Dwgprefix") (Getvar "DWGNAME")))
    ;assuming TimeToRun is a real value
    (addfile (strcat "Time Elapsed: "(rtos TimeToRun 2 2) " seconds")) ;or
    whatever granularity desired
    (addfile ";-------------------------------")
    (close FileHandle)
    (gc)
    );progn
    (princ"\nError opening log file")
    );if
    (princ)
    )



    then in the routine you want to log

    (defun RoutineName()
    (starttimer);however you do this now

    ...routine body...

    (setq elapsedTime(Endtimer));or however you're doing it
    (logLispTime "RoutineName" elapsedTime)
    (princ)
    )
    hth
    Mark
     
    MP, Jul 15, 2004
    #8
  9. C Witt

    MP Guest

    Bob,
    just for simplicity...
    you can eliminate the following
    and just use this
    (append will create the file first time if it doesn't exist)

    :)
     
    MP, Jul 15, 2004
    #9
  10. C Witt

    C Witt Guest

    that did it. (i thought it would create the dir if not found)..

    TY agian.
     
    C Witt, Jul 15, 2004
    #10
  11. C Witt

    ECCAD Guest

    You are correct. I nil Fexist, in case I used it in some other place, and forgot to nil it..
    And, open "a" will (fresh) open a file for sure..don't need
    the open "w"..could get rid of that..

    Thanks for pointing that out.
    :)
    Bob
     
    ECCAD, Jul 15, 2004
    #11
  12. C Witt

    Allen Jessup Guest

    www.augi.com

     
    Allen Jessup, Jul 15, 2004
    #12
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.