diff options
| author | Theofilos Augoustis <theofilos.augoustis@gmail.com> | 2023-12-26 19:57:40 +0100 |
|---|---|---|
| committer | Theofilos Augoustis <theofilos.augoustis@gmail.com> | 2023-12-26 19:57:40 +0100 |
| commit | aab6b5969717b192555147b2e4fce86323c5f83c (patch) | |
| tree | 19af9fb33d42fd9d58fd525b04b483acd781c96c /parser.py | |
| parent | 194f3d6f2ebdc7b0631fdaaeb8451142b052ccb0 (diff) | |
| download | focaccia-aab6b5969717b192555147b2e4fce86323c5f83c.tar.gz focaccia-aab6b5969717b192555147b2e4fce86323c5f83c.zip | |
Improve SparseMemory.write_memory performance
Reduce overhead of handling sparse memory
Diffstat (limited to '')
| -rw-r--r-- | parser.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/parser.py b/parser.py index d2fcf13..19fb7c2 100644 --- a/parser.py +++ b/parser.py @@ -1,5 +1,6 @@ """Parsing of JSON files containing snapshot data.""" +import base64 import json import re from typing import TextIO @@ -29,7 +30,7 @@ def parse_snapshots(json_stream: TextIO) -> list[ProgramState]: state.set(reg, val) for mem in _get_or_throw(snapshot, 'memory'): start, end = _get_or_throw(mem, 'range') - data = _get_or_throw(mem, 'data').encode() + data = base64.b64decode(_get_or_throw(mem, 'data')) assert(len(data) == end - start) state.write_memory(start, data) @@ -51,7 +52,7 @@ def serialize_snapshots(snapshots: list[ProgramState], out_stream: TextIO): for addr, data in snapshot.mem._pages.items(): mem.append({ 'range': [addr, addr + len(data)], - 'data': data.decode(), + 'data': base64.b64encode(data).decode('ascii') }) res['snapshots'].append({ 'registers': regs, 'memory': mem }) |