snapshots: measure SELECT / READ commands and show timing stats
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.
This commit is contained in:
+11
-3
@@ -277,15 +277,22 @@ Read file content. Auto-detects transparent vs record files.
|
||||
|
||||
Returns transparent data:
|
||||
```json
|
||||
{"success": true, "sw": "9000", "file_type": "transparent", "data": "..."}
|
||||
{"success": true, "sw": "9000", "file_type": "transparent", "data": "...",
|
||||
"apdu_times": [{"type": "select", "ms": 12}, {"type": "read_binary", "ms": 9}]}
|
||||
```
|
||||
|
||||
Returns records:
|
||||
```json
|
||||
{"success": true, "sw": "9000", "file_type": "linear_fixed",
|
||||
"records": [{"num": 1, "data": "..."}, {"num": 2, "data": "..."}]}
|
||||
"records": [{"num": 1, "data": "..."}, {"num": 2, "data": "..."}],
|
||||
"apdu_times": [{"type": "select", "ms": 12},
|
||||
{"type": "read_record", "ms": 11}, {"type": "read_record", "ms": 13}]}
|
||||
```
|
||||
|
||||
`apdu_times` reports each command's duration (command sent to response
|
||||
received) classified as `select`, `read_binary` or `read_record`; the PWA uses
|
||||
it for snapshot timing statistics. Other commands are not reported.
|
||||
|
||||
### `POST /api/write`
|
||||
|
||||
Write raw hex data to a file.
|
||||
@@ -316,7 +323,8 @@ Returns:
|
||||
```json
|
||||
{"name": "EF.ICCID", "fid": "2FE2", "file_type": "transparent",
|
||||
"file_size": 10, "record_len": null, "num_of_rec": null,
|
||||
"fci_hex": "621082024021...", "exists": true}
|
||||
"fci_hex": "621082024021...",
|
||||
"apdu_times": [{"type": "select", "ms": 12}], "exists": true}
|
||||
```
|
||||
|
||||
`fci_hex` is the raw FCP template (`'62'`) from the SELECT response, used by
|
||||
|
||||
Reference in New Issue
Block a user