6d30e7095e
Server measures every classified APDU (A4 select, B0 read binary, B2 read
record) from command to response: _collect_apdu_times() enables the tracer
(reattaching it if pySim nulled it) and /api/select + /api/read return
'apdu_times': [{type, ms}]. Collection is safe: handlers hold _CARD_LOCK.
Snapshots store per-file {select_ms, read_ms}, a ms value per record and
snapshot-level stats {select, read_binary, read_record}: {min, max, avg,
count} plus total_ms (wall time of the scan). The snapshot view gets a
summary under the title (files/records counts, scan time, min/avg/max per
command type) and shows select/read per file and read time per record.
Timings are display-only: checks, snapshots comparison and imports ignore
them (old snapshots simply show 'No timing data').
Tests: Python classifier/collection (tests/test_apdu_timing.py) and
frontend stats/accumulator/format/build-file/summary. SW cache v99 ->
v100; help, README and docs/api.md updated.
44 lines
1.8 KiB
JavaScript
44 lines
1.8 KiB
JavaScript
const { test } = require('node:test');
|
|
const assert = require('node:assert');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const html = fs.readFileSync(path.join(__dirname, '..', 'index.html'), 'utf8');
|
|
const opens = (html.match(/<div\b/g) || []).length;
|
|
const closes = (html.match(/<\/div>/g) || []).length;
|
|
|
|
test('HTML <div> tags are balanced', () => {
|
|
assert.strictEqual(opens, closes, `Unbalanced divs: ${opens} opens vs ${closes} closes`);
|
|
});
|
|
|
|
test('top-level tabs match the rearranged views', () => {
|
|
const tabs = [...html.matchAll(/class="tab-btn[^"]*" data-tab="([^"]+)"/g)].map(m => m[1]);
|
|
assert.deepStrictEqual(tabs, ['c-apdu', 'scp80', 'pysim', 'profiler', 'phone']);
|
|
assert.match(html, /data-tab="c-apdu">Remote APDU</);
|
|
});
|
|
|
|
test('response parser is a Remote APDU pill', () => {
|
|
assert.match(html, /data-sub="response" onclick="cApduSwitchSubtab\('response'\)"/);
|
|
assert.ok(html.includes('id="c-apdu-sub-response"'));
|
|
});
|
|
|
|
test('profiler and phone simulator are top-level tab contents', () => {
|
|
assert.ok(html.includes('id="tab-profiler" class="tab-content hidden"'));
|
|
assert.ok(html.includes('id="tab-phone" class="tab-content hidden"'));
|
|
});
|
|
|
|
test('phone simulator has Phone / TR Config pills', () => {
|
|
assert.match(html, /data-phone-sub="phone" onclick="phoneSwitchSubtab\('phone'\)"/);
|
|
assert.match(html, /data-phone-sub="tr" onclick="phoneSwitchSubtab\('tr'\)"/);
|
|
assert.ok(html.includes('id="phone-sub-phone"'));
|
|
assert.ok(html.includes('id="phone-sub-tr"'));
|
|
});
|
|
|
|
test('scan name input starts scanning on Enter', () => {
|
|
assert.match(html, /id="profiler-scan-name"[^>]*onkeydown="profilerScanNameKeydown\(event\)"/);
|
|
});
|
|
|
|
test('snapshot view has a timing summary block', () => {
|
|
assert.ok(html.includes('id="snapshot-summary"'));
|
|
});
|