benchmark: enable no-empty ESLint rule

PR-URL: https://github.com/nodejs/node/pull/41831
Refs: https://eslint.org/docs/rules/no-empty
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Rich Trott authored and Node.js GitHub Bot committed 2022-02-05 12:58:27 +00:00
1 parent 912c297b7a
commit 776d0b4e62
11 files changed
+62 -14

No files matched your search

+1
View File
@@ -5,5 +5,6 @@ env:
es6: true
rules:
no-empty: error
no-var: error
prefer-arrow-callback: error
+1 -1
View File
@@ -22,7 +22,7 @@ function useFor(n, items, count) {
function useForOf(n, items) {
bench.start();
for (let i = 0; i < n; i++) {
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line no-unused-vars, no-empty
for (const item of items) {}
}
bench.end(n);
+1
View File
@@ -21,6 +21,7 @@ function main({ n, statSyncType }) {
try {
fs.statSync(arg);
} catch {
// Continue regardless of error.
}
}
}
+10 -2
View File
@@ -50,7 +50,11 @@ function main(conf) {
buf.fill('x');
}
try { fs.unlinkSync(filename); } catch {}
try {
fs.unlinkSync(filename);
} catch {
// Continue regardless of error.
}
const ws = fs.createWriteStream(filename);
ws.on('close', runTest.bind(null, filesize, highWaterMark, encoding, n));
ws.on('drain', write);
@@ -81,7 +85,11 @@ function runTest(filesize, highWaterMark, encoding, n) {
});
rs.on('end', () => {
try { fs.unlinkSync(filename); } catch {}
try {
fs.unlinkSync(filename);
} catch {
// Continue regardless of error.
}
// MB/sec
bench.end(bytes / (1024 * 1024));
});
+10 -2
View File
@@ -23,7 +23,11 @@ const bench = common.createBenchmark(main, {
});
function main({ len, dur, concurrent }) {
try { fs.unlinkSync(filename); } catch {}
try {
fs.unlinkSync(filename);
} catch {
// Continue regardless of error.
}
let data = Buffer.alloc(len, 'x');
fs.writeFileSync(filename, data);
data = null;
@@ -38,7 +42,11 @@ function main({ len, dur, concurrent }) {
const totalOps = reads + zips;
benchEnded = true;
bench.end(totalOps);
try { fs.unlinkSync(filename); } catch {}
try {
fs.unlinkSync(filename);
} catch {
// Continue regardless of error.
}
}, dur * 1000);
function read() {
+10 -2
View File
@@ -20,7 +20,11 @@ const bench = common.createBenchmark(main, {
});
function main({ len, duration, concurrent }) {
try { fs.unlinkSync(filename); } catch { }
try {
fs.unlinkSync(filename);
} catch {
// Continue regardless of error.
}
let data = Buffer.alloc(len, 'x');
fs.writeFileSync(filename, data);
data = null;
@@ -31,7 +35,11 @@ function main({ len, duration, concurrent }) {
setTimeout(() => {
benchEnded = true;
bench.end(writes);
try { fs.unlinkSync(filename); } catch { }
try {
fs.unlinkSync(filename);
} catch {
// Continue regardless of error.
}
process.exit(0);
}, duration * 1000);
+10 -2
View File
@@ -20,7 +20,11 @@ const bench = common.createBenchmark(main, {
});
function main({ len, duration, concurrent }) {
try { fs.unlinkSync(filename); } catch {}
try {
fs.unlinkSync(filename);
} catch {
// Continue regardless of error.
}
let data = Buffer.alloc(len, 'x');
fs.writeFileSync(filename, data);
data = null;
@@ -31,7 +35,11 @@ function main({ len, duration, concurrent }) {
setTimeout(() => {
benchEnded = true;
bench.end(reads);
try { fs.unlinkSync(filename); } catch {}
try {
fs.unlinkSync(filename);
} catch {
// Continue regardless of error.
}
process.exit(0);
}, duration * 1000);
+10 -2
View File
@@ -36,7 +36,11 @@ function main({ dur, encodingType, size }) {
throw new Error(`invalid encodingType: ${encodingType}`);
}
try { fs.unlinkSync(filename); } catch {}
try {
fs.unlinkSync(filename);
} catch {
// Continue regardless of error.
}
let started = false;
let ended = false;
@@ -48,7 +52,11 @@ function main({ dur, encodingType, size }) {
f.on('finish', () => {
ended = true;
const written = fs.statSync(filename).size / 1024;
try { fs.unlinkSync(filename); } catch {}
try {
fs.unlinkSync(filename);
} catch {
// Continue regardless of error.
}
bench.end(written / 1024);
});
+5 -1
View File
@@ -46,7 +46,11 @@ function main({ encodingType, duration, concurrent, size }) {
benchEnded = true;
bench.end(writes);
for (let i = 0; i < filesWritten; i++) {
try { fs.unlinkSync(`${filename}-${i}`); } catch { }
try {
fs.unlinkSync(`${filename}-${i}`);
} catch {
// Continue regardless of error.
}
}
process.exit(0);
}, duration * 1000);
+3 -1
View File
@@ -4,7 +4,9 @@ const common = require('../common.js');
let icu;
try {
icu = common.binding('icu');
} catch {}
} catch {
// Continue regardless of error.
}
const punycode = require('punycode');
const bench = common.createBenchmark(main, {
+1 -1
View File
@@ -55,7 +55,7 @@ function main({ dur, len, type }) {
function send() {
socket.cork();
while (socket.write(chunk, encoding)) {}
while (socket.write(chunk, encoding));
socket.uncork();
}
});