(function(){function a(h,g,f){if(h.length===+h.length){for(var e=0,c=h.length;e<c;e++){if(g.call(f,e,h[e],h)===false){return}}}else{for(var d in h){if(h.hasOwnProperty(d)){if(g.call(f,d,h[d],h)===false){return}}}}}var b=function(e,d){this._render_start=e.render_start;this._data=e;this._render_timing={ht:0,vt:0,drt:0,tti:0,lt:0,fvt:0,crt:0};this._conf=d||{log_path:"http://static.tieba.baidu.com/tb/pms/img/st.gif",img_conn_path:"http://xs.tieba.baidu.com/cache_monitor",display:false};if(window.PDC&&PDC._opt.log_path){this._conf.log_path=PDC._opt.log_path}this._performance_timing={};this._metrics=[];this._readyCount=0;a(e.timing,function(f,g){this._render_timing[f]=g},this);var c=this;if(document.attachEvent){window.attachEvent("onbeforeunload",function(){c._unload_send()})}else{window.addEventListener("beforeunload",function(){c._unload_send()},false)}this._measureScreen();this._browser();this._cache();this._measureNetworkTime();this._measureRenderTime();this._speicalParams();this._ready()};b.prototype._speicalParams=function(){var c=window.PDC&&PDC._opt&&PDC._opt.s_params;if(c){a(c,function(d,e){this._metrics.push("cus_"+d+"="+e)},this)}};b.prototype._ready=function(){this._readyCount++;if(this._readyCount==2){this.send()}};b.prototype._measureScreen=function(){if(window.screen){this._metrics.push("_screen="+window.screen.width+"*"+window.screen.height+"|"+window.screen.availWidth+"*"+window.screen.availHeight)}};b.prototype.getFPT=function(){var c;if(window.performance&&performance.timing&&performance.timing.msFirstPaint){c=performance.timing.msFirstPaint}else{if(window.chrome&&chrome.loadTimes){c=parseInt(chrome.loadTimes().firstPaintTime*1000)}}return c};b.prototype._measureNetworkTime=function(){var e={};var f=0;if(window.performance&&performance.timing){var d=performance.timing;f=d.domainLookupStart;e.dns=d.domainLookupEnd;e.ct=d.connectEnd;e.st=d.responseStart;e.tt=d.responseEnd;e.dct=d.domComplete;e.olt=d.loadEventEnd;if(this.getFPT()){e.nfpt=this.getFPT()}var c=PDC._render_start-d.navigationStart;c>0&&this._metrics.push("wtt="+c)}this._measureTime(f,e)};b.prototype._measureTime=function(e,c){var d=0;a(c,function(f,g){d=(""+g).length<8?g:g-e;this._metrics.push(f+"="+d)},this)};b.prototype._measureRenderTime=function(){if(window.performance&&window.performance.timing){var c=window.performance.timing;this._performance_timing=c;this._render_timing.lt=c.loadEventStart;if(c.loadEventEnd>0){this._render_timing.let=c.loadEventEnd}}if(this.getFPT()){this._render_timing.fpt=this.getFPT()}if(this._render_timing.fvt==0){this._render_timing.fvt=this._render_timing.crt=this._render_timing.let}this._measureTime(this._render_start,this._render_timing)};b.prototype._browser=function(){var c=this._uaMatch(navigator.userAgent);var e=c.browser;if(e=="msie"){if(document.documentMode){var d=c.version.substring(0,1);if(window.performance){e+="9.0";this._metrics.push("ebrowser="+d+"9"+document.documentMode)}else{e+="8.0";this._metrics.push("ebrowser="+d+"8"+document.documentMode)}}else{e+=c.version}}var f={"msie6.0":16,"msie7.0":17,"msie8.0":18,"msie9.0":19,chrome:20,mozilla:30,safari:40,opera:50};this._metrics.push("browser="+(f[e]||0))};b.prototype._uaMatch=function(f){var e=/(chrome)\/(\d+\.\d)/,j=/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/,i=/(opera)(?:.*version)?[ \/]([\w.]+)/,g=/(msie) ([\w.]+)/,h=/(mozilla)(?:.*? rv:([\w.]+))?/,f=f.toLowerCase(),c={};var d=e.exec(f)||i.exec(f)||g.exec(f)||f.indexOf("compatible")<0&&h.exec(f)||[];if(j.test(f)&&!/chrome/.test(f)){d[1]="safari";d[2]=RegExp["$1"]||RegExp["$2"]}return{browser:d[1]||"unknown",version:d[2]||"0"}};b.prototype._cache=function(){var c=new Image(),f,e,d=this,g=0;c.onload=function(){e=new Date();if(e-f<=1000){g=1}d._metrics.push("cache="+g);d._ready()};c.onerror=function(){d._ready()};f=new Date();c.src="http://static.tieba.baidu.com/cache_monitor"};b.prototype.send=function(){if(b._is_send){return}b._is_send=true;var d=this._data.env,e=this._metrics,f=this._connection_num;a(d,function(g,h){e.push(g+"="+h)});if(window._trace_page_logid){e.push("logid="+_trace_page_logid)}e.push("pf="+navigator.platform);e.push("_t="+new Date()*1);var c=document.createElement("img");c.src=this._conf.log_path+"?"+e.join("&");window["___pms_img_"+new Date()*1]=c};b.prototype._unload_send=function(){if(b._is_unload_send){return}b._is_unload_send=true;var e=this._data.env,f=[];if(window.F&&F.fisMark){var g=this._render_start,d=[];a(F.fisMark,function(i,j){var h=[];a(j,function(k,l){h.push('"'+k+'":'+(l-g))},this);d.push('"'+i+'":{'+h.join(",")+"}")},this);f.push("fis_timing={"+d.join(",")+"}")}if(f.length>0){a(e,function(h,i){f.push(h+"="+i)});var c=document.createElement("img");c.src=this._conf.log_path+"?"+f.join("&");window["___pms_img_"+new Date()*1]=c}};if(!window.WPO_PDA){window.WPO_PDA=new b(PDC.metadata())}})();