tasks/perfbudget.js
function(data) {

      var budget = options.budget,
          summary = data.data.summary,
          median = options.repeatView ? data.data.median.repeatView : data.data.median.firstView,
          pass = true,
          str = "";

      for (var item in budget) {
        // make sure this is objects own property and not inherited
        if (budget.hasOwnProperty(item)) {
          //make sure it exists
          if (budget[item] !== '' && median.hasOwnProperty(item)) {
            if (median[item] > budget[item]) {
              pass = false;
              str += item + ': ' + median[item] + ' [FAIL]. Budget is ' + budget[item] + '\n';
            } else {
              str += item + ': ' + median[item] + ' [PASS]. Budget is ' + budget[item] + '\n';
            }
          }
        }
      }

      //save the file before failing or passing
      var output = options.output;
      if (typeof output !== 'undefined') {
        grunt.log.ok('Writing file: ' + output);
        grunt.file.write(output, JSON.stringify(data));
      }

      //
      //output our header and results
      if (!pass) {
        grunt.log.error('\n\n-----------------------------------------------' +
              '\nTest for ' + options.url + ' \t  FAILED' +
            '\n-----------------------------------------------\n\n');
        grunt.log.error(str);
        grunt.log.error('Summary: ' + summary);
        done(false);
      } else {
        grunt.log.ok('\n\n-----------------------------------------------' +
              '\nTest for ' + options.url + ' \t  PASSED' +
            '\n-----------------------------------------------\n\n');
        grunt.log.ok(str);
        grunt.log.ok('Summary: ' + summary);
        done();
      }
    }
function(data) {

      var budget = options.budget,
          summary = data.data.summary,
          median = options.repeatView ? data.data.median.repeatView : data.data.median.firstView,
          pass = true,
          str = "";

      for (var item in budget) {
        // make sure this is objects own property and not inherited
        if (budget.hasOwnProperty(item)) {
          //make sure it exists
          if (budget[item] !== '' && median.hasOwnProperty(item)) {
            if (median[item] > budget[item]) {
              pass = false;
              str += item + ': ' + median[item] + ' [FAIL]. Budget is ' + budget[item] + '\n';
            } else {
              str += item + ': ' + median[item] + ' [PASS]. Budget is ' + budget[item] + '\n';
            }
          }
        }
      }

      //save the file before failing or passing
      var output = options.output;
      if (typeof output !== 'undefined') {
        grunt.log.ok('Writing file: ' + output);
        grunt.file.write(output, JSON.stringify(data));
      }

      //
      //output our header and results
      if (!pass) {
        grunt.log.error('\n\n-----------------------------------------------' +
              '\nTest for ' + options.url + ' \t  FAILED' +
            '\n-----------------------------------------------\n\n');
        grunt.log.error(str);
        grunt.log.error('Summary: ' + summary);
        done(false);
      } else {
        grunt.log.ok('\n\n-----------------------------------------------' +
              '\nTest for ' + options.url + ' \t  PASSED' +
            '\n-----------------------------------------------\n\n');
        grunt.log.ok(str);
        grunt.log.ok('Summary: ' + summary);
        done();
      }
    }
function ( data ) { var budget = options . budget , summary = data . data . summary , median = options . repeatView ? data . data . median . repeatView : data . data . median . firstView , pass = true , str = "" ; for ( var item in budget ) { // make sure this is objects own property and not inherited if ( budget . hasOwnProperty ( item ) ) { //make sure it exists if ( budget [ item ] !== '' && median . hasOwnProperty ( item ) ) { if ( median [ item ] > budget [ item ] ) { pass = false ; str += item + ': ' + median [ item ] + ' [FAIL]. Budget is ' + budget [ item ] + '\n' ; } else { str += item + ': ' + median [ item ] + ' [PASS]. Budget is ' + budget [ item ] + '\n' ; } } } } //save the file before failing or passing var output = options . output ; if ( typeof output !== 'undefined' ) { grunt . log . ok ( 'Writing file: ' + output ) ; grunt . file . write ( output , JSON . stringify ( data ) ) ; } // //output our header and results if ( ! pass ) { grunt . log . error ( '\n\n-----------------------------------------------' + '\nTest for ' + options . url + ' \t  FAILED' + '\n-----------------------------------------------\n\n' ) ; grunt . log . error ( str ) ; grunt . log . error ( 'Summary: ' + summary ) ; done ( false ) ; } else { grunt . log . ok ( '\n\n-----------------------------------------------' + '\nTest for ' + options . url + ' \t  PASSED' + '\n-----------------------------------------------\n\n' ) ; grunt . log . ok ( str ) ; grunt . log . ok ( 'Summary: ' + summary ) ; done ( ) ; } }
takes the data returned by wpt.getTestResults and compares to our budget thresholds
takes the data returned by wpt . getTestResults and compares to our budget thresholds