Skip to content

Commit

Permalink
updated: bench setup to free the gc after each cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Aug 9, 2024
1 parent 995da59 commit 9ef48f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions benchmarks/index.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-var, no-console */
/* eslint-disable no-console */
require('jsdom-global')()
require('../polyfills/range.cjs')

Expand All @@ -23,10 +23,11 @@ Object.entries(benchmarks).forEach(([key, bench]) => {

suite
.on('cycle', function (event) {
var mem = (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)
const mem = (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)
console.log(String(event.target), `Memory usage: ${mem} MiB`)
global.gc()
})
.on('error', function (e) {
console.log(e.target.error)
})
.run({ async: false })
.run()
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"build": "rollup -c",
"pretest": "npm run build",
"postest": "npm run cov-html",
"bench": "node benchmarks/index.cjs",
"bench": "node --expose-gc benchmarks/index.cjs",
"test": "npm run lint && c8 mocha -r test/index.js 'test/**/*.spec.js' && npm run test-typing",
"test-typing": "tsc -p test",
"test-debug": "mocha --inspect --inspect-brk -r test/index.js 'test/**/*.spec.js'",
Expand Down

0 comments on commit 9ef48f8

Please sign in to comment.