v1.1.0: pooled runtime, 959 tests, production hardening (0 squash)
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { performance } from 'node:perf_hooks'
|
||||
import { chromium } from 'playwright'
|
||||
import { imhotep } from 'imhotep'
|
||||
import { mkdtempSync, writeFileSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
|
||||
const tmpdir2 = mkdtempSync(join(tmpdir(), 'imhotep-full-pipeline-'))
|
||||
const html = `
|
||||
<!DOCTYPE html>
|
||||
<html><body>
|
||||
<div id="container">
|
||||
${Array.from({length: 50}, (_, i) => `<div class="item" data-testid="item-${i}" style="position:absolute;left:${(i % 10) * 60}px;top:${Math.floor(i / 10) * 60}px;width:50px;height:50px;background:#ccc;">${i}</div>
|
||||
`).join('')}
|
||||
</div>
|
||||
</body></html>
|
||||
`
|
||||
writeFileSync(join(tmpdir2, 'page.html'), html)
|
||||
|
||||
const browser = await chromium.launch()
|
||||
const page = await browser.newPage()
|
||||
await page.goto(`file:${join(tmpdir2, 'page.html')}`)
|
||||
|
||||
console.log('=== Full Pipeline Benchmark ===\n')
|
||||
|
||||
for (const count of [1, 5, 10, 25, 50]) {
|
||||
const ui = await imhotep(page)
|
||||
for (let i = 0; i < count; i++) {
|
||||
ui.expect(`[data-testid="item-${i}"]`).to.be.leftOf('[data-testid="item-0"]')
|
||||
}
|
||||
|
||||
const times = []
|
||||
for (let run = 0; run < 5; run++) {
|
||||
await ui.clearCache()
|
||||
const start = performance.now()
|
||||
await ui.checkAll()
|
||||
times.push(performance.now() - start)
|
||||
}
|
||||
const mean = times.reduce((a,b) => a+b, 0) / times.length
|
||||
console.log(`${count} assertions (cold): ${mean.toFixed(1)}ms (5 runs)`)
|
||||
}
|
||||
|
||||
await browser.close()
|
||||
rmSync(tmpdir2, { recursive: true, force: true })
|
||||
Reference in New Issue
Block a user