aboutsummaryrefslogtreecommitdiff
path: root/tmp/test-node.js
blob: bb009e7491e9845867cce92db2806f942dfc430f (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /usr/bin/env node

var sys = require("util");
var fs = require("fs");

var UglifyJS = require("../tools/node");

var filename = process.argv[2];
var code = fs.readFileSync(filename, "utf8");

var ast = time_it("parse", function() {
    return UglifyJS.parse(code);
});
var stream = UglifyJS.OutputStream({ beautify: false });
time_it("scope", function(){
    ast.figure_out_scope();
});
// time_it("mangle", function(){
//     ast.mangle_names();
// });

//ast.scope_warnings();

time_it("compress", function(){
    var compressor = new UglifyJS.Compressor({
    });
    ast = ast.squeeze(compressor);
});

time_it("generate", function(){
    ast.print(stream);
});
sys.puts(stream.get());

//ast.scope_warnings();

function time_it(name, cont) {
    var t1 = new Date().getTime();
    try { return cont(); }
    finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
};