dot.dot.dot.exampol
This commit is contained in:
commit
a0bc2d79de
406 changed files with 34577 additions and 0 deletions
51
node_modules/bunker/example/prof.js
generated
vendored
Normal file
51
node_modules/bunker/example/prof.js
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
var bunker = require('bunker');
|
||||
var b = bunker('(' + function () {
|
||||
function beep () {
|
||||
var x = 0;
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
for (var j = 0; j < 100; j++) {
|
||||
x += j;
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
beep();
|
||||
|
||||
} + ')()');
|
||||
|
||||
var counts = {};
|
||||
|
||||
b.on('node', function (node) {
|
||||
if (!counts[node.id]) {
|
||||
counts[node.id] = { times : 0, node : node, elapsed : 0 };
|
||||
}
|
||||
counts[node.id].times ++;
|
||||
|
||||
var now = Date.now();
|
||||
|
||||
if (last.id !== undefined) {
|
||||
counts[last.id].elapsed += last.
|
||||
}
|
||||
|
||||
if (node.name === 'call') {
|
||||
var start = now;
|
||||
|
||||
last.id = node.id;
|
||||
counts[node.id].elapsed += Date.now() - start;
|
||||
}
|
||||
else {
|
||||
counts[node.id].elapsed += now - last;
|
||||
last = now;
|
||||
}
|
||||
});
|
||||
|
||||
b.run();
|
||||
|
||||
Object.keys(counts).forEach(function (key) {
|
||||
var count = counts[key];
|
||||
console.log(
|
||||
[ count.times, count.node.source(), count.elapsed ]
|
||||
.join(' : ')
|
||||
);
|
||||
});
|
18
node_modules/bunker/example/tiny.js
generated
vendored
Normal file
18
node_modules/bunker/example/tiny.js
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
var bunker = require('bunker');
|
||||
var b = bunker('var x = 0; for (var i = 0; i < 30; i++) { x++ }');
|
||||
|
||||
var counts = {};
|
||||
|
||||
b.on('node', function (node) {
|
||||
if (!counts[node.id]) {
|
||||
counts[node.id] = { times : 0, node : node };
|
||||
}
|
||||
counts[node.id].times ++;
|
||||
});
|
||||
|
||||
b.run();
|
||||
|
||||
Object.keys(counts).forEach(function (key) {
|
||||
var count = counts[key];
|
||||
console.log(count.times + ' : ' + count.node.source());
|
||||
});
|
31
node_modules/bunker/example/top/run.js
generated
vendored
Normal file
31
node_modules/bunker/example/top/run.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
var bunker = require('bunker');
|
||||
var fs = require('fs');
|
||||
var src = fs.readFileSync(__dirname + '/src.js', 'utf8');
|
||||
|
||||
var counts = {};
|
||||
|
||||
var b = bunker(src);
|
||||
b.on('node', function (node) {
|
||||
if (!counts[node.id]) {
|
||||
counts[node.id] = { times : 0, node : node };
|
||||
}
|
||||
counts[node.id].times ++;
|
||||
});
|
||||
|
||||
b.run({
|
||||
setInterval : setInterval,
|
||||
clearInterval : clearInterval,
|
||||
end : function () {
|
||||
Object.keys(counts)
|
||||
.sort(function (a, b) {
|
||||
return counts[b].times - counts[a].times
|
||||
})
|
||||
.forEach(function (key) {
|
||||
var count = counts[key];
|
||||
console.log(
|
||||
count.times + ' : ' + count.node.source()
|
||||
);
|
||||
})
|
||||
;
|
||||
}
|
||||
});
|
18
node_modules/bunker/example/top/src.js
generated
vendored
Normal file
18
node_modules/bunker/example/top/src.js
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
function boop () {
|
||||
for (var i = 0; i < 30; i++) {
|
||||
nop();
|
||||
}
|
||||
}
|
||||
|
||||
function nop () {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var times = 0;
|
||||
var iv = setInterval(function () {
|
||||
if (++times === 10) {
|
||||
clearInterval(iv);
|
||||
end();
|
||||
}
|
||||
else boop()
|
||||
}, 100);
|
Loading…
Add table
Add a link
Reference in a new issue