Skip to content

Commit

Permalink
outputting results to markdown tables
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreardon committed Oct 19, 2021
1 parent 3e75de0 commit ce0c6bf
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 44 deletions.
62 changes: 31 additions & 31 deletions benchmarks/library-comparison.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,38 @@ import ora from 'ora';
import moize from 'moize';
import memoizee from 'memoizee';
import { green, bold } from 'nanocolors';
import Table from 'cli-table';
import { markdownTable } from 'markdown-table';

const libraries = [
{
name: 'no memoization',
memoize: (fn) => fn,
},
{
name: 'memoize-one',
memoize: memoizeOne,
},
{
name: 'lodash.memoize',
memoize: lodash,
},
{
name: 'fast-memoize',
memoize: fastMemoize,
},
{
name: 'moize',
memoize: moize,
},
{
name: 'memoizee',
memoize: memoizee,
},
{
name: 'mem (JSON.stringify strategy)',
// mem supports lots of strategies, choosing a 'fair' one for lots of operations
memoize: (fn) => mem(fn, { cacheKey: JSON.stringify }),
},
// {
// name: 'memoize-one',
// memoize: memoizeOne,
// },
// {
// name: 'lodash.memoize',
// memoize: lodash,
// },
// {
// name: 'fast-memoize',
// memoize: fastMemoize,
// },
// {
// name: 'moize',
// memoize: moize,
// },
// {
// name: 'memoizee',
// memoize: memoizee,
// },
// {
// name: 'mem (JSON.stringify strategy)',
// // mem supports lots of strategies, choosing a 'fair' one for lots of operations
// memoize: (fn) => mem(fn, { cacheKey: JSON.stringify }),
// },
];

function slowFn() {
Expand Down Expand Up @@ -136,11 +136,11 @@ scenarios.forEach((scenario) => {
return [index + 1, benchmark.name, Math.round(benchmark.hz).toLocaleString()];
});

const table = new Table({
head: ['Position', 'Library', 'Operations per second'],
});
table.push(...rows);
console.log(table.toString());
console.log('Markdown:\n');
console.log(`**${scenario.name}**\n`);
const table = markdownTable([['Position', 'Library', 'Operations per second'], ...rows]);

console.log(table);
});
suite.run();
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "memoize-one",
"version": "6.0.0-beta.1",
"type": "module",
"description": "A memoization library which only remembers the latest invocation",
"main": "dist/memoize-one.cjs.js",
"types": "dist/memoize-one.d.ts",
Expand Down Expand Up @@ -51,7 +52,6 @@
"@typescript-eslint/eslint-plugin": "^4.31.2",
"@typescript-eslint/parser": "^4.31.2",
"benchmark": "^2.1.4",
"cli-table": "^0.3.6",
"cross-env": "^7.0.3",
"eslint": "7.32.0",
"eslint-config-prettier": "^8.3.0",
Expand All @@ -62,6 +62,7 @@
"jest": "^27.2.2",
"lodash.isequal": "^4.5.0",
"lodash.memoize": "^4.1.2",
"markdown-table": "^3.0.1",
"mem": "^9.0.1",
"memoizee": "^0.4.15",
"moize": "^6.1.0",
Expand Down
17 changes: 5 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1696,13 +1696,6 @@ cli-spinners@^2.6.0:
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.6.0.tgz#36c7dc98fb6a9a76bd6238ec3f77e2425627e939"
integrity sha512-t+4/y50K/+4xcCRosKkA7W4gTr1MySvLV0q+PxmG7FJ5g+66ChKurYjxBCjHggHH3HA5Hh9cy+lcUGWDqVH+4Q==

cli-table@^0.3.6:
version "0.3.6"
resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.6.tgz#e9d6aa859c7fe636981fd3787378c2a20bce92fc"
integrity sha512-ZkNZbnZjKERTY5NwC2SeMeLeifSPq/pubeRoTpdr3WchLlnZg6hEgvHkK5zL7KNFdd9PmHN8lxrENUwI3cE8vQ==
dependencies:
colors "1.0.3"

cliui@^7.0.2:
version "7.0.4"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
Expand Down Expand Up @@ -1764,11 +1757,6 @@ colord@^2.0.1, colord@^2.6:
resolved "https://registry.yarnpkg.com/colord/-/colord-2.8.0.tgz#64fb7aa03de7652b5a39eee50271a104c2783b12"
integrity sha512-kNkVV4KFta3TYQv0bzs4xNwLaeag261pxgzGQSh4cQ1rEhYjcTJfFRP0SDlbhLONg0eSoLzrDd79PosjbltufA==

colors@1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
integrity sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=

combined-stream@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
Expand Down Expand Up @@ -4115,6 +4103,11 @@ map-visit@^1.0.0:
dependencies:
object-visit "^1.0.0"

markdown-table@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-3.0.1.tgz#88c48957aaf2a8014ccb2ba026776a1d736fe3dc"
integrity sha512-CBbaYXKSGnE1uLRpKA1SWgIRb2PQrpkllNWpZtZe6VojOJ4ysqiq7/2glYcmKsOYN09QgH/HEBX5hIshAeiK6A==

md5.js@^1.3.4:
version "1.3.5"
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
Expand Down

0 comments on commit ce0c6bf

Please sign in to comment.