HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/1991111/root/usr/share/doc/node-chrome-trace-event/examples/
Upload File :
Current File : //proc/1991111/root/usr/share/doc/node-chrome-trace-event/examples/child.js
/*
 * Show `evt.child()` usage for more practical usage. `.child(fields)`
 * allows you to bind common fields to emited events.
 */

var fs = require("fs");

var EVT = new (require("../dist/trace-event")).Tracer();
EVT.pipe(process.stdout);

function doSubTaskA(opts, cb) {
  var evt = EVT.child({ id: opts.id, name: "doSubTaskA" });
  evt.begin();
  setTimeout(function() {
    // ...
    evt.end();
    cb();
  }, Math.floor(Math.random() * 2000));
}

function doSomething(opts, cb) {
  var evt = EVT.child({ id: opts.id, name: "doSomething" });
  evt.begin();
  setTimeout(function() {
    // ...
    doSubTaskA(opts, function() {
      evt.end();
      cb();
    });
  }, Math.floor(Math.random() * 2000));
}

for (var i = 0; i < 5; i++) {
  doSomething({ id: i }, function() {});
}