Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local per-test score calculation #33

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/node_modules
.DS_Store
.DS_Store
/runs-2020-zstd
/runs-zstd
47 changes: 42 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ async function process_chunks (path) {
const scored_chunk = process_raw_results(chunk_run)
if (!result.run_info) {
const raw_run_info = scored_chunk.run_info
const matches = raw_run_info
.browser_version.match(/^Servo ([0-9.]+-[a-f0-9]+)?(-dirty)?$/)
const browser_version = matches.length === 3 ? matches[1] : 'Unknown'
const matches = raw_run_info?.browser_version?.match(/^Servo ([0-9.]+-[a-f0-9]+)?(-dirty)?$/)
const browser_version = matches?.length === 3 ? matches[1] : 'Unknown'
result.run_info = Object.assign(raw_run_info, { browser_version })
}
delete scored_chunk.run_info
Expand All @@ -67,6 +66,23 @@ async function add_run (runs_dir, chunks_dir, date) {
await write_compressed(`./${runs_dir}/${date}.xz`, new_run)
}

async function score_single_run (chunks_dir, print_filter) {
const run = await process_chunks(chunks_dir)
const test_to_areas = focus_areas_map(run)
const { area_keys } = get_focus_areas()
const score = score_run(run, run, test_to_areas, print_filter)
const row = [
['revision', run.run_info.revision.substring(0, 9)],
['browser version', run.run_info.browser_version]
]

for (const area of area_keys) {
row.push([area, score[area]])
}

return row
}

async function recalc_scores (runs_dir) {
console.log(`Calculating scores for ${runs_dir} directory...`)

Expand All @@ -81,10 +97,12 @@ async function recalc_scores (runs_dir) {
const { area_keys } = get_focus_areas()
for (const [i, r] of all_runs.entries()) {
const [date] = r.split('.')
const start = Date.now()
console.log(`Reading run ${runs_dir}/${r} (${i}/${run_count})`)
const run = await read_compressed(`./${runs_dir}/${r}`)
const start_score = Date.now()
console.log(`Calculating score for run ${runs_dir}/${r} (${i}/${run_count})`)
const score = score_run(run, new_run, test_to_areas)
const score = score_run(run, new_run, test_to_areas, () => false)
const row = [
date,
run.run_info.revision.substring(0, 9),
Expand All @@ -95,17 +113,36 @@ async function recalc_scores (runs_dir) {
row.push(score[area])
}
scores.push(row)

const end = Date.now()
const read_time = start_score - start
const score_time = end - start_score
const total_time = end - start

console.log(`Done in ${total_time}ms (read in ${read_time}ms; scored in ${score_time}ms).`)
}

return scores
}

async function main () {
const mode = process.argv[2]
if (!['--add', '--recalc'].includes(mode)) {
if (!['--add', '--recalc', '--score'].includes(mode)) {
throw new Error(`invalid mode specified: ${mode}`)
}

if (mode === '--score') {
const input_dir = process.argv[3]

let filterStr = undefined
if (process.argv[4] === '--filter') {
filterStr = process.argv[5]
}
const result = await score_single_run(input_dir, filterStr ? name => name.includes(filterStr) : () => true)
console.log(result)
return
}

if (mode === '--add') {
const chunks = process.argv[3]
const date = process.argv[4]
Expand Down
200 changes: 160 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"mocha": "^10.2.0"
},
"dependencies": {
"chalk": "^5.3.0",
"lzma-native": "^8.0.6"
}
}
Loading