ui: show total scan time in the card snapshots list
Each snapshot row now renders '(N files, scanned in X.XX sec)' when the snapshot has timing data (profilerSnapshotCountLabel); old/imported snapshots without timing keep the plain '(N files)'. RU wording 'за X.XX сек'. SW cache v100 -> v101.
This commit is contained in:
+11
-1
@@ -7293,7 +7293,7 @@ function profilerRenderSnapshotList() {
|
||||
html += '<b>' + esc(s.name) + '</b>';
|
||||
if (s.iccid) html += '<span class="text-xs font-mono text-gray-500 dark:text-slate-400">' + esc(s.iccid) + '</span>';
|
||||
html += '<span class="text-xs text-gray-400 dark:text-slate-500">' + esc(new Date(s.created).toLocaleString()) + '</span>';
|
||||
html += '<span class="text-xs text-gray-400 dark:text-slate-500">(' + s.files.length + ' ' + esc(t('files')) + ')</span>';
|
||||
html += '<span class="text-xs text-gray-400 dark:text-slate-500">(' + esc(profilerSnapshotCountLabel(s)) + ')</span>';
|
||||
html += '<span class="ml-auto flex gap-1">';
|
||||
html += '<button onclick="snapshotOpen(' + i + ')" class="px-2 py-0.5 text-xs rounded bg-blue-600 text-white hover:bg-blue-700">' + esc(t('Open')) + '</button>';
|
||||
html += '<button onclick="snapshotExport(' + i + ')" class="px-2 py-0.5 text-xs rounded bg-gray-600 text-white hover:bg-gray-700">' + esc(t('Export')) + '</button>';
|
||||
@@ -7623,6 +7623,14 @@ function profilerFormatMs(ms) {
|
||||
return Math.round(ms) + ' ms';
|
||||
}
|
||||
|
||||
function profilerSnapshotCountLabel(s) {
|
||||
let label = (s.files ? s.files.length : 0) + ' ' + t('files');
|
||||
if (s.timing && s.timing.total_ms !== undefined) {
|
||||
label += ', ' + t('scanned in') + ' ' + (s.timing.total_ms / 1000).toFixed(2) + ' ' + t('sec');
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
async function profilerBuildSnapshotFile(path, c, timing) {
|
||||
let sel;
|
||||
try {
|
||||
@@ -8951,6 +8959,8 @@ const LANG_RU = {
|
||||
'Files': 'Файлов',
|
||||
'Records': 'Записей',
|
||||
'Scan time': 'Время сканирования',
|
||||
'scanned in': 'за',
|
||||
'sec': 'сек',
|
||||
'No timing data': 'Нет данных о времени',
|
||||
'min': 'мин',
|
||||
'avg': 'сред',
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
const CACHE = 'otaman-v100';
|
||||
const CACHE = 'otaman-v101';
|
||||
const URLS = [
|
||||
'index.html',
|
||||
'help.html',
|
||||
|
||||
@@ -21,7 +21,7 @@ function extractFunc(src, name, asyncFn) {
|
||||
return (asyncFn ? 'async ' : '') + src.slice(m.index, i + 1);
|
||||
}
|
||||
|
||||
const FNS = ['profilerNormHex', 'profilerNormHexStrict', 'profilerMatch', 'profilerMatchMin', 'profilerMaskPrefix4', 'profilerFileFields', 'profilerContentKindForFileType', 'profilerEmptyRecordContent', 'profilerValidateProfile', 'profilerCustomNameForPath', 'profilerUpdateRulePath', 'profilerResultAspects', 'profilerAspectSummary', 'profilerNumRanges', 'esc', 'escHtml', 'profilerRawDataCheck', 'profilerRenderReport', 'parseBerLen', 'parseTlvList', 'fcpInt', 'fcpParseTlvs', 'fcpFileDescriptor', 'fcpLifeCycle', 'fcpSfi', 'fcpDo', 'fcpDecode', 'fcpDiffHtml', 'profilerFciPreviewItems', 'profilerUpdateFciPreview', 'profilerUpdateRule', 'profilerFciInput', 'profilerScanToggleAll', 'profilerScanIgnoreAllState', 'swapNibbles', 'decIccid', 'profilerSnapshotIccid', 'profilerValidateSnapshot', 'profilerListSwitch', 'profilerScanRefreshOptions', 'profilerLiveSource', 'profilerSnapshotSource', 'profilerVisibleResults', 'profilerMaskFidForFile', 'profilerRulesFromSnapshot', 'profilerExtraFileResults', 'profilerScanNameKeydown', 'profilerTimingStats', 'profilerTimingAccumulator', 'profilerFormatMs', 'profilerRenderSnapshotSummary'];
|
||||
const FNS = ['profilerNormHex', 'profilerNormHexStrict', 'profilerMatch', 'profilerMatchMin', 'profilerMaskPrefix4', 'profilerFileFields', 'profilerContentKindForFileType', 'profilerEmptyRecordContent', 'profilerValidateProfile', 'profilerCustomNameForPath', 'profilerUpdateRulePath', 'profilerResultAspects', 'profilerAspectSummary', 'profilerNumRanges', 'esc', 'escHtml', 'profilerRawDataCheck', 'profilerRenderReport', 'parseBerLen', 'parseTlvList', 'fcpInt', 'fcpParseTlvs', 'fcpFileDescriptor', 'fcpLifeCycle', 'fcpSfi', 'fcpDo', 'fcpDecode', 'fcpDiffHtml', 'profilerFciPreviewItems', 'profilerUpdateFciPreview', 'profilerUpdateRule', 'profilerFciInput', 'profilerScanToggleAll', 'profilerScanIgnoreAllState', 'swapNibbles', 'decIccid', 'profilerSnapshotIccid', 'profilerValidateSnapshot', 'profilerListSwitch', 'profilerScanRefreshOptions', 'profilerLiveSource', 'profilerSnapshotSource', 'profilerVisibleResults', 'profilerMaskFidForFile', 'profilerRulesFromSnapshot', 'profilerExtraFileResults', 'profilerScanNameKeydown', 'profilerTimingStats', 'profilerTimingAccumulator', 'profilerFormatMs', 'profilerRenderSnapshotSummary', 'profilerSnapshotCountLabel'];
|
||||
let code = '';
|
||||
for (const f of FNS) code += extractFunc(html, f) + '\n';
|
||||
code += extractFunc(html, 'profilerBuildFileRule', true) + '\n';
|
||||
@@ -1216,3 +1216,14 @@ test('profilerRenderSnapshotSummary notes missing timing data', () => {
|
||||
assert.ok(html.includes('No timing data'), html);
|
||||
delete global.t;
|
||||
});
|
||||
|
||||
test('profilerSnapshotCountLabel appends the scan time when available', () => {
|
||||
global.t = s => (s === 'scanned in' ? 'scanned in' : s);
|
||||
const withTime = profilerSnapshotCountLabel({ files: new Array(95).fill({}), timing: { total_ms: 21320 } });
|
||||
assert.strictEqual(withTime, '95 files, scanned in 21.32 sec');
|
||||
const noTime = profilerSnapshotCountLabel({ files: new Array(3).fill({}) });
|
||||
assert.strictEqual(noTime, '3 files');
|
||||
const empty = profilerSnapshotCountLabel({ files: [], timing: {} });
|
||||
assert.strictEqual(empty, '0 files');
|
||||
delete global.t;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user