Test: update bench deps, use physical CPU core count

This commit is contained in:
Lovell Fuller 2023-09-26 21:16:46 +01:00
parent aabbe1fa08
commit 70a3067963
2 changed files with 7 additions and 8 deletions

View File

@ -17,11 +17,8 @@
"jimp": "0.22.10" "jimp": "0.22.10"
}, },
"optionalDependencies": { "optionalDependencies": {
"@tensorflow/tfjs-node": "4.9.0", "@tensorflow/tfjs-node": "4.11.0",
"mapnik": "4.5.9" "mapnik": "4.5.9"
}, },
"license": "Apache-2.0", "license": "Apache-2.0"
"engines": {
"node": "16"
}
} }

View File

@ -5,7 +5,7 @@
const os = require('os'); const os = require('os');
const fs = require('fs'); const fs = require('fs');
const { exec } = require('child_process'); const { exec, execSync } = require('child_process');
const async = require('async'); const async = require('async');
const Benchmark = require('benchmark'); const Benchmark = require('benchmark');
@ -40,8 +40,10 @@ const heightPng = 540;
// Disable libvips cache to ensure tests are as fair as they can be // Disable libvips cache to ensure tests are as fair as they can be
sharp.cache(false); sharp.cache(false);
// Spawn one thread per CPU // Spawn one thread per physical CPU core
sharp.concurrency(os.cpus().length); const physicalCores = Number(execSync('lscpu -p | egrep -v "^#" | sort -u -t, -k 2,4 | wc -l', { encoding: 'utf-8' }).trim());
console.log(`Detected ${physicalCores} physical cores`);
sharp.concurrency(physicalCores);
async.series({ async.series({
jpeg: function (callback) { jpeg: function (callback) {