<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">Source:
/** * @author Mrdoob/http://mrdoob.com/ */varStats =function () {varStartTime = Date.now (), Prevtime =StartTime; varms =0, msmin = Infinity, Msmax =0; varfps =0, fpsmin = Infinity, Fpsmax =0; varFrames =0, mode =0; varcontainer = Document.createelement ('Div' ); Container.id='Stats'; Container.addeventlistener ('MouseDown', Function (Event) {Event. Preventdefault (); SetMode (+ + mode%2) },false ); Container.style.cssText='Width:80px;opacity:0.9;cursor:pointer'; varFpsdiv = Document.createelement ('Div' ); Fpsdiv.id='fps'; FpsDiv.style.cssText='padding:0 0 3px 3px;text-align:left;background-color: #002'; Container.appendchild (FPSDIV); varFpstext = Document.createelement ('Div' ); Fpstext.id='Fpstext'; FpsText.style.cssText='color: #0ff; font-family:helvetica,arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px'; Fpstext.innerhtml='FPS'; Fpsdiv.appendchild (Fpstext); varFpsgraph = Document.createelement ('Div' ); Fpsgraph.id='Fpsgraph'; FpsGraph.style.cssText='Position:relative;width:74px;height:30px;background-color: #0ff'; Fpsdiv.appendchild (fpsgraph); while(FpsGraph.children.length < About ) { varBar = Document.createelement ('span' ); Bar.style.cssText='Width:1px;height:30px;float:left;background-color: #113'; Fpsgraph.appendchild (bar); } varMsdiv = Document.createelement ('Div' ); Msdiv.id='Ms'; MsDiv.style.cssText='padding:0 0 3px 3px;text-align:left;background-color: #020;d isplay:none'; Container.appendchild (MSDIV); varMstext = Document.createelement ('Div' ); Mstext.id='Mstext'; MsText.style.cssText='color: #0f0; font-family:helvetica,arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px'; Mstext.innerhtml='MS'; Msdiv.appendchild (Mstext); varMSGraph = Document.createelement ('Div' ); Msgraph.id='MSGraph'; MsGraph.style.cssText='Position:relative;width:74px;height:30px;background-color: #0f0'; Msdiv.appendchild (MSGraph); while(MsGraph.children.length < About ) { varBar = Document.createelement ('span' ); Bar.style.cssText='Width:1px;height:30px;float:left;background-color: #131'; Msgraph.appendchild (bar); } varSetMode =function (value) {mode=value; Switch(mode) { Case 0: FpsDiv.style.display='Block'; MsDiv.style.display='None'; Break; Case 1: FpsDiv.style.display='None'; MsDiv.style.display='Block'; Break; } } varUpdategraph =function (DOM, value) {varChild =Dom.appendchild (Dom.firstchild); Child.style.height= value +'px'; } return{REVISION: One, Domelement:container, Setmode:setmode, Begin:function () {startTime=Date.now (); }, End:function () {varTime =Date.now (); Ms= Time-StartTime; Msmin=math.min (Msmin, MS); Msmax=Math.max (Msmax, MS); Mstext.textcontent= ms +'MS ('+ Msmin +'-'+ Msmax +')'; Updategraph (MSGraph, Math.min ( -, --(MS/ $) * - ) ); Frames++; if(Time > Prevtime + +) {fps= Math.Round ((Frames * +)/(Time-prevtime)); Fpsmin=math.min (Fpsmin, fps); Fpsmax=Math.max (Fpsmax, fps); Fpstext.textcontent= fps +'FPS ('+ Fpsmin +'-'+ Fpsmax +')'; Updategraph (Fpsgraph, Math.min ( -, --(FPS/ -) * - ) ); Prevtime=Time ; Frames=0; } returnTime ; }, Update:function () {startTime= This. end (); } }};
View CodeStats.js view fps at any time