Skip to content

Commit

Permalink
chore(bench): rename foid -> uid
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Mar 13, 2020
1 parent 60644dd commit fb66411
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions bench/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ const Hash = require('hashids/cjs');
const { Suite } = require('benchmark');
const nanoid2 = require('nanoid/non-secure');
const nanoid = require('nanoid');
const foid = require('../dist');
const uid = require('../dist');

const size_11 = {
'hashids/fixed': new Hash('', 11),
'nanoid/non-secure': nanoid2.bind(nanoid2, 11),
'nanoid': nanoid.bind(nanoid, 11),
'foid': foid.bind(foid, 11),
'uid': uid.bind(uid, 11),
};

const size_16 = {
'hashids/fixed': new Hash('', 16),
'nanoid/non-secure': nanoid2.bind(nanoid2, 16),
'nanoid': nanoid.bind(nanoid, 16),
'foid': foid.bind(foid, 16),
'uid': uid.bind(uid, 16),
};

const size_25 = {
'cuid': require('cuid'),
'hashids/fixed': new Hash('', 25),
'nanoid/non-secure': nanoid2.bind(nanoid2, 25),
'nanoid': nanoid.bind(nanoid, 25),
'foid': foid.bind(foid, 25),
'uid': uid.bind(uid, 25),
};

const size_36 = {
Expand All @@ -35,7 +35,7 @@ const size_36 = {
'@lukeed/uuid': require('@lukeed/uuid'),
'nanoid/non-secure': nanoid2.bind(nanoid2, 36),
'nanoid': nanoid.bind(nanoid, 36),
'foid': foid.bind(foid, 36),
'uid': uid.bind(uid, 36),
};

function pad(str) {
Expand Down
4 changes: 2 additions & 2 deletions test/collisions/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const foid = require('../../dist');
const uid = require('../../dist');

// $ node test/collisions 16 1e7
const [len=8, cycles] = process.argv.slice(2);
Expand All @@ -10,7 +10,7 @@ console.log('~> hash length:', len);
let sentry = new Set();
let i=0, tmp, duplicates=0;
for (; i < total; i++) {
tmp = foid(len);
tmp = uid(+len);
if (sentry.has(tmp)) {
duplicates++;
} else {
Expand Down

0 comments on commit fb66411

Please sign in to comment.