From 70a3067963a056ce80ca710422887dbc09e255f5 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Tue, 26 Sep 2023 21:16:46 +0100 Subject: [PATCH] Test: update bench deps, use physical CPU core count --- test/bench/package.json | 7 ++----- test/bench/perf.js | 8 +++++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/test/bench/package.json b/test/bench/package.json index ee43e9c5..10a63e00 100644 --- a/test/bench/package.json +++ b/test/bench/package.json @@ -17,11 +17,8 @@ "jimp": "0.22.10" }, "optionalDependencies": { - "@tensorflow/tfjs-node": "4.9.0", + "@tensorflow/tfjs-node": "4.11.0", "mapnik": "4.5.9" }, - "license": "Apache-2.0", - "engines": { - "node": "16" - } + "license": "Apache-2.0" } diff --git a/test/bench/perf.js b/test/bench/perf.js index 05f364be..a017df80 100644 --- a/test/bench/perf.js +++ b/test/bench/perf.js @@ -5,7 +5,7 @@ const os = require('os'); const fs = require('fs'); -const { exec } = require('child_process'); +const { exec, execSync } = require('child_process'); const async = require('async'); const Benchmark = require('benchmark'); @@ -40,8 +40,10 @@ const heightPng = 540; // Disable libvips cache to ensure tests are as fair as they can be sharp.cache(false); -// Spawn one thread per CPU -sharp.concurrency(os.cpus().length); +// Spawn one thread per physical CPU core +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({ jpeg: function (callback) {