How to use the benny.save function in benny

To help you get started, we’ve selected a few benny 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 caderek / benny / examples / custom-logging-replace.js View on Github external
}),

  add('Add two numbers', () => {
    1 + 1 + 1
  }),

  cycle((result, summary) => {
    // This will be replaced in-place by each cycle:
    return `Progress: ${
      summary.results.filter((result) => result.completed).length
    } / ${summary.results.length}`
  }),
  complete((summary) => {
    console.log(`Finished ${summary.results.length} benchmarks!`)
  }),
  save({
    file: 'custom-logging-replace',
    folder: path.join(__dirname, 'results'),
  }),
)
github caderek / benny / examples / async-madness.js View on Github external
return async () => {
      await delay(0.5) // Still 2 ops/s
    }
  }),

  add('Sync benchmark with some async setup', async () => {
    await delay(2) // Setup can be async, it will not affect the results

    return () => {
      1 + 1 // High ops, not affected by slow, async setup
    }
  }),

  cycle(),
  complete(),
  save({ file: 'async-madness', folder: path.join(__dirname, 'results') }),
)
github caderek / benny / examples / allEqual.js View on Github external
)

suite(
  'All equal - million elements',

  add('Imperative', () => {
    allEqualImperative(inputMillion)
  }),

  add('Declarative', () => {
    allEqualEveryDeclarative(inputMillion)
  }),

  cycle(),
  complete(),
  save({ file: 'all-equal-million', folder: path.join(__dirname, 'results') }),
  save({
    file: 'all-equal-million',
    folder: path.join(__dirname, 'results'),
    format: 'chart.html',
  }),
)
github caderek / benny / examples / reduce.js View on Github external
add('@arrows/array', () => {
    A.reduce((a, b) => a + b, 0)(input)
  }),

  add('@arrows/array first', () => {
    A.reduce.first((a, b) => a + b)(input)
  }),

  add('rambda', () => {
    RB.reduce((a, b) => a + b, 0)(input)
  }),

  cycle(),
  complete(),
  save({ file: 'reduce' }),
  save({ file: 'reduce', format: 'chart.html' }),
)
github caderek / benny / examples / reduce.js View on Github external
add('@arrows/array', () => {
    A.reduce((a, b) => a + b, 0)(input)
  }),

  add('@arrows/array first', () => {
    A.reduce.first((a, b) => a + b)(input)
  }),

  add('rambda', () => {
    RB.reduce((a, b) => a + b, 0)(input)
  }),

  cycle(),
  complete(),
  save({ file: 'reduce' }),
  save({ file: 'reduce', format: 'chart.html' }),
)
github caderek / arrows / packages / multimethod / benchmark / suites / multimethod-execution.ts View on Github external
),

  add(
    'Execute multimethod with a thousand complex caseVal methods - last matching',
    () => {
      const methods = createNMethodsWithComplexCaseVal(1000)
      const fn = multi(...methods)

      return () =>
        fn({ foo: 1000, bar: { baz: 1000, bat: [1000, 1000, 1000] } })
    },
  ),

  cycle(),
  complete(),
  save({ file: `${version}-multimethod-execution`, version }),
)
github caderek / benny / examples / allEqual.js View on Github external
suite(
  'All equal - million elements',

  add('Imperative', () => {
    allEqualImperative(inputMillion)
  }),

  add('Declarative', () => {
    allEqualEveryDeclarative(inputMillion)
  }),

  cycle(),
  complete(),
  save({ file: 'all-equal-million', folder: path.join(__dirname, 'results') }),
  save({
    file: 'all-equal-million',
    folder: path.join(__dirname, 'results'),
    format: 'chart.html',
  }),
)
github caderek / benny / examples / immutable-transform.js View on Github external
}
  }),

  add('Clone - lodash', () => {
    const data = initializeTestData()

    return () => {
      const newData = _.cloneDeep(data)
      newData.foo.bar.baz = 'yo'
      newData.foo.bar.bat[1] = 7
    }
  }),

  cycle(),
  complete(),
  save({ file: 'immutable-trans', folder: path.join(__dirname, 'results') }),
  save({
    file: 'immutable-trans',
    folder: path.join(__dirname, 'results'),
    format: 'chart.html',
  }),
)
github caderek / benny / examples / composition.js View on Github external
A.map(triple),
      A.reduce(sum, 0),
    )(initialArr)
  }),

  add('lodash/fp', () => {
    _.pipe(
      _.filter(isOdd),
      _.map(triple),
      _.reduce(sum, 0),
    )(initialArr)
  }),

  cycle(),
  complete(),
  save({ file: 'composition', folder: path.join(__dirname, 'results') }),
)
github caderek / benny / examples / immutable-transform.js View on Github external
}),

  add('Clone - lodash', () => {
    const data = initializeTestData()

    return () => {
      const newData = _.cloneDeep(data)
      newData.foo.bar.baz = 'yo'
      newData.foo.bar.bat[1] = 7
    }
  }),

  cycle(),
  complete(),
  save({ file: 'immutable-trans', folder: path.join(__dirname, 'results') }),
  save({
    file: 'immutable-trans',
    folder: path.join(__dirname, 'results'),
    format: 'chart.html',
  }),
)

benny

A dead simple benchmarking framework

ISC
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis