lib/profile.js
function report() {
      return Object.keys(eventsByFilename)
        .filter(testIncluded)
        .reduce(reduceFilenames, {});

      function testIncluded(filename) {
        return !excludeRegex || !excludeRegex.test(filename);
      }

      function reduceFilenames(reduced, filename) {
        var totalsByKey = {},
            list        = eventsByFilename[filename],
            lastKey     = null,
            lastTime    = NaN;

        // events consist of time,key pairs
        for (var i = 0; i < list.length; i += 2) {
          var time = list[i],
              key  = list[i + 1];
          if (lastKey) {
            var initial = totalsByKey[key] || 0,
                delta   = ((time - lastTime) / 1000) || 0;
            totalsByKey[lastKey] = initial + delta;
          }
          lastKey = key;
          lastTime = time;
        }

        // total at the end to guarantee consistency
        var total = 0;
        for (var key in totalsByKey) {
          total += totalsByKey[key];
        }
        totalsByKey.total = total;

        // store by the short filename
        var short = path.relative(process.cwd(), filename);
        reduced[short] = totalsByKey;
        return reduced;
      }
    }
function report() {
      return Object.keys(eventsByFilename)
        .filter(testIncluded)
        .reduce(reduceFilenames, {});

      function testIncluded(filename) {
        return !excludeRegex || !excludeRegex.test(filename);
      }

      function reduceFilenames(reduced, filename) {
        var totalsByKey = {},
            list        = eventsByFilename[filename],
            lastKey     = null,
            lastTime    = NaN;

        // events consist of time,key pairs
        for (var i = 0; i < list.length; i += 2) {
          var time = list[i],
              key  = list[i + 1];
          if (lastKey) {
            var initial = totalsByKey[key] || 0,
                delta   = ((time - lastTime) / 1000) || 0;
            totalsByKey[lastKey] = initial + delta;
          }
          lastKey = key;
          lastTime = time;
        }

        // total at the end to guarantee consistency
        var total = 0;
        for (var key in totalsByKey) {
          total += totalsByKey[key];
        }
        totalsByKey.total = total;

        // store by the short filename
        var short = path.relative(process.cwd(), filename);
        reduced[short] = totalsByKey;
        return reduced;
      }
    }
function report ( ) { return Object . keys ( eventsByFilename ) . filter ( testIncluded ) . reduce ( reduceFilenames , { } ) ; function testIncluded ( filename ) { return ! excludeRegex || ! excludeRegex . test ( filename ) ; } function reduceFilenames ( reduced , filename ) { var totalsByKey = { } , list = eventsByFilename [ filename ] , lastKey = null , lastTime = NaN ; // events consist of time,key pairs for ( var i = 0 ; i < list . length ; i += 2 ) { var time = list [ i ] , key = list [ i + 1 ] ; if ( lastKey ) { var initial = totalsByKey [ key ] || 0 , delta = ( ( time - lastTime ) / 1000 ) || 0 ; totalsByKey [ lastKey ] = initial + delta ; } lastKey = key ; lastTime = time ; } // total at the end to guarantee consistency var total = 0 ; for ( var key in totalsByKey ) { total += totalsByKey [ key ] ; } totalsByKey . total = total ; // store by the short filename var short = path . relative ( process . cwd ( ) , filename ) ; reduced [ short ] = totalsByKey ; return reduced ; } }
Create a json report of time verses key verses filename.
Create a json report of time verses key verses filename .