How to use the @angular/benchpress.Options function in @angular/benchpress

To help you get started, we’ve selected a few @angular/benchpress examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github handsontable / performance-lab / test / runner.js View on Github external
const HOT_VERSION = process.env.HOT_VERSION;

const bindings = [
  benchpress.SeleniumWebDriverAdapter.PROTRACTOR_PROVIDERS,
  // { provide: benchpress.Options.FORCE_GC, useValue: true },
  { provide: benchpress.RegressionSlopeValidator.SAMPLE_SIZE, useValue: config.SAMPLE_SIZE },
  benchpress.JsonFileReporter.PROVIDERS,
  benchpress.MultiReporter.provideWith([
    benchpress.ConsoleReporter,
    benchpress.JsonFileReporter
  ]),
];

benchpress.Options.DEFAULT_PROVIDERS.push({
  provide: benchpress.Options.WRITE_FILE,
  useValue: (filename, content) => void process.send(content),
});

const runner = new benchpress.Runner(bindings);

exports.runSample = async function(config) {
  config.providers = [{
    provide: benchpress.Options.SAMPLE_DESCRIPTION,
    useValue: { hotVersion: HOT_VERSION }
  }];

  return new Promise((resolve) => {
    setTimeout(() => resolve(runner.sample(config)), 50);
  });
}
github handsontable / performance-lab / test / runner.js View on Github external
const path = require('path');

const HOT_VERSION = process.env.HOT_VERSION;

const bindings = [
  benchpress.SeleniumWebDriverAdapter.PROTRACTOR_PROVIDERS,
  // { provide: benchpress.Options.FORCE_GC, useValue: true },
  { provide: benchpress.RegressionSlopeValidator.SAMPLE_SIZE, useValue: config.SAMPLE_SIZE },
  benchpress.JsonFileReporter.PROVIDERS,
  benchpress.MultiReporter.provideWith([
    benchpress.ConsoleReporter,
    benchpress.JsonFileReporter
  ]),
];

benchpress.Options.DEFAULT_PROVIDERS.push({
  provide: benchpress.Options.WRITE_FILE,
  useValue: (filename, content) => void process.send(content),
});

const runner = new benchpress.Runner(bindings);

exports.runSample = async function(config) {
  config.providers = [{
    provide: benchpress.Options.SAMPLE_DESCRIPTION,
    useValue: { hotVersion: HOT_VERSION }
  }];

  return new Promise((resolve) => {
    setTimeout(() => resolve(runner.sample(config)), 50);
  });
}
github angular / benchpress-tree / tree_benchmark.spec.js View on Github external
var benchpress = require('@angular/benchpress');
var runner = new benchpress.Runner([
  //use protractor as Webdriver client
  benchpress.SeleniumWebDriverAdapter.PROTRACTOR_PROVIDERS,
  //use RegressionSlopeValidator to validate samples
  {provide: benchpress.Validator, useExisting: benchpress.RegressionSlopeValidator},
  //use 10 samples to calculate slope regression
  {provide: benchpress.RegressionSlopeValidator.SAMPLE_SIZE, useValue: 20},
  //use the script metric to calculate slope regression
  {provide: benchpress.RegressionSlopeValidator.METRIC, useValue: 'scriptTime'},
  {provide: benchpress.Options.FORCE_GC, useValue: true}
]);

describe('deep tree baseline', function() {
  it('should be fast!', function(done) {
    var depth = 11;
    //Tells protractor this isn't an Angular 1 application
    browser.ignoreSynchronization = true;
    //Load the benchmark, with a tree depth of 9
    browser.get('http://localhost:8080/tree.html?depth='+depth);
    /*
     * Tell benchpress to click the buttons to destroy and re-create the tree for each sample.
     * Benchpress will log the collected metrics after each sample is collected, and will stop
     * sampling as soon as the calculated regression slope for last 20 samples is stable.
     */
    runner.sample({
      id: 'deep-tree',
github angular / benchpress-tree / tree_benchmark.spec.js View on Github external
* Tell benchpress to click the buttons to destroy and re-create the tree for each sample.
     * Benchpress will log the collected metrics after each sample is collected, and will stop
     * sampling as soon as the calculated regression slope for last 20 samples is stable.
     */
    runner.sample({
      id: 'deep-tree',
      execute: function() {
        /*
         * Will call querySelector in the browser, but benchpress is smart enough to ignore injected
         * script.
         */
        $('#destroyDom').click();
        $('#createDom').click();
      },
      providers: [{
        provide: benchpress.Options.SAMPLE_DESCRIPTION,
        useValue: { depth: depth }
      }]
    }).then(done, done.fail);
  });
});