Skip to content
Myr

Move benchmark to test dir

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Andrey Sitnik · committed by Andrey Sitnik · parent 22e0279 · Browse files · 3 files+34 added−36 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+34 added−36 removed

  • tests:+34 added−0 removed
  • other:+0 added−36 removed

3 files+34 added−36 removed

added:test/benchmark+34 added
1#!/usr/bin/env node2var benchmark = require('benchmark')3var shortid = require('shortid')4var uuid4 = require('uuid/v4')5var chalk = require('chalk')67var generate = require('../generate')8var nanoid = require('../')910var suite = new benchmark.Suite()1112function formatNumber (number) {13 return String(number).replace(/\d\d\d$/, ',$&')14}1516suite17 .add('nanoid', function () {18 nanoid()19 })20 .add('nanoid/generate', function () {21 generate('1234567890abcdef-', 10)22 })23 .add('uuid/v4', function () {24 uuid4()25 })26 .add('shortid', function () {27 shortid()28 })29 .on('cycle', function (event) {30 var name = event.target.name.padEnd('nanoid/generate'.length)31 var hz = formatNumber(event.target.hz.toFixed(0)).padStart(7)32 process.stdout.write(name + ' ' + chalk.bold(hz) + ' ops/sec \n')33 })34 .run()
modified:.npmignore-2 removed
15 unmodified lines
16.jsdocrc17jest.config.js18docs/19img/2021benchmark
deleted:benchmark-34 removed
1#!/usr/bin/env node2var benchmark = require('benchmark')3var shortid = require('shortid')4var uuid4 = require('uuid/v4')5var chalk = require('chalk')67var generate = require('./generate')8var nanoid = require('./')910var suite = new benchmark.Suite()1112function formatNumber (number) {13 return String(number).replace(/\d\d\d$/, ',$&')14}1516suite17 .add('nanoid', function () {18 nanoid()19 })20 .add('nanoid/generate', function () {21 generate('1234567890abcdef-', 10)22 })23 .add('uuid/v4', function () {24 uuid4()25 })26 .add('shortid', function () {27 shortid()28 })29 .on('cycle', function (event) {30 var name = event.target.name.padEnd('nanoid/generate'.length)31 var hz = formatNumber(event.target.hz.toFixed(0)).padStart(7)32 process.stdout.write(name + ' ' + chalk.bold(hz) + ' ops/sec \n')33 })34 .run()