MAJOR FIX of ELTIM scheme for FG 3.9: Keep time for each script separate from times for gaps. Record script completion times in eltimList[N], where N is eltimSptNumber when spt began exec. When a script begins execution, the preceding gap (same N) time is recorded in eltimList[N] first. Once a script is sent to JSmol, FG javascript (gap) can keep on chugging. In fact, the total gap time is typically 1 or a few seconds shorter than the stopwatched load time (till BUSY disappears). The sum of gap and script execution time is way more than the actual stopwatched time: 2gtl (+1=12"), 1wce (+1=12"), 1wce &bbmax (+1"=35"), 4ioa nosimp (+4"=45"). (Above times taken before avoiding some scripts irrelevant to simplified models.) I think that means that scripts are running concurrently with gaps. A script can be sent to JSmol before the previous script finishes executing. The 3.8 eltim system did not increment eltimSptNumber until the previous script was done. This caused two scripts #1, and probably various other irregularities. -------------------------------------------------------------------------------------- "eltim" supersedes "Elapsed". But I'll leave the older "elapsed" code intact in case. -------------------------------------------------------------------------------------- HOW TO USE: EXPLAINED WELL in the Advanced Options page! The TWO non-automatic timings that require manual insertion: 1. Within FirstGlance Javascript ("gaps") reportElapsed(from where) (repurposed from the earlier elapsed time system). 2. Within a script: += makeReportElapsedSpt(locationDescription) which prepends "MidSPT: " to the locn. Requesting a report (clicking red T) opens 2 browser tabs: Timing Summary (sorted eltimSummary) All Scripts (eltimList) SENDING SCRIPTS: Sending a script to JSmol handles eltim automatically: unchangedScriptToJmol(spt) adds "javascript eltimSptDone()" to end of spt. calls eltimSendSpt() which resets the clock (eltimStart). adds one line to eltimSummary. adds the cumulative sec for PREVIOUS GAP to eltimList. adds "Script # going to JSmol" to eltimList. MID-SPT TIMING: Insert into script += makeReportElapsedSpt(locationDescription); SCRIPT COMPLETION: eltimSptDone() (tacked to end of spt when sent): reports sec for execution into eltimSummary and eltimList. draws a line in eltimList prior to the next gap. GAPS: "GAPs" are FirstGlance Javascript between scripts to Jmol, but may include jmolEvaluate(...). MID-GAP TIMING: ***reportElapsed(locationDescription) can be used between scripts (gaps). It does eltimMid(locationDescription) which adds to eltimList: sec at MidGAP: locationDescription, where sec is cumulative since previous SPT completed. -------------------------------------------------------------------------------------- Plan: 1. A numbered list of full scripts sent to unchangedScriptToJmol() in top.js, with their EXECUTION times. Between each pair of consecutive scripts will be the numbered (interscript) GAP time. (GAP = NON-JSMOL "NJ"? J is confusing re Javascript. Or PREP time?) EXECUTION time begins when script is sent to JSmol, and ends when it is completed: javascript recordScriptCompletion() GAP time begins when a script completes, and ends when a new script is sent to JSmol. GAP times longer than ??? sec are not included in total and listed in [] (or gray?). They are assumed to be times awaiting a user response. At the top of the list will be Total Execution time + Total Gap Time = Total Time. 2. A Summary list of execution times, sorted longest at top, followed by script numbers. 3. Lists are simply accumulated as text strings during exection (not displayed). 4. Lists are displayed in new windows when a red "T" below JSmol is clicked, which also resets (blanks) the lists. 5. GAP Time prior a display request (click of T) is not recorded. 6. If script execution time is long, need to find which parts are slow. Script command "javascript eltimMidSpt()" records time since start of script execution. 7. If gap time is long, need to find slow parts. eltimMidGap() records time since start of gap in eltimList only (not in eltimSummary). -------------------------------------------------------------------------------------- "elapsed" already in very wide use. Need a unique token easily searched for all related variables/functions. "eltim" for ElapsedTIMe. Query parameter: eltim=1 Variables: eltimActive boolean eltimList eltimSummary eltimSptTot eltimGapTot eltimStart: time a script is sent or completed eltimSptNumber eltimGapNumber Functions: eltimSendSpt() Called by unchangedScriptToJmol() just before script is sent. Time since eltimStart is recorded as a Gap for eltimGapNumber eltimGapNumber++ add gap time to eltimGapTot reset eltimStart (start of script execution) Append javascript eltimSptDone() to script. send Spt. eltimSptDone() Called by command appended to script: javascript eltimSptDone() Time since eltimStart is recorded as Script Execution Time for eltimSptNumber reset eltimStart (start of gap) eltimSptNumber++ // NOT USED eltimRecord("s"|"g") records event eltimReport() when red "T" clicked, opens new tab and displays report. eltimWriteTButton() puts red T below JSmol cf. eltimMidSpt() records JSmol time since eltimStart in eltimList only (not eltimSummary) eltimMidGap() records Gap time since eltimStart in eltimList only (not eltimSummary) reportElapsed(locationDescription) can be used between scripts.