diff options
| author | eunhhu <[email protected]> | 2026-10-18 16:44:17 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-10-18 16:44:17 +0100 |
| commit | 241016b0fc3139414089619f0ef8cb7237722c6c (patch) | |
| tree | b782ed50757ee910278c8d1129dcfc7ded48d527 /tests | |
| parent | 433f56c29b26b83cd2991b4a834b427fae3e75d4 (diff) | |
| download | pure-241016b0fc3139414089619f0ef8cb7237722c6c.tar.gz pure-241016b0fc3139414089619f0ef8cb7237722c6c.zip | |
Research 140, 027's stage 2c measured: JSON read into a tree by recursive descent (aup's examples/json_tree.aup: value(d, i) -> Json, number giving the value and where it ends, each call's own let's lists, string's escapes joined by char(u), a depth-first walk passing items as values) against Python's reading walked so: JSONTestSuite's 95 y_ taken alike, no n_ taken, 2b's 6 i_ taken (a lone surrogate refused by char as encoding); 100,000 and 50,000 deep refused as memory (the frames fill the event's room, 0.2 s), 30,000 deep taken (past Python's json); 300 random documents alike; in make check (module_specs' digest now depth first, three paths); 142 lines against the same design's 105 in Python (json_rec.py; the bar missed: 24 lines of declarations, 23 of braces), 46 times cJSON's time and 1.6 times plain Python's (600 ns a byte, 248 Pure instructions; 71% in the steps, about 10% in calls, 66,000 calls a document, most of them small block fns like skip); characters against Python's ord in aup's check; probes: p5-chars compiles, p4-rec (a view calling itself) refused; instruction counts: the workloads' modules the same, batches within 0.001% of 2b (BFS -0.21%), the executor alone -0.001% to +0.30%, the bank's queries -0.30% to +0.11% (four runs each; bar 1%); json_rec_time.c (cJSON, a depth-first digest compared first); CHECKPOINT's direction row through 2c
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/check.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/tests/check.py b/tests/check.py index 9386ced..ed2a5c9 100644 --- a/tests/check.py +++ b/tests/check.py @@ -1738,17 +1738,17 @@ def module_specs(aup, pure, work): assert accepted == (name[0] == 'y') or name[0] == 'i', (name, accepted) taken[name[0]] += accepted runs['json'] = {'cases': len(cases), 'taken': taken} - # A JSON text read into a tree of values (its examples/json_tree.aup, 027's 2b: a variant, lists in records, match), - # walked breadth first for a digest, against Python's reading walked so: JSONTestSuite's cases and random documents. + # A JSON text read into a tree of values by recursive descent (its examples/json_tree.aup, 027's 2b and 2c: a + # variant, lists in records, match, fns that call themselves), walked depth first for a digest, against Python's + # reading walked so: JSONTestSuite's cases and random documents. class Pairs(list): pass def digest(data): doc = json.loads(data.decode('utf-8'), object_pairs_hook=Pairs) d = dict(nulls=0, trues=0, falses=0, numbers=0, strings=0, arrays=0, objects=0, sum=0.0, text_bytes=0, key_bytes=0) - q, at = [doc], 0 - while at < len(q): - x = q[at] + + def walk(x): if x is None: d['nulls'] += 1 elif x is True: d['trues'] += 1 elif x is False: d['falses'] += 1 @@ -1756,9 +1756,11 @@ def module_specs(aup, pure, work): elif isinstance(x, str): d['strings'] += 1; d['text_bytes'] += len(x.encode('utf-8')) elif isinstance(x, Pairs): d['objects'] += 1 - for k, v in x: d['key_bytes'] += len(k.encode('utf-8')); q.append(v) - else: d['arrays'] += 1; q.extend(x) - at += 1 + for k, v in x: d['key_bytes'] += len(k.encode('utf-8')); walk(v) + else: + d['arrays'] += 1 + for y in x: walk(y) + walk(doc) return d def value(depth): |
