[ci skip] ugly performance test

This commit is contained in:
Christien Rioux 2025-03-12 19:30:49 -04:00
parent 3a8150c062
commit 30a0889d07
7 changed files with 6979 additions and 3177 deletions

View File

@ -662,10 +662,11 @@ async def test_dht_write_read_full_subkeys_local():
subkey_data = await cs.crypt_no_auth(subkey_data, NONCE, SECRET)
subkey_data_list.append(subkey_data)
# Create dht record
desc = await rc0.create_dht_record(schema)
records.append(desc)
# Set all subkeys in their own future
for i in range(SUBKEY_COUNT):
init_futures.add(rc0.set_dht_value(desc.key, ValueSubkey(i), subkey_data))

File diff suppressed because it is too large Load Diff

View File

@ -6,10 +6,11 @@
"node": ">=18"
},
"devDependencies": {
"@wdio/browser-runner": "^8.16.4",
"@wdio/cli": "^8.16.4",
"@wdio/mocha-framework": "^8.16.3",
"@wdio/spec-reporter": "^8.16.3",
"@wdio/browser-runner": "^9.12.0",
"@wdio/cli": "^9.12.0",
"@wdio/devtools-service": "^8.42.0",
"@wdio/mocha-framework": "^9.11.0",
"@wdio/spec-reporter": "^9.11.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"veilid-wasm": "file:../pkg",

View File

@ -1,4 +1,6 @@
import { expect } from '@wdio/globals';
import * as fs from 'fs';
import * as path from 'path';
import {
veilidCoreInitConfig,
@ -81,7 +83,7 @@ describe('VeilidRoutingContext', () => {
const dhtRecord = await routingContext.createDhtRecord({ kind: 'DFLT', o_cnt: 1 });
expect(dhtRecord.key).toBeDefined();
expect(dhtRecord.owner).toBeDefined();
expect(dhtRecord.owner_secret).toBeDefined();
expect(dhtRecord.owner_secret).toBeDefined();
expect(dhtRecord.schema).toEqual({ kind: 'DFLT', o_cnt: 1 });
});
@ -109,6 +111,82 @@ describe('VeilidRoutingContext', () => {
});
});
describe('DHT stress tests', () => {
var savedHandler = undefined;
before(async () => {
await browser.cdp("Profiler", "enable")
await browser.cdp("Profiler", "start")
savedHandler = window.onerror;
process.removeListener("uncaughtException");
})
it('should inspect in parallel without delay', async () => {
const recordCount = 16;
const subkeyCount = 32;
const inspectCount = 10;
const data = textEncoder.encode('🚀 This example DHT data with unicode a Ā 𐀀 文 🚀');
let a = Array();
for (var r = 0; r < recordCount; r++) {
let dhtRecord = await routingContext.createDhtRecord(
{
kind: 'DFLT',
o_cnt: subkeyCount,
},
);
// Set all subkeys
for (var n = 0; n < subkeyCount; n++) {
a.push((async () => {
const measureName = `${r}-setDhtValue-${n}`;
performance.mark(measureName + "-start")
const res = await routingContext.setDhtValue(
dhtRecord.key,
n,
data,
);
console.log(performance.measure(measureName, measureName + "-start").toJSON())
})());
}
// Inspect all records N times while sets are happening
for (var n = 0; n < inspectCount; n++) {
a.push((async () => {
const measureName = `${r}-inspectDhtRecord-${n}`;
performance.mark(measureName + "-start")
const res = await routingContext.inspectDhtRecord(
dhtRecord.key,
null,
"SyncSet",
);
console.log(performance.measure(measureName, measureName + "-start").toJSON())
})());
}
}
// Wait for all results
await Promise.all(a)
});
after(async () => {
let profile = await browser.cdp("Profiler", "stop")
fs.writeFileSync(path.join(__dirname, "profile.json"), JSON.stringify(profile));
await browser.cdp("Profiler", "disable")
})
});
describe('DHT kitchen sink', () => {
let dhtRecord: DHTRecordDescriptor;
const data = '🚀 This example DHT data with unicode a Ā 𐀀 文 🚀';

View File

@ -8,7 +8,8 @@
"@wdio/globals/types",
"expect-webdriverio",
"@wdio/mocha-framework",
"@wdio/browser-runner"
"@wdio/browser-runner",
"@wdio/devtools-service",
],
"skipLibCheck": true,
"noEmit": true,
@ -20,5 +21,7 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
"include": [
"src"
]
}

View File

@ -1,5 +1,7 @@
import type { Options } from '@wdio/types';
export const config: Options.Testrunner = {
/// <reference types="node" />
/// <reference types="@wdio/types" />
export const config: WebdriverIO.Config = {
//
// ====================
// Runner Configuration
@ -19,13 +21,6 @@ export const config: Options.Testrunner = {
},
},
],
autoCompileOpts: {
autoCompile: true,
tsNodeOpts: {
project: './tsconfig.json',
typeCheck: true,
},
},
//
// ==================
@ -70,20 +65,22 @@ export const config: Options.Testrunner = {
// Sauce Labs platform configurator - a great tool to configure your capabilities:
// https://saucelabs.com/platform/platform-configurator
//
capabilities: [
{
// capabilities for local browser web tests
browserName: 'firefox', // or "chrome", "microsoftedge", "safari"
'moz:firefoxOptions': {
args: process.env.WDIO_HEADLESS ? ['-headless'] : [],
},
},
// {
// browserName: 'chrome',
// 'goog:chromeOptions': {
// args: process.env.WDIO_HEADLESS ? ['headless', 'disable-gpu'] : [],
// // capabilities for local browser web tests
// browserName: 'firefox', // or "chrome", "microsoftedge", "safari"
// 'moz:debuggerAddress': true,
// 'moz:firefoxOptions': {
// args: process.env.WDIO_HEADLESS ? ['-headless'] : [],
// },
// },
{
browserName: 'chrome',
'goog:chromeOptions': {
args: process.env.WDIO_HEADLESS ? ['headless', 'disable-gpu'] : [],
},
},
],
//
@ -133,7 +130,7 @@ export const config: Options.Testrunner = {
// Services take over a specific job you don't want to take care of. They enhance
// your test setup with almost no effort. Unlike plugins, they don't add new
// commands. Instead, they hook themselves up into the test process.
// services: [],
services: ['devtools'],
//
// Framework you want to run your specs with.
// The following are supported: Mocha, Jasmine, and Cucumber

View File

@ -7,6 +7,13 @@ pushd "$SCRIPTDIR" &> /dev/null
WASM_PACK_FLAGS="--dev"
if [[ "$1" == "release" ]]; then
WASM_PACK_FLAGS="--release"
shift
fi
TEST_COMMAND="npm run test:headless"
if [[ "$1" == "interactive" ]]; then
TEST_COMMAND="npm run test"
shift
fi
# Build wasm into an npm package, output into ./pkg
@ -18,7 +25,7 @@ npm install
original_tmpdir=$TMPDIR
mkdir -p ~/tmp
export TMPDIR=~/tmp
npm run test:headless
$TEST_COMMAND $@
export TMPDIR=$original_tmpdir
popd &> /dev/null