Chinaunix首页 | 论坛 | 博客
  • 博客访问: 365149
  • 博文数量: 284
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1707
  • 用 户 组: 普通用户
  • 注册时间: 2014-05-14 16:38
文章分类

全部博文(284)

文章存档

2015年(6)

2014年(278)

我的朋友

分类: JavaScript

2014-07-29 16:17:55

随手写了个小工具,主要为了测试不同混淆程度的javascript脚本的加载速度
1. [代码]Timestamp.js     

(function() {
 
if (typeof this.Timestamp == 'undefined') {
    /**
     * Global timestamp manager
     * @author Janpoem
     * created at 2011.03.30
     */
    this.Timestamp = (function() {
 
        var pool = {
            'page_init': new Date()
        };
 
        return {
            add: function(flag) {
                pool[flag] = new Date();
            },
            get: function(flag) {
                return typeof flag == 'undefined' ? pool : (pool[flag] ? pool[flag] : pool);
            },
            diff: function(to, diff) {
                if (!diff)
                    diff = to, to = 'page_init';
                return (pool[to] && pool[diff]) ? pool[diff] - pool[to] : 0;
            }
        }
    }) ();
}
 
}) ();
2. [代码]实际用例    




MooTools Test Page









阅读(470) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~