页面性能调优辅助脚本类
来源:互联网 发布:ise软件win8 编辑:程序博客网 时间:2024/06/05 16:16
由于部分页面对性能要求非常严格,ms级别,所以需要对页面加载、页面DOM元素初始化与展现做调试。附带写了个小TOOL。
希望对大家有所帮助。
function StringBuilder(value) { this.strings = new Array(""); this.append(value); }StringBuilder.prototype.append = function(value) { if (value) this.strings.push(value); }StringBuilder.prototype.clear = function() { this.strings.length = 1; }StringBuilder.prototype.toString = function() { return this.strings.join(""); }/* DOM耗时调试 *//*AddMsg("PageInit",new Date());Debuger = true;ShowStepMsg = false;ShowResult();*/var result = new StringBuilder();var time = new Date();var Debuger = false;var ShowStepMsg = false;function DateDiff(sDate1, sDate2) {//格式1900/01/01 01:01:01 //new Date(year,month-1,day,0,0,0,0); var startDate = new Date(sDate1.replace("-", "/")); var endDate = new Date(sDate2.replace("-", "/")); return Math.abs(endDate - startDate) / 1000; //把相差的毫秒数转换为秒 }function GetCurrentDate() { var now = new Date(); var currentDate = now.getYear(); currentDate += "-" + (now.getMonth() + 1); currentDate += "-" + now.getDate(); currentDate += " " + now.getHours(); currentDate += ":" + now.getMinutes(); currentDate += ":" + now.getSeconds(); return currentDate;}Date.prototype.format = function(format) { var o = { "M+": this.getMonth() + 1, //month "d+": this.getDate(), //day "h+": this.getHours(), //hour "m+": this.getMinutes(), //minute "s+": this.getSeconds(), //second "q+": Math.floor((this.getMonth() + 3) / 3), //quarter "S": this.getMilliseconds() //millisecond } if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); } for (var k in o) if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); return format;}SetStepTime = function(date) { return date.format('yyyy-MM-dd hh:mm:ss:S');}AddMsg = function(tip, date) { if (Debuger) { result.append(tip + "," + SetStepTime(date) + "\r\n"); if (ShowStepMsg) ShowResult(); }}ShowResult = function() { alert(result.toString());}
- 页面性能调优辅助脚本类
- WEB辅助开发、调试、性能检测、调优工具集
- gcov辅助脚本
- DBLinq mysql辅助脚本
- nginx服务,HTTPS_性能测试调优(辅助同事一起测试研究的)
- 提供一段JavaScript脚本以辅助迅雷下载页面中的所有pdf文件链接
- Unity3D脚本18:可视化辅助设置类 Gizmos
- Unity3D脚本18:可视化辅助设置类 Gizmos
- Unity3D脚本18:可视化辅助设置类 Gizmos
- untiy 脚本API之可视化辅助类Gizmos
- 性能调优之页面静态化
- Qt辅助脚本工具syncqt
- Excel VBA脚本辅助编辑
- C# 实现脚本辅助功能
- php代码审计辅助脚本
- 辅助类
- 辅助类
- 辅助类
- 《JMeter从入门到精通》之一——开始你的第一个JMeter脚本
- C#、Javascript闭包(closure)
- 各类签名体制
- 《 AOP 》之基础介绍
- 框架中session为空的解决办法
- 页面性能调优辅助脚本类
- SQL集锦
- I Believe in fate
- SEO标准模板
- 再谈Assert
- 《架构模式应用●设计模式》之构造者
- 终于发现了框架的重要性
- [英语阅读]韩国首尔:公务员考试“挤破头”
- Linux下查看 设置 删除 环境变量方法