perf.js
Simple JavaScript library to monitor frame rate (FPS), frame time (MS) and memory (MEM).
Uses performance.now()
with Date.now()
fallback on older browsers.
perf.js is a self contained library, so monitoring of stats will start by just instantiating it.
var stats = new Perf();
Installation:
npm install perf.js
For haxe users:
haxelib install perf.js
Basic Stats:

With Memory (Chrome only):

With Custom Info (Optional):
Optional custom info can be added if needed, For example the following shows what kind of renderer and pixel ratio pixi.js is using.

To use, simply call addInfo(info)
on perf instance.
stats.addInfo("custom info");
Customisation:
You can customize the following:
Perf.MEASUREMENT_INTERVAL = 1000;
Perf.FONT_FAMILY = "Helvetica,Arial";
Perf.FPS_BG_CLR = "#00FF00";
Perf.FPS_WARN_BG_CLR = "#FF8000";
Perf.FPS_PROB_BG_CLR = "#FF0000";
Perf.MS_BG_CLR = "#FFFF00";
Perf.MEM_BG_CLR = "#086A87";
Perf.INFO_BG_CLR = "#00FFFF";
Perf.FPS_TXT_CLR = "#000000";
Perf.MS_TXT_CLR = "#000000";
Perf.MEM_TXT_CLR = "#FFFFFF";
Perf.INFO_TXT_CLR = "#000000";
The values assigned above are the default values.
Positioning:
By default stats appear on the top right corner. The position can be changed by passing the position to the constructor when instantiating Perf
.
Top Right - default
var stats = new Perf();
Top Left
var stats = new Perf(Perf.TOP_LEFT);
Bottom Right
var stats = new Perf(Perf.BOTTOM_RIGHT);
Bottom Left
var stats = new Perf(Perf.BOTTOM_LEFT);
Offset
Offset is optional and is 0 by default.
var stats = new Perf(Perf.TOP_LEFT, 100);
Bookmarklet:
javascript:{var script=document;{{ifnull==dreturn null;null==d__id__&&d__id__=k++;var c;null==ahx__closures__?ahx__closures__={}:c=ahx__closures__d__id__;null==c&&{return cmethod}cscope=acmethod=dahx__closures__d__id__=c;return c}var a=h{null==d&&d=0;null==g&&g="TR";this_perfObj=windowperformance;null!=f&&this_memoryObj=f;this_memCheck=null!=this_perfObj&& null!=this_memoryObj&&0<this_memoryObjtotalJSHeapSize;this_pos=g;this_offset=d;thiscurrentFps=60;thiscurrentMs=0;thiscurrentMem="0";thisavgFps=thislowFps=60;this_ticks=this_time=this_totalFps=this_measureCount=0;this_fpsMax=this_fpsMin=60;null!=this_perfObj&&null!=b=this_perfObj?this_startTime=this_perfObj:this_startTime=;this_prevTime=-aMEASUREMENT_INTERVAL;this;this;this_memCheck&&this; null!=b=window?thisRAF=b=window:null!=windowmozRequestAnimationFrame?thisRAF=windowmozRequestAnimationFrame:null!=windowwebkitRequestAnimationFrame?thisRAF=windowwebkitRequestAnimationFrame:null!=windowmsRequestAnimationFrame&&thisRAF=windowmsRequestAnimationFrame;null!=b=window?thisCAF=b=window:null!=windowmozCancelAnimationFrame?thisCAF=windowmozCancelAnimationFrame: null!=windowwebkitCancelAnimationFrame?thisCAF=windowwebkitCancelAnimationFrame:null!=windowmsCancelAnimationFrame&&thisCAF=windowmsCancelAnimationFrame;null!=thisRAF&&this_raf=f};aprototype={thiscurrentFps=60;thiscurrentMs=0;thiscurrentMem="0";thisavgFps=thislowFps=60;this_ticks=this_time=this_totalFps=this_measureCount=0;this_fpsMax=this_fpsMin=60;null!=this_perfObj&&null!=b=this_perfObj?this_startTime= this_perfObj:this_startTime=;this_prevTime=-aMEASUREMENT_INTERVAL}{return null!=this_perfObj&&null!=b=this_perfObj?this_perfObj:}{var d;d=null!=this_perfObj&&null!=b=this_perfObj?this_perfObj:;this_ticks++;null!=this_raf&&d>this_prevTime+aMEASUREMENT_INTERVAL&&thiscurrentMs=MaththismsinnerHTML="MS: "+thiscurrentMsthiscurrentFps= Math0<thiscurrentFps&&g>aDELAY_TIME&&this_measureCount++this_totalFps+=thiscurrentFpsthislowFps=this_fpsMin=Maththis_fpsMax=MaththisavgFps=MaththisfpsinnerHTML="FPS: "+thiscurrentFps+" ("+this_fpsMin+"-"+this_fpsMax+")"thisfpsstylebackgroundColor=30<=thiscurrentFps?aFPS_BG_CLR:15<=thiscurrentFps?aFPS_WARN_BG_CLR:aFPS_PROB_BG_CLR this_prevTime=dthis_ticks=0this_memCheck&&thiscurrentMem=thisthismemoryinnerHTML="MEM: "+thiscurrentMem;this_startTime=d;null!=this_raf&&this_raf=f}{null==d&&d=0;var c;c=windowdocument;cid=b;cclassName=b;cstyleposition="absolute";cstylewidth="80px";cstyleheight="12px";cstylelineHeight="12px";cstylepadding="2px";cstylefontFamily=aFONT_FAMILY;cstylefontSize="9px";cstylefontWeight="bold";cstyletextAlign="center";windowdocumentbody;return c}{thisfps= this;thisfpsstylebackgroundColor=aFPS_BG_CLR;thisfpsstylezIndex="995";thisfpsstylecolor=aFPS_TXT_CLR;thisfpsinnerHTML="FPS: 0"}{thisms=this;thismsstylebackgroundColor=aMS_BG_CLR;thismsstylezIndex="996";thismsstylecolor=aMS_TXT_CLR;thismsinnerHTML="MS: 0"}{thismemory=this;thismemorystylebackgroundColor=aMEM_BG_CLR;thismemorystylecolor=aMEM_TXT_CLR;thismemorystylezIndex= "997";thismemoryinnerHTML="MEM: 0"}{null==d&&d=0;if0==areturn"0";var c=Mathb=Math;return Math/c+" "+"Bytes""KB""MB""GB""TB"b}{thisinfo=this;thisinfostylebackgroundColor=aINFO_BG_CLR;thisinfostylecolor=aINFO_TXT_CLR;thisinfostylezIndex="998";thisinfoinnerHTML=b}{null!=thisinfo&&windowdocumentbody thisinfo=null}{f;this_memoryObj=this_perfObj=this_raf=null;null!=thisfps&&windowdocumentbodythisfps=null;null!=thisms&&windowdocumentbodythisms=null;null!=thismemory&&windowdocumentbodythismemory=null;this;thiscurrentFps=60;thiscurrentMs=0;thiscurrentMem="0";thisavgFps=thislowFps=60;this_ticks=this_time=this_totalFps=this_measureCount= 0;this_fpsMax=this_fpsMin=60;null!=this_perfObj&&null!=b=this_perfObj?this_startTime=this_perfObj:this_startTime=;this_prevTime=-aMEASUREMENT_INTERVAL}{f;this_raf=null};var {};f{tryreturn abcatchcreturn null};f{return b};var bk=0;aMEASUREMENT_INTERVAL=1E3;aFONT_FAMILY="Helvetica,Arial";aFPS_BG_CLR="#00FF00"; aFPS_WARN_BG_CLR="#FF8000";aFPS_PROB_BG_CLR="#FF0000";aMS_BG_CLR="#FFFF00";aMEM_BG_CLR="#086A87";aINFO_BG_CLR="#00FFFF";aFPS_TXT_CLR="#000000";aMS_TXT_CLR="#000000";aMEM_TXT_CLR="#FFFFFF";aINFO_TXT_CLR="#000000";aTOP_LEFT="TL";aTOP_RIGHT="TR";aBOTTOM_LEFT="BL";aBOTTOM_RIGHT="BR";aDELAY_TIME=4E3}"undefined"!=typeof console?console:{}"undefined"!=typeof window?window:exports; var stats = PerfTOP_RIGHT 0;documenthead;};
Licensing Information
This content is released under the MIT License.