Skip to content

Commit 0fa8ba8

Browse files
committed
fix: fixed up benches
1 parent 39e6652 commit 0fa8ba8

File tree

6 files changed

+49
-40
lines changed

6 files changed

+49
-40
lines changed

benches/db_1KiB.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import os from 'os';
22
import fs from 'fs';
33
import path from 'path';
44
import crypto from 'crypto';
5+
import url from 'node:url';
56
import b from 'benny';
67
import Logger, { LogLevel, StreamHandler } from '@matrixai/logger';
7-
import DB from '@/DB';
8-
import { suiteCommon } from './utils';
8+
import DB from '#DB.js';
9+
import { suiteCommon } from './utils/utils.js';
910

1011
const logger = new Logger('DB1KiB Bench', LogLevel.WARN, [new StreamHandler()]);
12+
const filename = url.fileURLToPath(new URL(import.meta.url));
1113

1214
async function main() {
1315
const dataDir = await fs.promises.mkdtemp(
@@ -18,7 +20,7 @@ async function main() {
1820
const data0 = crypto.randomBytes(0);
1921
const data1KiB = crypto.randomBytes(1024);
2022
const summary = await b.suite(
21-
path.basename(__filename, path.extname(__filename)),
23+
path.basename(filename, path.extname(filename)),
2224
b.add('get 1 KiB of data', async () => {
2325
await db.put('1kib', data1KiB, true);
2426
return async () => {
@@ -44,8 +46,7 @@ async function main() {
4446
});
4547
return summary;
4648
}
47-
48-
if (require.main === module) {
49+
if (process.argv[1] === url.fileURLToPath(import.meta.url)) {
4950
void main();
5051
}
5152

benches/db_1MiB.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import os from 'os';
22
import fs from 'fs';
33
import path from 'path';
44
import crypto from 'crypto';
5+
import url from "node:url";
56
import b from 'benny';
67
import Logger, { LogLevel, StreamHandler } from '@matrixai/logger';
7-
import DB from '@/DB';
8-
import { suiteCommon } from './utils';
8+
import DB from '#DB.js';
9+
import { suiteCommon } from './utils/utils.js';
910

1011
const logger = new Logger('DB1MiB Bench', LogLevel.WARN, [new StreamHandler()]);
12+
const filename = url.fileURLToPath(new URL(import.meta.url));
1113

1214
async function main() {
1315
const dataDir = await fs.promises.mkdtemp(
@@ -18,7 +20,7 @@ async function main() {
1820
const data0 = crypto.randomBytes(0);
1921
const data1MiB = crypto.randomBytes(1024 * 1024);
2022
const summary = await b.suite(
21-
path.basename(__filename, path.extname(__filename)),
23+
path.basename(filename, path.extname(filename)),
2224
b.add('get 1 MiB of data', async () => {
2325
await db.put('1mib', data1MiB, true);
2426
return async () => {
@@ -45,7 +47,7 @@ async function main() {
4547
return summary;
4648
}
4749

48-
if (require.main === module) {
50+
if (process.argv[1] === url.fileURLToPath(import.meta.url)) {
4951
void main();
5052
}
5153

benches/index.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,29 @@
22

33
import fs from 'fs';
44
import path from 'path';
5+
import url from 'node:url';
56
import si from 'systeminformation';
67
import DB1KiB from './db_1KiB.js';
78
import DB1MiB from './db_1MiB.js';
89

10+
const dirname = url.fileURLToPath(new URL('.', import.meta.url));
11+
912
async function main(): Promise<void> {
10-
await fs.promises.mkdir(path.join(__dirname, 'results'), { recursive: true });
13+
await fs.promises.mkdir(path.join(dirname, 'results'), { recursive: true });
1114
await DB1KiB();
1215
await DB1MiB();
1316
const resultFilenames = await fs.promises.readdir(
14-
path.join(__dirname, 'results'),
17+
path.join(dirname, 'results'),
1518
);
1619
const metricsFile = await fs.promises.open(
17-
path.join(__dirname, 'results', 'metrics.txt'),
20+
path.join(dirname, 'results', 'metrics.txt'),
1821
'w',
1922
);
2023
let concatenating = false;
2124
for (const resultFilename of resultFilenames) {
2225
if (/.+_metrics\.txt$/.test(resultFilename)) {
2326
const metricsData = await fs.promises.readFile(
24-
path.join(__dirname, 'results', resultFilename),
27+
path.join(dirname, 'results', resultFilename),
2528
);
2629
if (concatenating) {
2730
await metricsFile.write('\n');
@@ -37,7 +40,7 @@ async function main(): Promise<void> {
3740
system: 'model, manufacturer',
3841
});
3942
await fs.promises.writeFile(
40-
path.join(__dirname, 'results', 'system.json'),
43+
path.join(dirname, 'results', 'system.json'),
4144
JSON.stringify(systemData, null, 2),
4245
);
4346
}

benches/results/system.json

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
{
22
"cpu": {
3-
"manufacturer": "AMD",
4-
"brand": "Ryzen 7 2700X Eight-Core Processor",
5-
"vendor": "AMD",
6-
"family": "23",
7-
"model": "8",
3+
"manufacturer": "Intel",
4+
"brand": "Gen Intel® Core™ i7-1370P",
5+
"vendor": "Intel",
6+
"family": "6",
7+
"model": "186",
88
"stepping": "2",
99
"revision": "",
1010
"voltage": "",
11-
"speed": 3.7,
12-
"speedMin": 2.2,
13-
"speedMax": 3.7,
14-
"governor": "performance",
15-
"cores": 16,
16-
"physicalCores": 8,
17-
"performanceCores": 8,
18-
"efficiencyCores": 0,
11+
"speed": 1.12,
12+
"speedMin": 0.4,
13+
"speedMax": 5.2,
14+
"governor": "powersave",
15+
"cores": 20,
16+
"physicalCores": 14,
17+
"performanceCores": 6,
18+
"efficiencyCores": 8,
1919
"processors": 1,
2020
"socket": "",
21-
"flags": "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate ssbd ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca sev sev_es",
21+
"flags": "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq tme rdpid movdiri movdir64b fsrm md_clear serialize pconfig arch_lbr ibt flush_l1d arch_capabilities",
2222
"virtualization": true,
2323
"cache": {
24-
"l1d": 262144,
25-
"l1i": 524288,
26-
"l2": 4194304,
27-
"l3": 16777216
24+
"l1d": 557056,
25+
"l1i": 720896,
26+
"l2": 11534336,
27+
"l3": 25165824
2828
}
2929
},
3030
"osInfo": {
3131
"platform": "linux",
3232
"distro": "nixos",
33-
"release": "22.11",
34-
"kernel": "6.1.23",
33+
"release": "24.11",
34+
"kernel": "6.6.47",
3535
"arch": "x64"
3636
},
3737
"system": {
38-
"model": "System Product Name",
39-
"manufacturer": "System manufacturer"
38+
"model": "Precision 3480",
39+
"manufacturer": "Dell Inc."
4040
}
4141
}

benches/utils/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './utils';
1+
export * from './utils.js';

benches/utils/utils.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
import fs from 'fs';
22
import path from 'path';
3+
import url from 'node:url';
34
import b from 'benny';
45
import { codeBlock } from 'common-tags';
56
import packageJson from '../../package.json';
67

8+
const dirname = url.fileURLToPath(new URL('.', import.meta.url));
9+
710
const suiteCommon = [
811
b.cycle(),
912
b.complete(),
1013
b.save({
1114
file: (summary) => summary.name,
12-
folder: path.join(__dirname, '../results'),
15+
folder: path.join(dirname, '../results'),
1316
version: packageJson.version,
1417
details: true,
1518
}),
1619
b.save({
1720
file: (summary) => summary.name,
18-
folder: path.join(__dirname, '../results'),
21+
folder: path.join(dirname, '../results'),
1922
version: packageJson.version,
2023
format: 'chart.html',
2124
}),
2225
b.complete((summary) => {
2326
const filePath = path.join(
24-
__dirname,
27+
dirname,
2528
'../results',
2629
summary.name + '_metrics.txt',
2730
);

0 commit comments

Comments
 (0)