How to use the benchmark.options function in benchmark

To help you get started, we’ve selected a few benchmark 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 khalidsalomao / simple-query-string / spec / benchmarks.js View on Github external
/* jshint
eqeqeq: true, undef: true, unused: true, indent: 4, plusplus: false, curly: false, forin: true, trailing: true, white: true, sub:true,
browser: true, node: true, devel: true, mocha: true
*/
/* global require */

// benchmarks
var Benchmark = require('benchmark');
if (!Benchmark) return;

Benchmark.options.initCount = 2;
Benchmark.options.delay = 0;
Benchmark.options.maxTime = 1; // secs
Benchmark.options.minSamples = 5;
Benchmark.options.minTime = 0;

// run benchmarks
var Path = require('path');
var Promise = require('bluebird');
var fs = Promise.promisifyAll(require("fs"));
var dir = __dirname;

console.time('benchmark');
console.log("searching files...");
fs.readdirAsync(dir).map(function (file) {
    if (file.indexOf('.js') < 0 || file.indexOf('benchmark-') !== 0) {
        return;
    }
    console.log('------------------');
    console.log("loading file: " + file);
    require(Path.join(dir, file));
github styled-components / styled-components / benchmarks / server / src / benchmark.js View on Github external
import { renderStylesToString } from 'emotion-server';
import { withStyles, MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';
import ButtonBase from '@material-ui/core/ButtonBase';

const theme = createMuiTheme();

const suite = new Benchmark.Suite('ssr', {
  onError: event => {
    console.log(event.target.error);
  },
  onStart: () => {
    console.log('\nStarting benchmarks...');
  },
});

Benchmark.options.minSamples = 100;

global.__MUI_USE_NEXT_TYPOGRAPHY_VARIANTS__ = true;

function NakedButton(props) {
  return <button type="button">;
}

const JssButton = withStyles({
  root: {
    display: 'inline-flex',
    alignItems: 'center',
    justifyContent: 'center',
    position: 'relative',
    // Remove grey highlight
    WebkitTapHighlightColor: 'transparent',
    backgroundColor: 'transparent', // Reset default value</button>
github khalidsalomao / simple-query-string / spec / benchmarks.js View on Github external
/* jshint
eqeqeq: true, undef: true, unused: true, indent: 4, plusplus: false, curly: false, forin: true, trailing: true, white: true, sub:true,
browser: true, node: true, devel: true, mocha: true
*/
/* global require */

// benchmarks
var Benchmark = require('benchmark');
if (!Benchmark) return;

Benchmark.options.initCount = 2;
Benchmark.options.delay = 0;
Benchmark.options.maxTime = 1; // secs
Benchmark.options.minSamples = 5;
Benchmark.options.minTime = 0;

// run benchmarks
var Path = require('path');
var Promise = require('bluebird');
var fs = Promise.promisifyAll(require("fs"));
var dir = __dirname;

console.time('benchmark');
console.log("searching files...");
fs.readdirAsync(dir).map(function (file) {
    if (file.indexOf('.js') &lt; 0 || file.indexOf('benchmark-') !== 0) {
        return;
    }
github khalidsalomao / simple-query-string / spec / benchmarks.js View on Github external
/* jshint
eqeqeq: true, undef: true, unused: true, indent: 4, plusplus: false, curly: false, forin: true, trailing: true, white: true, sub:true,
browser: true, node: true, devel: true, mocha: true
*/
/* global require */

// benchmarks
var Benchmark = require('benchmark');
if (!Benchmark) return;

Benchmark.options.initCount = 2;
Benchmark.options.delay = 0;
Benchmark.options.maxTime = 1; // secs
Benchmark.options.minSamples = 5;
Benchmark.options.minTime = 0;

// run benchmarks
var Path = require('path');
var Promise = require('bluebird');
var fs = Promise.promisifyAll(require("fs"));
var dir = __dirname;

console.time('benchmark');
console.log("searching files...");
fs.readdirAsync(dir).map(function (file) {
    if (file.indexOf('.js') &lt; 0 || file.indexOf('benchmark-') !== 0) {
        return;
github apollographql / apollo-client / packages / apollo-client / benchmark / util.ts View on Github external
import Benchmark from 'benchmark';

// This file implements utilities around benchmark.js that make it
// easier to use for our benchmarking needs.

// Specifically, it provides `group` and `benchmark`, examples of which
// can be seen within the benchmarks.The functions allow you to manage scope and async
// code more easily than benchmark.js typically allows.
//
// `group` is meant to provide a way to execute code that sets up the scope variables for your
// benchmark. It is only run once before the benchmark, not on every call of the code to
// be benchmarked. The `benchmark` function is similar to the `it` function within mocha;
// it allows you to define a particular block of code to be benchmarked.

Benchmark.options.minSamples = 150;
export const bsuite = new Benchmark.Suite();
export type DoneFunction = () =&gt; void;

export interface DescriptionObject {
  name: string;
  [other: string]: any;
}

export type Nullable = T | undefined;
export type Description = DescriptionObject | string;
export type CycleFunction = (doneFn: DoneFunction) =&gt; void;
export type BenchmarkFunction = (
  description: Description,
  cycleFn: CycleFunction,
) =&gt; void;
export type GroupFunction = (done: DoneFunction) =&gt; void;
github mui-org / material-ui / packages / material-ui-benchmark / src / docs.js View on Github external
import Benchmark from 'benchmark';
import fs from 'fs';
import path from 'path';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import MarkdownElement from 'docs/src/modules/components/MarkdownElement';
import Markdown from 'docs/src/pages/getting-started/templates/blog/Markdown';
import { createStore } from 'redux';
import { Provider } from 'react-redux';

const suite = new Benchmark.Suite('core', {
  onError: event =&gt; {
    console.log(event.target.error);
  },
});
Benchmark.options.minSamples = 100;

const markdown = fs.readFileSync(
  path.join(__dirname, '../../../docs/src/pages/getting-started/templates/blog/blog-post.1.md'),
  'UTF-8',
);

const store = createStore(state =&gt; state, {
  options: {
    userLanguage: 'en',
  },
});

suite
  .add('Markdown', () =&gt; {
    ReactDOMServer.renderToString({markdown});
  })
github kb-dev / sanic.js / bench / index.js View on Github external
'use strict';

const BenchFileCreator = require('./benchFileCreator');
const Benchmark = require('benchmark');
const Classes = {
    Array: require('./array'),
    Object: require('./object'),
};

const SuiteOptions = {
    async: false
};

Benchmark.options.minSamples = 200;

const ALL = 'all';
const WRITE_FILE = 'writeFile';

let onlySpecificTest = false;
const testsToDo = {};
let fileWriter = null;

const writeFileArg = process.argv.some((arg) =&gt; arg === WRITE_FILE);

if (process.argv.length &gt; 2 &amp;&amp; !writeFileArg ||
    process.argv.length &gt; 3) {
    onlySpecificTest = true;

    for (let i = 2, iMax = process.argv.length; i &lt; iMax; i++) {
        const [className, methodName] = process.argv[i].split('.');
github calmm-js / partial.lenses / bench / bench.js View on Github external
const aEb = L.orElse('b', 'a')
const aEbEc = L.orElse(L.orElse('c', 'b'), 'a')
const abM = L.choice('a', 'b')
const abS = L.choices('a', 'b')
const abcM = L.choice('a', 'b', 'c')
const abcS = L.choices('a', 'b', 'c')

const Ident = {
  map: (xy, x) => xy(x),
  ap: (xy, x) => xy(x),
  of: x => x,
  chain: (xy, x) => xy(x)
}

const Benchmark = require('benchmark')
Benchmark.options.maxTime = Number(process.argv[2]) || Benchmark.options.maxTime

const pattern = new RegExp(process.argv[3] || '')

const dropped = [
  M ? '' : 'M',
  P ? '' : 'P',
  O ? '' : 'O',
  K ? '' : 'K',
  U ? '' : 'U',
  _get ? '' : '_get'
].filter(I.id)

R.forEach(
  bs => {
    if (bs.find(s => pattern.test(s))) {
      global.gc()
github kb-dev / sanic.js / bench / misc / loop.js View on Github external
'use strict';

const Benchmark = require('benchmark');
Benchmark.options.minSamples = 200;

let fileWriter = null;

if (process.argv.some((e) =&gt; e === "writeFile")) {
    const BenchFileCreator = require('../benchFileCreator');
    fileWriter = new BenchFileCreator();
    fileWriter.addInformations(Benchmark.options.minSamples);
    fileWriter.writeTableHeader(['Elements', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13']);
}

function computeNumber(nb) {
    if (nb &gt; 1000000){
        return `${Math.round(nb / 10000)/100}m`;
    } else if (nb &gt; 1000){
        return `${Math.round(nb / 10)/100}k`;
    } else {
        return `${Math.round(nb*100)/100}`;
    }
}

function simpleRecursiveIteration(array, i = 0){
    if (i &lt; array.length) {
        array[i] * array[i];
github Yomguithereal / mnemonist / benchmark / linked-list / benchmark.js View on Github external
var Benchmark = require('benchmark'),
    ClassicLinkedList = require('./classic.js'),
    ArrayNodeLinkedList = require('./array-node.js'),
    ClassNodeLinkedList = require('./class-node.js'),
    ObjectNullLinkedList = require('./object-null.js');

Benchmark.options.delay = 1;
Benchmark.options.initCount = 5;

var Suite = Benchmark.Suite;

var classic,
    arrayNode,
    classNode,
    objectNull;

function doTimes(Class, method) {
  var target = new Class();

  for (var i = 0; i &lt; 10000; i++)
    target[method](Math.random());

  target.clear();