project_note
Clone
https://git.tahinli.com/Tahinli/project_note.git
0 watching0 forksRust3.6 MiBc49f5e7Tahinli1 month ago2 commits
| 1 | import * as path from "https://deno.land/std@0.105.0/path/mod.ts"; |
| 2 | const __dirname = path.dirname(path.fromFileUrl(import.meta.url)); |
| 3 | import { resolve } from "https://deno.land/std@0.105.0/path/mod.ts"; |
| 4 | |
| 5 | export const Tasks = [ |
| 6 | "100_concurrent", |
| 7 | "200_concurrent", |
| 8 | "automerge", |
| 9 | "10_actor_sync_1000_actions", |
| 10 | "20_actor_sync_1000_actions", |
| 11 | "10_actor_sync_2000_actions", |
| 12 | ]; |
| 13 | |
| 14 | export interface Result { |
| 15 | task: string; |
| 16 | maxBytes: number; |
| 17 | endBytes: number; |
| 18 | } |
| 19 | |
| 20 | // run `cargo run --example mem -r -- ${task}` |
| 21 | export async function run(task: string): Promise<Result> { |
| 22 | const cmd = `cargo run --example mem -r -- ${task}`; |
| 23 | const process = Deno.run({ |
| 24 | cmd: cmd.split(" "), |
| 25 | cwd: resolve(__dirname, ".."), |
| 26 | stdout: "piped", |
| 27 | stderr: "piped", |
| 28 | }); |
| 29 | |
| 30 | const output = new TextDecoder().decode(await process.stderrOutput()); |
| 31 | try { |
| 32 | // extract "2,555,555" from `dhat: At t-gmax: 2,555,555 bytes` |
| 33 | const maxBytes = parseInt( |
| 34 | output.match(/dhat: At t-gmax:\s+((\d+,?)+) bytes/)![1].replace(/,/g, ""), |
| 35 | ); |
| 36 | const endBytes = parseInt( |
| 37 | output.match(/dhat: At t-end:\s+((\d+,?)+) bytes/)![1].replace(/,/g, ""), |
| 38 | ); |
| 39 | return { |
| 40 | task, |
| 41 | maxBytes, |
| 42 | endBytes, |
| 43 | }; |
| 44 | } catch (e) { |
| 45 | console.error(e); |
| 46 | console.log(output); |
| 47 | throw e; |
| 48 | } |
| 49 | } |