mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-02 10:52:05 +00:00
- Added `torch-lock` dependency to `torch/package.json` - Initialized TORCH structure using `cmdInit` (mocked interaction) - Updated `torch/package.json` with TORCH CLI scripts (`lock:check`, `lock:lock`, etc.) - Updated `torch/torch-config.json` with Nostr configuration - Added `type: module` to `torch/package.json` to support ES modules - Cleaned up extraneous directories (`test_logs`, `todo`, etc.) from initialization Co-authored-by: PR0M3TH3AN <[email protected]>
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
import { loadTorchConfig, _resetTorchConfigCache } from '../torch-config.mjs';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
const configPath = path.resolve(process.cwd(), 'torch-config.json');
|
|
const originalConfig = fs.existsSync(configPath) ? fs.readFileSync(configPath) : null;
|
|
|
|
// Ensure a config file exists for benchmark
|
|
if (!fs.existsSync(configPath)) {
|
|
fs.writeFileSync(configPath, JSON.stringify({
|
|
nostrLock: {
|
|
relays: ["wss://relay.damus.io"],
|
|
namespace: "test-ns"
|
|
}
|
|
}, null, 2));
|
|
}
|
|
|
|
const ITERATIONS = 1000;
|
|
const start = process.hrtime.bigint();
|
|
|
|
async function run() {
|
|
for (let i = 0; i < ITERATIONS; i++) {
|
|
_resetTorchConfigCache();
|
|
try {
|
|
const res = await loadTorchConfig();
|
|
// Use res to prevent dead code elimination if JIT is smart (though side effects exist)
|
|
if (!res) throw new Error("Failed");
|
|
} catch (e) {
|
|
// ignore
|
|
}
|
|
}
|
|
|
|
const end = process.hrtime.bigint();
|
|
const duration = Number(end - start) / 1e6; // ms
|
|
|
|
console.log(`[ASYNC] Loaded config ${ITERATIONS} times in ${duration.toFixed(2)}ms`);
|
|
console.log(`[ASYNC] Average: ${(duration / ITERATIONS).toFixed(4)}ms per load`);
|
|
|
|
// Cleanup
|
|
if (!originalConfig && fs.existsSync(configPath)) {
|
|
fs.unlinkSync(configPath);
|
|
}
|
|
}
|
|
|
|
run();
|