From b40278fd516319b9817dbfe57ce5800ae5eb2d35 Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Mon, 20 May 2024 21:31:59 +1200 Subject: [PATCH] chore: update benchmarks --- benchmark/package.json | 18 +- benchmark/pnpm-lock.yaml | 501 ++++++++++++++++++++++++++------------- benchmark/run.ts | 114 +++++---- package.json | 2 +- 4 files changed, 416 insertions(+), 219 deletions(-) diff --git a/benchmark/package.json b/benchmark/package.json index ff7e19f3..38334f31 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -8,20 +8,20 @@ "email": "rebecca.stevens@outlook.co.nz" }, "scripts": { - "prebenchmark": "pnpm install; pnpm link deepmerge-ts", - "benchmark": "ts-node run.ts" + "benchmark": "tsx run.ts" }, + "type": "module", "dependencies": { - "@types/benchmark": "^2.1.1", - "benchmark": "^2.1.4", - "deepmerge": "^4.2.2", + "deepmerge": "^4.3.1", + "deepmerge-ts": "link:..", "lodash": "^4.17.21", - "merge-anything": "^5.0.0", + "merge-anything": "^5.1.7", "object-accumulator": "^0.0.5" }, "devDependencies": { - "@types/node": "18.15.11", - "ts-node": "10.9.1", - "typescript": "5.0.4" + "@types/node": "20.12.12", + "tinybench": "2.8.0", + "tsx": "4.10.5", + "typescript": "5.4.5" } } diff --git a/benchmark/pnpm-lock.yaml b/benchmark/pnpm-lock.yaml index faf906cd..fd5eb028 100644 --- a/benchmark/pnpm-lock.yaml +++ b/benchmark/pnpm-lock.yaml @@ -1,191 +1,366 @@ -lockfileVersion: '6.0' - -dependencies: - '@types/benchmark': - specifier: ^2.1.1 - version: 2.1.2 - benchmark: - specifier: ^2.1.4 - version: 2.1.4 - deepmerge: - specifier: ^4.2.2 - version: 4.3.0 - lodash: - specifier: ^4.17.21 - version: 4.17.21 - merge-anything: - specifier: ^5.0.0 - version: 5.1.4 - object-accumulator: - specifier: ^0.0.5 - version: 0.0.5 - -devDependencies: - '@types/node': - specifier: 18.15.11 - version: 18.15.11 - ts-node: - specifier: 10.9.1 - version: 10.9.1(@types/node@18.15.11)(typescript@5.0.4) - typescript: - specifier: 5.0.4 - version: 5.0.4 +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + deepmerge: + specifier: ^4.3.1 + version: 4.3.1 + deepmerge-ts: + specifier: link:.. + version: link:.. + lodash: + specifier: ^4.17.21 + version: 4.17.21 + merge-anything: + specifier: ^5.1.7 + version: 5.1.7 + object-accumulator: + specifier: ^0.0.5 + version: 0.0.5 + devDependencies: + '@types/node': + specifier: 20.12.12 + version: 20.12.12 + tinybench: + specifier: 2.8.0 + version: 2.8.0 + tsx: + specifier: 4.10.5 + version: 4.10.5 + typescript: + specifier: 5.4.5 + version: 5.4.5 packages: - /@cspotcode/source-map-support@0.8.1: - resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} + '@esbuild/aix-ppc64@0.20.2': + resolution: {integrity: sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==} engines: {node: '>=12'} - dependencies: - '@jridgewell/trace-mapping': 0.3.9 - dev: true + cpu: [ppc64] + os: [aix] - /@jridgewell/resolve-uri@3.1.0: - resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==} - engines: {node: '>=6.0.0'} - dev: true + '@esbuild/android-arm64@0.20.2': + resolution: {integrity: sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] - /@jridgewell/sourcemap-codec@1.4.14: - resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} - dev: true + '@esbuild/android-arm@0.20.2': + resolution: {integrity: sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] - /@jridgewell/trace-mapping@0.3.9: - resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} - dependencies: - '@jridgewell/resolve-uri': 3.1.0 - '@jridgewell/sourcemap-codec': 1.4.14 - dev: true - - /@tsconfig/node10@1.0.9: - resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==} - dev: true - - /@tsconfig/node12@1.0.11: - resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} - dev: true - - /@tsconfig/node14@1.0.3: - resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} - dev: true - - /@tsconfig/node16@1.0.3: - resolution: {integrity: sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==} - dev: true - - /@types/benchmark@2.1.2: - resolution: {integrity: sha512-EDKtLYNMKrig22jEvhXq8TBFyFgVNSPmDF2b9UzJ7+eylPqdZVo17PCUMkn1jP6/1A/0u78VqYC6VrX6b8pDWA==} - dev: false - - /@types/node@18.15.11: - resolution: {integrity: sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==} - dev: true - - /acorn-walk@8.2.0: - resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==} - engines: {node: '>=0.4.0'} - dev: true - - /acorn@8.8.2: - resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} - engines: {node: '>=0.4.0'} - hasBin: true - dev: true + '@esbuild/android-x64@0.20.2': + resolution: {integrity: sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] - /arg@4.1.3: - resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} - dev: true + '@esbuild/darwin-arm64@0.20.2': + resolution: {integrity: sha512-4J6IRT+10J3aJH3l1yzEg9y3wkTDgDk7TSDFX+wKFiWjqWp/iCfLIYzGyasx9l0SAFPT1HwSCR+0w/h1ES/MjA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] - /benchmark@2.1.4: - resolution: {integrity: sha512-l9MlfN4M1K/H2fbhfMy3B7vJd6AGKJVQn2h6Sg/Yx+KckoUA7ewS5Vv6TjSq18ooE1kS9hhAlQRH3AkXIh/aOQ==} - dependencies: - lodash: 4.17.21 - platform: 1.3.6 - dev: false + '@esbuild/darwin-x64@0.20.2': + resolution: {integrity: sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + + '@esbuild/freebsd-arm64@0.20.2': + resolution: {integrity: sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.20.2': + resolution: {integrity: sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + + '@esbuild/linux-arm64@0.20.2': + resolution: {integrity: sha512-9pb6rBjGvTFNira2FLIWqDk/uaf42sSyLE8j1rnUpuzsODBq7FvpwHYZxQ/It/8b+QOS1RYfqgGFNLRI+qlq2A==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm@0.20.2': + resolution: {integrity: sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-ia32@0.20.2': + resolution: {integrity: sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-loong64@0.20.2': + resolution: {integrity: sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] - /create-require@1.1.1: - resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} - dev: true + '@esbuild/linux-mips64el@0.20.2': + resolution: {integrity: sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-ppc64@0.20.2': + resolution: {integrity: sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-riscv64@0.20.2': + resolution: {integrity: sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-s390x@0.20.2': + resolution: {integrity: sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-x64@0.20.2': + resolution: {integrity: sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + + '@esbuild/netbsd-x64@0.20.2': + resolution: {integrity: sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + + '@esbuild/openbsd-x64@0.20.2': + resolution: {integrity: sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] - /deepmerge@4.3.0: - resolution: {integrity: sha512-z2wJZXrmeHdvYJp/Ux55wIjqo81G5Bp4c+oELTW+7ar6SogWHajt5a9gO3s3IDaGSAXjDk0vlQKN3rms8ab3og==} + '@esbuild/sunos-x64@0.20.2': + resolution: {integrity: sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + + '@esbuild/win32-arm64@0.20.2': + resolution: {integrity: sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-ia32@0.20.2': + resolution: {integrity: sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-x64@0.20.2': + resolution: {integrity: sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + + '@types/node@20.12.12': + resolution: {integrity: sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==} + + deepmerge@4.3.1: + resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} - dev: false - /diff@4.0.2: - resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} - engines: {node: '>=0.3.1'} - dev: true + esbuild@0.20.2: + resolution: {integrity: sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==} + engines: {node: '>=12'} + hasBin: true + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] - /is-what@4.1.8: + get-tsconfig@4.7.5: + resolution: {integrity: sha512-ZCuZCnlqNzjb4QprAzXKdpp/gh6KTxSJuw3IBsPnV/7fV4NxC9ckB+vPTt8w7fJA0TaSD7c55BR47JD6MEDyDw==} + + is-what@4.1.8: resolution: {integrity: sha512-yq8gMao5upkPoGEU9LsB2P+K3Kt8Q3fQFCGyNCWOAnJAMzEXVV9drYb0TXr42TTliLLhKIBvulgAXgtLLnwzGA==} engines: {node: '>=12.13'} - dev: false - /lodash@4.17.21: + lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: false - - /make-error@1.3.6: - resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} - dev: true - /merge-anything@5.1.4: - resolution: {integrity: sha512-7PWKwGOs5WWcpw+/OvbiFiAvEP6bv/QHiicigpqMGKIqPPAtGhBLR8LFJW+Zu6m9TXiR/a8+AiPlGG0ko1ruoQ==} + merge-anything@5.1.7: + resolution: {integrity: sha512-eRtbOb1N5iyH0tkQDAoQ4Ipsp/5qSR79Dzrz8hEPxRX10RWWR/iQXdoKmBSRCThY1Fh5EhISDtpSc93fpxUniQ==} engines: {node: '>=12.13'} - dependencies: - is-what: 4.1.8 - dev: false - /object-accumulator@0.0.5: + object-accumulator@0.0.5: resolution: {integrity: sha512-UKkFOfHwuL+nHRSVRjTHv99h8gjeW/zHfgtfaaRM4WLbGvJbutlujegjN7YsL1EsJlB7Q1kGI12P93+yiY4snA==} - dev: false - /platform@1.3.6: - resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==} - dev: false + resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} - /ts-node@10.9.1(@types/node@18.15.11)(typescript@5.0.4): - resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} + tinybench@2.8.0: + resolution: {integrity: sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw==} + + tsx@4.10.5: + resolution: {integrity: sha512-twDSbf7Gtea4I2copqovUiNTEDrT8XNFXsuHpfGbdpW/z9ZW4fTghzzhAG0WfrCuJmJiOEY1nLIjq4u3oujRWQ==} + engines: {node: '>=18.0.0'} hasBin: true - peerDependencies: - '@swc/core': '>=1.2.50' - '@swc/wasm': '>=1.2.50' - '@types/node': '*' - typescript: '>=2.7' - peerDependenciesMeta: - '@swc/core': - optional: true - '@swc/wasm': - optional: true - dependencies: - '@cspotcode/source-map-support': 0.8.1 - '@tsconfig/node10': 1.0.9 - '@tsconfig/node12': 1.0.11 - '@tsconfig/node14': 1.0.3 - '@tsconfig/node16': 1.0.3 - '@types/node': 18.15.11 - acorn: 8.8.2 - acorn-walk: 8.2.0 - arg: 4.1.3 - create-require: 1.1.1 - diff: 4.0.2 - make-error: 1.3.6 - typescript: 5.0.4 - v8-compile-cache-lib: 3.0.1 - yn: 3.1.1 - dev: true - - /typescript@5.0.4: - resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} - engines: {node: '>=12.20'} + + typescript@5.4.5: + resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} + engines: {node: '>=14.17'} hasBin: true - dev: true - /v8-compile-cache-lib@3.0.1: - resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} - dev: true + undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + +snapshots: + + '@esbuild/aix-ppc64@0.20.2': + optional: true + + '@esbuild/android-arm64@0.20.2': + optional: true + + '@esbuild/android-arm@0.20.2': + optional: true + + '@esbuild/android-x64@0.20.2': + optional: true + + '@esbuild/darwin-arm64@0.20.2': + optional: true + + '@esbuild/darwin-x64@0.20.2': + optional: true + + '@esbuild/freebsd-arm64@0.20.2': + optional: true + + '@esbuild/freebsd-x64@0.20.2': + optional: true + + '@esbuild/linux-arm64@0.20.2': + optional: true + + '@esbuild/linux-arm@0.20.2': + optional: true + + '@esbuild/linux-ia32@0.20.2': + optional: true + + '@esbuild/linux-loong64@0.20.2': + optional: true + + '@esbuild/linux-mips64el@0.20.2': + optional: true + + '@esbuild/linux-ppc64@0.20.2': + optional: true + + '@esbuild/linux-riscv64@0.20.2': + optional: true + + '@esbuild/linux-s390x@0.20.2': + optional: true + + '@esbuild/linux-x64@0.20.2': + optional: true + + '@esbuild/netbsd-x64@0.20.2': + optional: true + + '@esbuild/openbsd-x64@0.20.2': + optional: true + + '@esbuild/sunos-x64@0.20.2': + optional: true + + '@esbuild/win32-arm64@0.20.2': + optional: true + + '@esbuild/win32-ia32@0.20.2': + optional: true + + '@esbuild/win32-x64@0.20.2': + optional: true + + '@types/node@20.12.12': + dependencies: + undici-types: 5.26.5 + + deepmerge@4.3.1: {} + + esbuild@0.20.2: + optionalDependencies: + '@esbuild/aix-ppc64': 0.20.2 + '@esbuild/android-arm': 0.20.2 + '@esbuild/android-arm64': 0.20.2 + '@esbuild/android-x64': 0.20.2 + '@esbuild/darwin-arm64': 0.20.2 + '@esbuild/darwin-x64': 0.20.2 + '@esbuild/freebsd-arm64': 0.20.2 + '@esbuild/freebsd-x64': 0.20.2 + '@esbuild/linux-arm': 0.20.2 + '@esbuild/linux-arm64': 0.20.2 + '@esbuild/linux-ia32': 0.20.2 + '@esbuild/linux-loong64': 0.20.2 + '@esbuild/linux-mips64el': 0.20.2 + '@esbuild/linux-ppc64': 0.20.2 + '@esbuild/linux-riscv64': 0.20.2 + '@esbuild/linux-s390x': 0.20.2 + '@esbuild/linux-x64': 0.20.2 + '@esbuild/netbsd-x64': 0.20.2 + '@esbuild/openbsd-x64': 0.20.2 + '@esbuild/sunos-x64': 0.20.2 + '@esbuild/win32-arm64': 0.20.2 + '@esbuild/win32-ia32': 0.20.2 + '@esbuild/win32-x64': 0.20.2 + + fsevents@2.3.3: + optional: true + + get-tsconfig@4.7.5: + dependencies: + resolve-pkg-maps: 1.0.0 + + is-what@4.1.8: {} + + lodash@4.17.21: {} + + merge-anything@5.1.7: + dependencies: + is-what: 4.1.8 + + object-accumulator@0.0.5: {} + + resolve-pkg-maps@1.0.0: {} + + tinybench@2.8.0: {} + + tsx@4.10.5: + dependencies: + esbuild: 0.20.2 + get-tsconfig: 4.7.5 + optionalDependencies: + fsevents: 2.3.3 + + typescript@5.4.5: {} - /yn@3.1.1: - resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} - engines: {node: '>=6'} - dev: true + undici-types@5.26.5: {} diff --git a/benchmark/run.ts b/benchmark/run.ts index 700403ae..5b6a94e2 100644 --- a/benchmark/run.ts +++ b/benchmark/run.ts @@ -1,34 +1,51 @@ -import { promises as fs, constants as fsConstants } from "node:fs"; +/* eslint-disable no-await-in-loop */ +import * as fs from "node:fs"; +import * as fsp from "node:fs/promises"; import * as path from "node:path"; +import { dirname } from "node:path"; +import { fileURLToPath } from "node:url"; -import Benchmark from "benchmark"; -import { all as deepmerge } from "deepmerge"; +import deepmerge from "deepmerge"; import { deepmerge as deepmergeTs } from "deepmerge-ts"; -import { merge as lodashMerge } from "lodash"; +import lodash from "lodash"; import { merge as mergeAnything } from "merge-anything"; import { Accumulator as ObjectAccumulator } from "object-accumulator"; - -const benchmarkDataFile = path.join(__dirname, "data.json"); - -const benchmarkDataSets: any[][] = await fs - .access(benchmarkDataFile, fsConstants.R_OK) +import { Bench } from "tinybench"; + +const benchmarkDataFile = path.join( + dirname(fileURLToPath(import.meta.url)), + "data.json", +); + +const benchmarkDataSets: Array<{ + name: string; + data: object[]; +}> = await fsp + .access(benchmarkDataFile, fs.constants.R_OK) .then(async () => { console.log("Loading benchmark data file."); - const data = await fs.readFile(benchmarkDataFile, { encoding: "utf8" }); + const data = await fsp.readFile(benchmarkDataFile, { encoding: "utf8" }); return JSON.parse(data); }) .catch(async (error: unknown) => { - if (error?.code !== "ENOENT") { + if ( + !(error instanceof Error) || + !("code" in error) || + error.code !== "ENOENT" + ) { throw error; } - console.log("No benchmark data file found. Generating benchmark data."); + console.log( + "No benchmark data file found. Generating random data for benchmarking against.", + ); const data = [ - generateBenchmarkDataArray(2, 4, 15), - generateBenchmarkDataArray(100, 10, 4), + generateBenchmarkDataSet("tall", 2, 3, 16), + generateBenchmarkDataSet("wide", 100, 12, 4), + generateBenchmarkDataSet("mid", 10, 6, 8), ]; - await fs.writeFile(benchmarkDataFile, JSON.stringify(data), { + await fsp.writeFile(benchmarkDataFile, JSON.stringify(data), { encoding: "utf8", }); @@ -36,22 +53,26 @@ const benchmarkDataSets: any[][] = await fs }); for (let m_i = 0; m_i < benchmarkDataSets.length; m_i++) { - const benchmarkData = benchmarkDataSets[m_i]; - const suite = new Benchmark.Suite(); + const { name: benchmarkName, data: benchmarkData } = benchmarkDataSets[m_i]; + const bench = new Bench({ + time: 10_000, + iterations: 1, + warmupTime: 1000, + warmupIterations: 1, + }); console.log( - `\nRunning benchmarks for data set ${m_i + 1} of ${ + `\nRunning benchmarks for data set "${benchmarkName}" (${m_i + 1} of ${ benchmarkDataSets.length - }:\n`, + }):\n`, ); - // add tests - suite + bench .add("deepmerge-ts", () => { deepmergeTs(...benchmarkData); }) .add("deepmerge", () => { - deepmerge(benchmarkData); + deepmerge.all(benchmarkData); }) .add("merge-anything", () => { (mergeAnything as any)(...benchmarkData); @@ -59,39 +80,40 @@ for (let m_i = 0; m_i < benchmarkDataSets.length; m_i++) { .add("object-accumulator", () => { ObjectAccumulator.from(benchmarkData).merge(); }) - .add("lowdash merge", () => { - lodashMerge({}, benchmarkData); - }) - .on("cycle", (event: any) => { - console.log(String(event.target)); - }) - // eslint-disable-next-line func-names - .on("complete", function () { - // @ts-expect-error When need to access the "this" value - // eslint-disable-next-line unicorn/no-this-assignment, ts/no-this-alias - const results = this; - - console.log( - `\nFastest is ${results.filter("fastest").map("name")} for data set ${ - m_i + 1 - } of ${benchmarkDataSets.length}`, - ); - }) - .run({ async: false }); + .add("lodash merge", () => { + lodash.merge({}, benchmarkData); + }); + + await bench.warmup(); + await bench.run(); + + console.table(bench.table()); } -function generateBenchmarkDataArray(items, maxProperties, maxDepth) { +function generateBenchmarkDataSet( + name: string, + items: number, + maxProperties: number, + maxDepth: number, +) { const data: object[] = []; for (let m_i = 0; m_i < items; m_i++) { data.push(generateBenchmarkDataItem(maxProperties, maxDepth)); } - return data; + return { + name, + data, + }; } -function generateBenchmarkDataItem(maxProperties, depth, currentDepth = 0) { - const obj = {}; +function generateBenchmarkDataItem( + maxProperties: number, + depth: number, + currentDepth = 0, +) { + const obj: object = {}; const properties = Math.floor(maxProperties * Math.random()) + 1; @@ -113,7 +135,7 @@ function generateBenchmarkDataItem(maxProperties, depth, currentDepth = 0) { return obj; } -function shuffle(array) { +function shuffle(array: T[]) { let m_currentIndex = array.length; let m_randomIndex; diff --git a/package.json b/package.json index f9276c20..09d0042a 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "README.md" ], "scripts": { - "benchmark": "pnpm run build && pnpm run link & cd benchmark && pnpm run benchmark; cd ..", + "benchmark": "pnpm run build && cd benchmark && pnpm run benchmark; cd ..", "build": "rimraf build && pnpm run build:node && pnpm run build:deno && rimraf build && if-env-defined CI || pnpm run build:assume-unchanged", "build:assume-unchanged": "cd dist; git update-index --assume-unchanged $(git ls-files | tr '\n' ' '); cd ..", "build:deno": "rimraf dist/deno && tsc -p tsconfig.build.deno.json && denoify",