Skip to content

Commit

Permalink
fix: add debug logs to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Oct 17, 2023
1 parent 9e192d4 commit 7fa77e7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ jobs:
- name: Merge example timings ⛙
id: merge
run: npm run demo-merge -- --set-gha-output merged
env:
DEBUG: cypress-split

- name: Show merged output
run: |
Expand Down
3 changes: 2 additions & 1 deletion bin/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ const loadedTimings = files.map((filename) => {
})
debug('loaded %d timings from %d files', loadedTimings, files.length)

const merged = mergeSplitTimings(loadedTimings)
const merged = mergeSplitTimings(loadedTimings, debug)
debug('merged timings has %d entries', merged.durations.length)
debug(merged)

const mergedText = JSON.stringify(merged, null, 2)
if (args['--output']) {
Expand Down
10 changes: 9 additions & 1 deletion src/timings.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,22 @@ function mergeTimings(prevTimings, currTimings) {
return merged
}

const noop = () => {}

/**
* Merged loaded timings from multiple files into a combined result.
* @param {object[]} timings Loaded timings
* @param {function} debug optional debug function
*/
function mergeSplitTimings(timings) {
function mergeSplitTimings(timings, debug = noop) {
// [spec relative name]: duration
const specResults = {}

debug('merging %d timings', timings.length)
timings.forEach((json, k) => {
debug('timings %k with %d entries', k + 1, json.durations.length)
})

timings.forEach((json) => {
json.durations.forEach((item) => {
if (!specResults[item.spec]) {
Expand Down

0 comments on commit 7fa77e7

Please sign in to comment.