refactor(core): migrate to Bun and converge acquisition policies and Agent boundaries
This commit is contained in:
1 parent
3f1c6d02f6
commit
27c0f27434
268 files changed
+7468
-7852
No files matched your search
@@ -1,11 +1,12 @@
|
||||
// 文件操作基准(不进 ci):跨卷 move 1 GB、全量哈希 1 GB、10 万文件扫描;输出耗时与 MB/s。
|
||||
// 用法:deno run -A scripts/bench/fs-bench.ts --base /opt/tmp-bench --other /dev/shm [--size-mb 1024] [--files 100000]
|
||||
// 用法:bun scripts/bench/fs-bench.ts --base /opt/tmp-bench --other /dev/shm [--size-mb 1024] [--files 100000]
|
||||
// base:被测盘(源文件、扫描树所在);other:跨卷 move 的目标(必须与 base 不同设备)
|
||||
// 结果写进 docs/porting/moviepilot-rust-transfer.md「基准记录」。
|
||||
import { randomBytes } from "node:crypto";
|
||||
import { mkdir, mkdtemp, rm, stat, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { parseArgs } from "node:util";
|
||||
import { Command, runtimeOpen } from "@umt/runtime";
|
||||
import {
|
||||
crossDeviceMove,
|
||||
FsProxy,
|
||||
@@ -17,7 +18,7 @@ import {
|
||||
} from "../../packages/adapters/src/index.ts";
|
||||
|
||||
const { values } = parseArgs({
|
||||
args: Deno.args,
|
||||
args: process.argv.slice(2),
|
||||
options: {
|
||||
base: { type: "string" },
|
||||
other: { type: "string", default: "/dev/shm" },
|
||||
@@ -27,7 +28,7 @@ const { values } = parseArgs({
|
||||
});
|
||||
if (!values.base) {
|
||||
console.error("需要 --base <被测目录>");
|
||||
Deno.exit(2);
|
||||
process.exit(2);
|
||||
}
|
||||
const MB = 1024 * 1024;
|
||||
const sizeMb = Number(values["size-mb"]);
|
||||
@@ -50,7 +51,7 @@ async function timed(name: string, bytes: number | null, fn: () => Promise<unkno
|
||||
}
|
||||
|
||||
async function makeBig(p: string) {
|
||||
const f = await Deno.open(p, { write: true, create: true, truncate: true });
|
||||
const f = await runtimeOpen(p, { write: true, create: true, truncate: true });
|
||||
const chunk = randomBytes(8 * MB);
|
||||
for (let i = 0; i < sizeMb / 8; i++) await f.write(chunk);
|
||||
f.close();
|
||||
@@ -84,7 +85,7 @@ try {
|
||||
const cp = join(work, "cp.bin");
|
||||
await makeBig(cp);
|
||||
await timed("对照:cp 跨卷", bytes, async () => {
|
||||
const r = await new Deno.Command("cp", { args: [cp, join(other, "cp.bin")] }).output();
|
||||
const r = await new Command("cp", { args: [cp, join(other, "cp.bin")] }).output();
|
||||
if (!r.success) throw new Error("cp failed");
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user