-
Notifications
You must be signed in to change notification settings - Fork 39
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
perf: increase html-reporter performance #492
Conversation
8e4bef6
to
3a7cf13
Compare
return resolvedUrls; | ||
} | ||
|
||
async function tryResolveUrl(url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Рекурсивно проходит по всем вложенным .json
базам. Если возникает ошибка при получении данных, возвращаем саму json
-базу. Помимо "ничего не сломать", фоллбэк нужен для драфт отчетов
const results = await Promise.all(urls.map(tryResolveUrl)); | ||
|
||
results.forEach(({jsonUrls, dbUrls}) => { | ||
resolvedUrls.push(...jsonUrls.concat(dbUrls)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все urls
вставляются в один массив, потому что это позволяет не ломать API
слияния отчетов
@@ -131,7 +131,8 @@ export async function saveStaticFilesToReportDir(htmlReporter: HtmlReporter, plu | |||
copyToReportDir(destPath, ['report.min.js', 'report.min.css'], staticFolder), | |||
fs.copy(path.resolve(staticFolder, 'index.html'), path.resolve(destPath, 'index.html')), | |||
fs.copy(path.resolve(staticFolder, 'icons'), path.resolve(destPath, 'icons')), | |||
fs.copy(require.resolve('@gemini-testing/sql.js'), path.resolve(destPath, 'sql-wasm.js')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-2 МБ
@@ -131,7 +131,8 @@ export async function saveStaticFilesToReportDir(htmlReporter: HtmlReporter, plu | |||
copyToReportDir(destPath, ['report.min.js', 'report.min.css'], staticFolder), | |||
fs.copy(path.resolve(staticFolder, 'index.html'), path.resolve(destPath, 'index.html')), | |||
fs.copy(path.resolve(staticFolder, 'icons'), path.resolve(destPath, 'icons')), | |||
fs.copy(require.resolve('@gemini-testing/sql.js'), path.resolve(destPath, 'sql-wasm.js')), | |||
fs.copy(require.resolve('@gemini-testing/sql.js/dist/sql-wasm.js'), path.resolve(destPath, 'sql-wasm.js')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 56 КБ
@@ -131,7 +131,8 @@ export async function saveStaticFilesToReportDir(htmlReporter: HtmlReporter, plu | |||
copyToReportDir(destPath, ['report.min.js', 'report.min.css'], staticFolder), | |||
fs.copy(path.resolve(staticFolder, 'index.html'), path.resolve(destPath, 'index.html')), | |||
fs.copy(path.resolve(staticFolder, 'icons'), path.resolve(destPath, 'icons')), | |||
fs.copy(require.resolve('@gemini-testing/sql.js'), path.resolve(destPath, 'sql-wasm.js')), | |||
fs.copy(require.resolve('@gemini-testing/sql.js/dist/sql-wasm.js'), path.resolve(destPath, 'sql-wasm.js')), | |||
fs.copy(require.resolve('@gemini-testing/sql.js/dist/sql-wasm.wasm'), path.resolve(destPath, 'sql-wasm.wasm')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 620 КБ
|
||
export function groupMeta({group, groupKey, ...restArgs}) { | ||
export function groupMeta({group, groupKey, diff = group, ...restArgs}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь и далее diff
в функциях - место, куда нужно записывать изменения. По иерархии такие diff
равны тому, чему устанавливаются по умолчанию (в данном случае, group
)
group: group.byKey[groupKey], | ||
result, | ||
value, | ||
diff: diff.byKey[groupKey] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Так что дальше в функции они прокидываются так же, как и сами их read-only
сущности из state
case actionNames.INIT_GUI_REPORT: | ||
case actionNames.INIT_STATIC_REPORT: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В этом action
, tree
не является частью стейта, так что тут можно мутировать его напрямую, что гораздо проще
@@ -1,4 +1,4 @@ | |||
import {findLast} from 'lodash'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут я перенес только action
из статического отчета, потому что в gui
профит слабый, да и логика там становится намного сложнее, так что оно того не стоит
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я тут пытался расположить обработку action
в том же порядке, но тем не менее, в секции с reduce
он отрезолвился плохо. Там можно не смотреть, оставил как было.
Редьюсер распилен на две части:
Первая (статика, без immer.produce
):
switch (action.type) {
case actionNames...
....
return applyStateUpdate(state, diff)
Вторая (gui, с immer.produce
):
return produce(state, draft => {
switch (action.type) {
case actionNames...
....
break;
})`
<link rel="preload" href="databaseUrls.json" as="fetch" crossorigin="anonymous"/> | ||
<link rel="preload" href="sql-wasm.wasm" as="fetch" crossorigin="anonymous"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Потоков у браузера хватает, чтобы грузить это все вместе с report.min.js
параллельно.
ebb880d
to
c91bcc0
Compare
c91bcc0
to
89b8618
Compare
Пулл-реквест распался: