From 6af5789fc4704b5071b47eb2201c6876e6aced2e Mon Sep 17 00:00:00 2001 From: Wu Jian Ping Date: Fri, 22 Jul 2022 14:28:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96bench=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- binding/nodejs/tests/bench.app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/binding/nodejs/tests/bench.app.js b/binding/nodejs/tests/bench.app.js index 091e97b..b0f5c6f 100644 --- a/binding/nodejs/tests/bench.app.js +++ b/binding/nodejs/tests/bench.app.js @@ -119,8 +119,7 @@ const main = async () => { const region = list.slice(2, list.length).join('|') // check the region info if (region !== info.region) { - console.log(`failed search(${mip}) with (${region} != ${info.region})`) - process.exit(1) + throw new Error(`failed search(${mip}) with (${region} != ${info.region})`) } total++ } @@ -139,8 +138,9 @@ process.on('exit', code => { if (code === 0) { // 这边只算个总时间就够了 const diff = process.hrtime(startTime) - const took = (diff[0] * 1e9 + diff[1]) / 1e9 - console.log(`Bench finished, {cachePolicy: ${cachePolicy}, total: ${total}, took: ${took}s, cost: ${total === 0 ? 0 : ((diff[0] * 1e9 + diff[1]) / 1e6) / total}μs/op}`) + const totalInNS = diff[0] * 1e9 + diff[1] + const took = totalInNS / 1e9 + console.log(`Bench finished, {cachePolicy: ${cachePolicy}, total: ${total}, took: ${took}s, cost: ${total === 0 ? 0 : (totalInNS / 1e6) / total}μs/op}`) } })