Monday, November 08, 2010 at 12:04 AM.
system.verbs.builtins.mainResponder.utilities.getThreadStats
on getThreadStats (flIncludeHeader=true) { <<This script generates a human-readable report from the output of thread.getStats. <<10/25/01; 4:34:32 PM by PBS <<Changes: <<10/31/01; 11:27:37 AM by PBS <<flIncludeHeader, a new optional parameter, specifies whether or not to include general info about this copy of Radio. Set it to false when you're concatenating multiple reports into one. local (text, indentlevel = 0); local (fldebug = false); //set this to false when not debugging on add (s) { text = text + string.filledString ('\t', indentlevel) + s + "\n"}; <<on isAgentsThread (id) <<local (adr) <<for adr in @system.compiler.threads <<if adr^ == id <<if nameOf (adr^) == "agents" <<return (true) <<return (false) on getName (id, adrName) { local (adr); for adr in @system.compiler.threads { if adr^ == id { adrName^ = nameOf (adr^); return (true)}}; return (false)}; bundle { //header add ("Frontier thread stats for " + user.prefs.name + " run at " + clock.now () + "."); add (""); if flIncludeHeader { add ("About This Installation:"); indentlevel++; add ("Radio version: " + Frontier.version ()); local (os = "Windows"); if system.environment.isMac { if system.environment.isCarbon { os = "Mac OS X"} else { os = "Mac OS"}}; add ("Operating System: " + os); local (osVersion = system.environment.osVersionString); if system.environment.isCarbon { osVersion = string.replace (osVersion, "16", "10")}; add ("OS Version: " + osVersion); add ("IP address: " + tcp.dns.getMyDottedId ()); add ("Email: " + user.prefs.mailAddress); add (""); indentlevel--}}; local (t); new (tableType, @t); thread.getStats (@t); local (adr); for adr in @t { local (stats = adr^.threadStats); local (idThread = number (string.nthField (stats, ',', 1))); add ("id: " + idThread); indentlevel++; <<if isAgentsThread (idThread) <<add ("Agents thread") local (name); if getName (idThread, @name) { add ("Name: " + name)}; bundle { //more info about the thread on doField (ix, label, flBoolean=false, flDate=false) { local (val = number (string.nthField (stats, ',', ix))); if flBoolean { val = boolean (val)}; if flDate { val = date (val)}; add (label + ": " + val)}; doField (2, "Time Started (ticks)"); doField (3, "Time To Wake (ticks)"); <<doField (6, "Time to Wake", flDate:true) doField (4, "Time Last Got Control (ticks)"); doField (5, "Time Slice (ticks)"); <<doField (7, "Obsolete Boolean", true) doField (8, "Scheduled for execution", true); doField (9, "One shot", true); doField (10, "In control of processor", true); doField (11, "Called thread verb", true)}; bundle { //do traceback if defined (adr^.traceback) { add (""); add ("Traceback:"); indentlevel++; local (oneCall); for oneCall in adr^.traceback { add (oneCall [3]); indentLevel++; add ("Line: " + oneCall [1]); add ("Character: " + oneCall [2]); indentlevel--}; add (""); indentLevel--}}; indentlevel--; add ("")}; if fldebug { wp.newTextObject (text, @temp.threadStatsText); edit (@temp.threadStatsText)}; return (text)}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.