a post-component library for building user-interfaces on the web.

Use commit refs in worktree names and mitata bench names

tombl.dev a7aca0b5 80838e88

verified
+21 -23
+8 -8
scripts/test/main.ts
··· 33 33 const filter = args.values.filter !== undefined ? new RegExp(args.values.filter) : undefined 34 34 const exec_file = promisify(execFile) 35 35 36 - async function setup_comparison_builds(commits: string[]): Promise<{ paths: string[]; cleanup: () => void }> { 37 - const build_paths: string[] = [] 36 + async function setup_comparison_builds(commits: string[]) { 37 + const builds: Array<{ path: string; ref: string }> = [] 38 38 const temp_dirs: string[] = [] 39 39 40 40 for (let i = 0; i < commits.length; i++) { 41 41 const commit = commits[i] 42 - const temp_dir = `temp-worktree-${i}` 42 + const temp_dir = `temp-worktree-${commit.replace(/[^a-zA-Z0-9]/g, '-')}` 43 43 44 - console.log(`Building version ${i + 1}: ${commit}`) 44 + console.log(`Building ${commit}`) 45 45 46 46 // Create worktree for this commit 47 47 await exec_file('git', ['worktree', 'add', temp_dir, commit], { stdio: 'inherit' }) ··· 52 52 await exec_file('npm', ['run', 'build'], { stdio: 'inherit', cwd: temp_dir }) 53 53 54 54 // Use the dist directory directly from the worktree 55 - build_paths.push(`${temp_dir}/dist`) 55 + builds.push({ path: `${temp_dir}/dist`, ref: commit }) 56 56 } 57 57 58 58 const cleanup = async () => { ··· 66 66 } 67 67 } 68 68 69 - return { paths: build_paths, cleanup } 69 + return { builds, cleanup } 70 70 } 71 71 72 72 const all_files: { [runtime: string]: string[] } = {} ··· 118 118 if (commits.length !== 2) { 119 119 throw new Error('--compare requires exactly two comma-separated commit references') 120 120 } 121 - const { paths: library_paths, cleanup } = await setup_comparison_builds(commits) 121 + const { builds, cleanup } = await setup_comparison_builds(commits) 122 122 try { 123 123 // Don't import bench.ts for comparison mode - handled internally 124 - await client.run_benchmarks({ filter, library_paths }) 124 + await client.run_benchmarks({ filter, builds }) 125 125 } finally { 126 126 await cleanup() 127 127 }
+13 -15
scripts/test/runtime.ts
··· 9 9 define<K extends keyof typeof globalThis>(name: K, value: (typeof globalThis)[K]): void 10 10 import(path: string): Promise<unknown> 11 11 run_tests(options: { filter?: RegExp }): Promise<void> 12 - run_benchmarks(options: { filter?: RegExp; library_paths?: string[] }): Promise<mitata.trial[]> 12 + run_benchmarks(options: { filter?: RegExp; builds?: Array<{ path: string; ref: string }> }): Promise<mitata.trial[]> 13 13 stop_coverage(): Promise<void> 14 14 } 15 15 ··· 35 35 } 36 36 }, 37 37 async run_benchmarks(options) { 38 - const { library_paths } = options 38 + const { builds } = options 39 39 40 - if (!library_paths || library_paths.length === 1) { 41 - // Single library path - standard benchmarking mode 40 + if (!builds || builds.length === 1) { 41 + // Single build or standard benchmarking mode 42 42 const { benchmarks } = await mitata.run({ filter: options.filter }) 43 43 return benchmarks 44 44 } else { 45 - // Multiple library paths - comparison mode 45 + // Multiple builds - comparison mode 46 46 const libraries = [] 47 47 48 48 // Dynamically import all library versions 49 - for (const libPath of library_paths) { 49 + for (const build of builds) { 50 50 try { 51 - const index = await import(`../../${libPath}/index.min.js`) 52 - const client = await import(`../../${libPath}/client.min.js`) 53 - const server = await import(`../../${libPath}/server.min.js`) 51 + const index = await import(`../../${build.path}/index.min.js`) 52 + const client = await import(`../../${build.path}/client.min.js`) 53 + const server = await import(`../../${build.path}/server.min.js`) 54 54 libraries.push({ 55 55 index: { html: index.html }, 56 56 client: { invalidate: client.invalidate, createRoot: client.createRoot }, 57 57 server, 58 + ref: build.ref, 58 59 }) 59 60 } catch (error) { 60 - console.error(`Failed to import from ${libPath}:`, error) 61 + console.error(`Failed to import from ${build.path}:`, error) 61 62 throw error 62 63 } 63 64 } ··· 68 69 69 70 // Setup mitata comparison 70 71 mitata.summary(() => { 71 - for (let i = 0; i < libraries.length; i++) { 72 - const lib = libraries[i] 73 - const libName = `version ${i + 1}` 74 - 75 - mitata.bench(libName, () => { 72 + for (const lib of libraries) { 73 + mitata.bench(lib.ref, () => { 76 74 const benchmarks = get_benchmarks(lib) 77 75 // Run all benchmark functions 78 76 for (const [name, fn] of Object.entries(benchmarks)) {