如本博客左上角显示FPS帧数
做到这个很简单
直接将以下代码加到博客底部就完工了

$('body').before('<div id="fps" style="z-index:10000;position:fixed;top:3;left:3;font-weight:bold;"></div>');
var showFPS = (function(){ 
    var requestAnimationFrame =  
        window.requestAnimationFrame || 
        window.webkitRequestAnimationFrame || 
        window.mozRequestAnimationFrame ||
        window.oRequestAnimationFrame ||
        window.msRequestAnimationFrame || 
        function(callback) { 
            window.setTimeout(callback, 1000/60); 
        }; 
    var e,pe,pid,fps,last,offset,step,appendFps; 
 
    fps = 0; 
    last = Date.now(); 
    step = function(){ 
        offset = Date.now() - last; 
        fps += 1; 
        if( offset >= 1000 ){ 
        last += offset; 
        appendFps(fps); 
        fps = 0; 
        } 
        requestAnimationFrame( step ); 
    }; 
    appendFps = function(fps){ 
        console.log(fps+'FPS');
        $('#fps').html(fps+'FPS');
    };
    step();
})();

注意这是JavaScript代码
需要加在 <script></script>标签内

出现运行报错可能是本站调用了jQuery调用即可
或者自己懂代码的可以改一下

最后修改:2022 年 02 月 14 日 10 : 22 PM
如果觉得我的文章对你有用,请随意赞赏
  • 本文作者:雨落倾城
  • 本文链接:https://yuluoqc.xyz/2022/02/14/658.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
  • # 商业转载请联系作者获得授权,非商业转载请注明出处
    # 协议(License):署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
    # For commercial use, please contact the author for authorization. For non-commercial use, please indicate the source.