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.
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.
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
Cause: (setq o_fil (strcat drive "/reports/lisptime.txt")) Fix: Place a 'real' path on your system in the line shown. Bob
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
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)
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