json-as 1.2.0 → 1.2.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -1
  3. package/.github/FUNDING.yml +0 -1
  4. package/.github/dependabot.yml +0 -11
  5. package/.github/workflows/benchmark.yml +0 -72
  6. package/.github/workflows/release-package.yml +0 -47
  7. package/.github/workflows/tests.yml +0 -25
  8. package/.prettierignore +0 -9
  9. package/.prettierrc.json +0 -7
  10. package/.trunk/configs/.markdownlint.yaml +0 -2
  11. package/.trunk/configs/.shellcheckrc +0 -7
  12. package/.trunk/configs/.yamllint.yaml +0 -7
  13. package/.trunk/trunk.yaml +0 -37
  14. package/CHANGELOG.md +0 -330
  15. package/SECURITY.md +0 -32
  16. package/asconfig.json +0 -7
  17. package/assembly/__benches__/abc.bench.ts +0 -28
  18. package/assembly/__benches__/large.bench.ts +0 -238
  19. package/assembly/__benches__/lib/bench.ts +0 -85
  20. package/assembly/__benches__/medium.bench.ts +0 -128
  21. package/assembly/__benches__/small.bench.ts +0 -46
  22. package/assembly/__benches__/throughput.ts +0 -172
  23. package/assembly/__benches__/vec3.bench.ts +0 -37
  24. package/assembly/__tests__/arbitrary.spec.ts +0 -35
  25. package/assembly/__tests__/array.spec.ts +0 -145
  26. package/assembly/__tests__/bool.spec.ts +0 -12
  27. package/assembly/__tests__/box.spec.ts +0 -27
  28. package/assembly/__tests__/custom.spec.ts +0 -56
  29. package/assembly/__tests__/date.spec.ts +0 -36
  30. package/assembly/__tests__/enum.spec.ts +0 -35
  31. package/assembly/__tests__/float.spec.ts +0 -42
  32. package/assembly/__tests__/generics.spec.ts +0 -49
  33. package/assembly/__tests__/hierarchy.spec.ts +0 -61
  34. package/assembly/__tests__/integer.spec.ts +0 -26
  35. package/assembly/__tests__/lib/index.ts +0 -41
  36. package/assembly/__tests__/map.spec.ts +0 -7
  37. package/assembly/__tests__/namespace.spec.ts +0 -63
  38. package/assembly/__tests__/null.spec.ts +0 -12
  39. package/assembly/__tests__/raw.spec.ts +0 -23
  40. package/assembly/__tests__/resolving.spec.ts +0 -55
  41. package/assembly/__tests__/staticarray.spec.ts +0 -12
  42. package/assembly/__tests__/string.spec.ts +0 -30
  43. package/assembly/__tests__/struct.spec.ts +0 -163
  44. package/assembly/__tests__/test.spec.ts +0 -3
  45. package/assembly/__tests__/types.spec.ts +0 -27
  46. package/assembly/__tests__/types.ts +0 -98
  47. package/assembly/test.tmp.ts +0 -133
  48. package/bench/abc.bench.ts +0 -25
  49. package/bench/large.bench.ts +0 -127
  50. package/bench/lib/bench.d.ts +0 -27
  51. package/bench/lib/bench.js +0 -53
  52. package/bench/lib/chart.ts +0 -217
  53. package/bench/medium.bench.ts +0 -68
  54. package/bench/runners/assemblyscript.js +0 -34
  55. package/bench/small.bench.ts +0 -34
  56. package/bench/throughput.ts +0 -87
  57. package/bench/tsconfig.json +0 -13
  58. package/bench/vec3.bench.ts +0 -30
  59. package/bench.ts +0 -18
  60. package/ci/bench/lib/bench.ts +0 -42
  61. package/ci/bench/runners/assemblyscript.js +0 -29
  62. package/ci/run-bench.as.sh +0 -63
  63. package/publish.sh +0 -78
  64. package/run-bench.as.sh +0 -60
  65. package/run-bench.js.sh +0 -36
  66. package/run-tests.sh +0 -51
  67. package/scripts/build-chart01.ts +0 -38
  68. package/scripts/build-chart02.ts +0 -38
  69. package/scripts/build-chart03.ts +0 -139
  70. package/scripts/build-chart05.ts +0 -47
  71. package/scripts/generate-as-class.ts +0 -50
  72. package/scripts/lib/bench-utils.ts +0 -308
  73. package/transform/src/builder.ts +0 -1375
  74. package/transform/src/index.ts +0 -1486
  75. package/transform/src/linkers/alias.ts +0 -58
  76. package/transform/src/linkers/custom.ts +0 -32
  77. package/transform/src/linkers/imports.ts +0 -22
  78. package/transform/src/types.ts +0 -300
  79. package/transform/src/util.ts +0 -128
  80. package/transform/src/visitor.ts +0 -530
@@ -1,133 +0,0 @@
1
- import {
2
- JSON
3
- } from ".";
4
- import {
5
- bs
6
- } from "../lib/as-bs";
7
- import {
8
- expect
9
- } from "./__tests__/lib";
10
- import {
11
- serializeString_SIMD
12
- } from "./serialize/simd/string";
13
- import {
14
- serializeString_SWAR
15
- } from "./serialize/swar/string";
16
- @lazy
17
- const ONES: u64 = 72340172838076673;
18
- @lazy
19
- const HIGHS: u64 = -9187201950435737472;
20
- @lazy
21
- const LANE_MASK_LOW: u64 = 71777214294589695;
22
- @inline
23
- function json_escapable_byte_mask(x: u64): u64 {
24
- x = x ^ -71777214294589696;
25
- const is_ascii: u64 = HIGHS & ~x;
26
- const xor2: u64 = x ^ 144680345676153346;
27
- const lt32_or_eq34: u64 = xor2 - 2387225703656530209;
28
- const sub92: u64 = x ^ 6655295901103053916;
29
- const eq92: u64 = sub92 - ONES;
30
- const high_bits: u64 = (lt32_or_eq34 | eq92) & is_ascii;
31
- return high_bits;
32
- }
33
- function to_u64(s: string): u64 {
34
- return load<u64>(changetype<usize>(s));
35
- }
36
- export function mask_to_string(mask: u64): string {
37
- let result = "0x";
38
- for (let i = 7; i >= 0; i--) {
39
- const byte = u8((mask >> (i * 8)) & 255);
40
- const hi = (byte >> 4) & 15;
41
- const lo = byte & 15;
42
- result += hi < 10 ? String.fromCharCode(48 + hi) : String.fromCharCode(55 + hi);
43
- result += lo < 10 ? String.fromCharCode(48 + lo) : String.fromCharCode(55 + lo);
44
- result += " ";
45
- }
46
- return result;
47
- }
48
- function test_mask(input: string, expected_mask: u64, description: string): void {
49
- const mask = json_escapable_byte_mask(to_u64(input));
50
- const pass = mask == expected_mask;
51
- console.log((pass ? "✓ " : "✗ ") + description);
52
- if (!pass) {
53
- console.log(" Input: \"" + input + "\"");
54
- console.log(" Expected: " + mask_to_string(expected_mask));
55
- console.log(" Got: " + mask_to_string(mask));
56
- process.exit(1);
57
- }
58
- }
59
- console.log("=== No Escapes Needed ===");
60
- test_mask("abcd", 0, "Regular ASCII letters");
61
- test_mask("ABCD", 0, "Uppercase letters");
62
- test_mask("1234", 0, "Numbers");
63
- test_mask("test", 0, "Common word");
64
- test_mask("____", 0, "Underscores");
65
- test_mask("....", 0, "Periods");
66
- test_mask("!#$%", 0, "Safe symbols");
67
- test_mask("&*()", 0, "More symbols");
68
- test_mask("+,-.", 0, "Math symbols");
69
- console.log();
70
- console.log("=== Quote Character (34 / 0x22) ===");
71
- test_mask("\"abc", 128, "Quote at position 0");
72
- test_mask("a\"bc", 8388608, "Quote at position 1");
73
- test_mask("ab\"c", 549755813888, "Quote at position 2");
74
- test_mask("abc\"", 36028797018963968, "Quote at position 3");
75
- test_mask("\"\"\"\"", 36029346783166592, "All quotes");
76
- console.log();
77
- console.log("=== Backslash Character (92 / 0x5C) ===");
78
- test_mask("\babc", 128, "Backslash at position 0");
79
- test_mask("a\bbc", 8388608, "Backslash at position 1");
80
- test_mask("ab\bc", 549755813888, "Backslash at position 2");
81
- test_mask("abc\b", 36028797018963968, "Backslash at position 3");
82
- test_mask("\b\b\b\b", 36029346783166592, "All backslashes");
83
- console.log();
84
- console.log("=== Control Characters (< 32) ===");
85
- test_mask("\0abc", 128, "Null character at position 0");
86
- test_mask("\nabc", 128, "Newline at position 0");
87
- test_mask("\rabc", 128, "Carriage return at position 0");
88
- test_mask("\tabc", 128, "Tab at position 0");
89
- test_mask("a\nbc", 8388608, "Newline at position 1");
90
- test_mask("ab\nc", 549755813888, "Newline at position 2");
91
- test_mask("abc\n", 36028797018963968, "Newline at position 3");
92
- console.log();
93
- console.log("=== Boundary Cases ===");
94
- test_mask("abc", 128, "Character 31 (should escape)");
95
- test_mask(" abc", 0, "Space (32, should NOT escape)");
96
- test_mask("!abc", 0, "Character 33 (should NOT escape)");
97
- console.log();
98
- console.log("=== Mixed Scenarios ===");
99
- test_mask("\"\nabc", 128 | 8388608, "Quote + newline");
100
- test_mask("\"\babc", 128 | 8388608, "Quote + backslash");
101
- test_mask("\"\b\nabc", 128 | 8388608 | 549755813888, "Quote + backslash + newline");
102
- test_mask("a\"\tb", 8388608 | 549755813888, "Quote + tab at pos 1-2");
103
- console.log();
104
- console.log("=== Multiple Escapes ===");
105
- test_mask("\"\"\b\b", 8388736 | 36029346774777856, "All 4 positions need escape");
106
- test_mask("a\"b\b", 8388608 | 36028797018963968, "Quote at pos 1, backslash at pos 3");
107
- test_mask("\"a\bb", 128 | 549755813888, "Quote at pos 0, backslash at pos 2");
108
- console.log();
109
- console.log("=== Edge Cases ===");
110
- test_mask("", 36029346783166592, "All control characters (1-4)");
111
- test_mask(" ", 128 | 8388608, "Characters 30-31, then two spaces");
112
- test_mask("]}~", 0, "High safe ASCII (125-127)");
113
- console.log();
114
- console.log("=== Specific JSON Escape Sequences ===");
115
- test_mask("\f\n\r", 36029346783166592, "Backspace, form feed, newline, carriage return");
116
- test_mask("\"\b\f", 36029346783166592, "Quote, backslash, backspace, form feed");
117
- console.log();
118
- function get_lane(mask: u64): u64 {
119
- return ctz(mask) >> 3;
120
- }
121
- function clearLane(mask: u64, lane_index: u32): u64 {
122
- return mask & ~(255 << (lane_index << 3));
123
- }
124
- expect(get_lane(128)).toBe(0);
125
- expect(get_lane(8388608)).toBe(2);
126
- expect(get_lane(549755813888)).toBe(4);
127
- expect(get_lane(36028797018963968)).toBe(6);
128
- let x: u64 = 36029346783166592;
129
- expect(get_lane(x = clearLane(x, 0))).toBe(2);
130
- expect(get_lane(x = clearLane(x, 2))).toBe(4);
131
- expect(get_lane(x = clearLane(x, 4))).toBe(6);
132
- serializeString_SWAR("\0\t\n\v\f\rabcdefg");
133
- expect(bs.out<string>()).toBe("\"\bu0000\bu0001\bu0002\bu0003\bu0004\bu0005\bu0006\bu0007\bb\bt\bn\bu000b\bf\br\bu000eabcdefg\"");
@@ -1,25 +0,0 @@
1
- import { dumpToFile } from "./lib/bench.js";
2
- import { bench, blackbox } from "./lib/bench.js";
3
-
4
- const v1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
5
- const v2 = '"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"';
6
-
7
- bench(
8
- "Serialize Alphabet",
9
- () => {
10
- blackbox(JSON.stringify(v1));
11
- },
12
- 64_000_00,
13
- v1.length << 1,
14
- );
15
- dumpToFile("abc", "serialize")
16
-
17
- bench(
18
- "Deserialize Alphabet",
19
- () => {
20
- blackbox(JSON.parse(v2));
21
- },
22
- 64_000_00,
23
- v2.length << 1,
24
- );
25
- dumpToFile("abc", "deserialize")
@@ -1,127 +0,0 @@
1
- import { bench, blackbox, dumpToFile } from "./lib/bench.js";
2
-
3
- class RepoOwner {
4
- login: string = "octocat";
5
- id: number = 583231;
6
- node_id: string = "MDQ6VXNlcjU4MzIzMQ==";
7
- avatar_url: string = "https://avatars.githubusercontent.com/u/583231?v=4";
8
- gravatar_id: string = "";
9
- url: string = "https://api.github.com/users/octocat";
10
- html_url: string = "https://github.com/octocat";
11
- followers_url: string = "https://api.github.com/users/octocat/followers";
12
- following_url: string = "https://api.github.com/users/octocat/following{/other_user}";
13
- gists_url: string = "https://api.github.com/users/octocat/gists{/gist_id}";
14
- starred_url: string = "https://api.github.com/users/octocat/starred{/owner}{/repo}";
15
- subscriptions_url: string = "https://api.github.com/users/octocat/subscriptions";
16
- organizations_url: string = "https://api.github.com/users/octocat/orgs";
17
- repos_url: string = "https://api.github.com/users/octocat/repos";
18
- events_url: string = "https://api.github.com/users/octocat/events{/privacy}";
19
- received_events_url: string = "https://api.github.com/users/octocat/received_events";
20
- type: string = "User";
21
- user_view_type: string = "public";
22
- site_admin: boolean = false;
23
- }
24
-
25
- class RepoLicense {
26
- key: string = "";
27
- name: string = "";
28
- spdx_id: string = "";
29
- url: string | null = null;
30
- node_id: string = "";
31
- }
32
-
33
- class Repo {
34
- id: number = 132935648;
35
- node_id: string = "MDEwOlJlcG9zaXRvcnkxMzI5MzU2NDg=";
36
- name: string = "boysenberry-repo-1";
37
- full_name: string = "octocat/boysenberry-repo-1";
38
- private: boolean = true;
39
- owner: RepoOwner = new RepoOwner();
40
- html_url: string = "https://github.com/octocat/boysenberry-repo-1";
41
- description: string | null = "Testing";
42
- fork: boolean = true;
43
- url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1";
44
- forks_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/forks";
45
- keys_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/keys{/key_id}";
46
- collaborators_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/collaborators{/collaborator}";
47
- teams_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/teams";
48
- hooks_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/hooks";
49
- issue_events_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/issues/events{/number}";
50
- events_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/events";
51
- assignees_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/assignees{/user}";
52
- branches_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/branches{/branch}";
53
- tags_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/tags";
54
- blobs_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/git/blobs{/sha}";
55
- git_tags_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/git/tags{/sha}";
56
- git_refs_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/git/refs{/sha}";
57
- trees_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/git/trees{/sha}";
58
- statuses_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/statuses/{sha}";
59
- languages_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/languages";
60
- stargazers_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/stargazers";
61
- contributors_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/contributors";
62
- subscribers_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/subscribers";
63
- subscription_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/subscription";
64
- commits_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/commits{/sha}";
65
- git_commits_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/git/commits{/sha}";
66
- comments_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/comments{/number}";
67
- issue_comment_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/issues/comments{/number}";
68
- contents_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/contents/{+path}";
69
- compare_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/compare/{base}...{head}";
70
- merges_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/merges";
71
- archive_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/{archive_format}{/ref}";
72
- downloads_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/downloads";
73
- issues_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/issues{/number}";
74
- pulls_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/pulls{/number}";
75
- milestones_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/milestones{/number}";
76
- notifications_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/notifications{?since,all,participating}";
77
- labels_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/labels{/name}";
78
- releases_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/releases{/id}";
79
- deployments_url: string = "https://api.github.com/repos/octocat/boysenberry-repo-1/deployments";
80
- created_at: string = "2018-05-10T17:51:29Z";
81
- updated_at: string = "2025-05-24T02:01:19Z";
82
- pushed_at: string = "2024-05-26T07:02:05Z";
83
- git_url: string = "git://github.com/octocat/boysenberry-repo-1.git";
84
- ssh_url: string = "git@github.com:octocat/boysenberry-repo-1.git";
85
- clone_url: string = "https://github.com/octocat/boysenberry-repo-1.git";
86
- svn_url: string = "https://github.com/octocat/boysenberry-repo-1";
87
- homepage: string | null = "";
88
- size: number = 4;
89
- stargazers_count: number = 332;
90
- watchers_count: number = 332;
91
- language: string | null = null;
92
- has_issues: boolean = false;
93
- has_projects: boolean = true;
94
- has_downloads: boolean = true;
95
- has_wiki: boolean = true;
96
- has_pages: boolean = false;
97
- has_discussions: boolean = false;
98
- forks_count: number = 20;
99
- mirror_url: string | null = null;
100
- archived: boolean = false;
101
- disabled: boolean = false;
102
- open_issues_count: number = 1;
103
- license: RepoLicense | null = null;
104
- allow_forking: boolean = true;
105
- is_template: boolean = false;
106
- web_commit_signoff_required: boolean = false;
107
- topics: string[] = [];
108
- visibility: string = "public";
109
- forks: number = 20;
110
- open_issues: number = 1;
111
- watchers: number = 332;
112
- default_branch: string = "master";
113
- }
114
-
115
- const v1 = new Repo();
116
-
117
- const v2 = `{"id":132935648,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI5MzU2NDg=","name":"boysenberry-repo-1","full_name":"octocat/boysenberry-repo-1","private":true,"owner":{"login":"octocat","id":583231,"node_id":"MDQ6VXNlcjU4MzIzMQ==","avatar_url":"https://avatars.githubusercontent.com/u/583231?v=4","gravatar_id":"","url":"https://api.github.com/users/octocat","html_url":"https://github.com/octocat","followers_url":"https://api.github.com/users/octocat/followers","following_url":"https://api.github.com/users/octocat/following{/other_user}","gists_url":"https://api.github.com/users/octocat/gists{/gist_id}","starred_url":"https://api.github.com/users/octocat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octocat/subscriptions","organizations_url":"https://api.github.com/users/octocat/orgs","repos_url":"https://api.github.com/users/octocat/repos","events_url":"https://api.github.com/users/octocat/events{/privacy}","received_events_url":"https://api.github.com/users/octocat/received_events","type":"User","user_view_type":"public","site_admin":false},"html_url":"https://github.com/octocat/boysenberry-repo-1","description":"Testing","fork":true,"url":"https://api.github.com/repos/octocat/boysenberry-repo-1","forks_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/forks","keys_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/teams","hooks_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/hooks","issue_events_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/issues/events{/number}","events_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/events","assignees_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/assignees{/user}","branches_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/branches{/branch}","tags_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/tags","blobs_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/statuses/{sha}","languages_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/languages","stargazers_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/stargazers","contributors_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/contributors","subscribers_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/subscribers","subscription_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/subscription","commits_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/contents/{+path}","compare_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/merges","archive_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/downloads","issues_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/issues{/number}","pulls_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/pulls{/number}","milestones_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/milestones{/number}","notifications_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/labels{/name}","releases_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/releases{/id}","deployments_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/deployments","created_at":"2018-05-10T17:51:29Z","updated_at":"2025-05-24T02:01:19Z","pushed_at":"2024-05-26T07:02:05Z","git_url":"git://github.com/octocat/boysenberry-repo-1.git","ssh_url":"git@github.com:octocat/boysenberry-repo-1.git","clone_url":"https://github.com/octocat/boysenberry-repo-1.git","svn_url":"https://github.com/octocat/boysenberry-repo-1","homepage":"","size":4,"stargazers_count":332,"watchers_count":332,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"has_discussions":false,"forks_count":20,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":null,"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":20,"open_issues":1,"watchers":332,"default_branch":"master"}`;
118
-
119
- bench("Serialize Large API Response", () => {
120
- blackbox(JSON.stringify(v1));
121
- }, 100_000, 10502);
122
- dumpToFile("large", "serialize")
123
-
124
- bench("Deserialize Large API Response", () => {
125
- blackbox(JSON.parse(v2));
126
- }, 100_000, 10502);
127
- dumpToFile("large", "deserialize")
@@ -1,27 +0,0 @@
1
- /**
2
- * Benchmark a routine under V8.
3
- *
4
- * @param description Human-readable benchmark name
5
- * @param routine Function to benchmark (must be side-effect safe)
6
- * @param ops Number of operations to execute (default: 1,000,000)
7
- * @param bytesPerOp Bytes processed per operation (used for MB/s reporting)
8
- */
9
- export function bench(
10
- description: string,
11
- routine: () => void,
12
- ops?: number,
13
- bytesPerOp?: number
14
- ): void;
15
-
16
- /**
17
- * Prevents V8 from optimizing away a value.
18
- *
19
- * This relies on the V8 intrinsic %PerformMicrotaskCheckpoint and therefore
20
- * only works under d8 / V8 with --allow-natives-syntax.
21
- *
22
- * @param x Value to blackbox
23
- * @returns The same value
24
- */
25
- export function blackbox<T>(x: T): T;
26
-
27
- export function dumpToFile(suite: string, type: string): void;
@@ -1,53 +0,0 @@
1
- let result = {};
2
- export function bench(description, routine, ops = 1_000_000, bytesPerOp = 0) {
3
- console.log(" - Benchmarking " + description);
4
- let warmup = Math.floor(ops / 10);
5
- while (warmup-- > 0) {
6
- routine();
7
- }
8
- const start = performance.now();
9
- let count = ops;
10
- while (count-- > 0) {
11
- routine();
12
- }
13
- const end = performance.now();
14
- const elapsed = Math.max(1, end - start);
15
- const opsPerSecond = (ops * 1000) / elapsed;
16
- let log = ` Completed benchmark in ${formatNumber(Math.round(elapsed))}ms at ${formatNumber(Math.round(opsPerSecond))} ops/s`;
17
- let mbPerSec = 0;
18
- if (bytesPerOp > 0) {
19
- const totalBytes = bytesPerOp * ops;
20
- mbPerSec = totalBytes / (elapsed / 1000) / (1000 * 1000);
21
- log += ` @ ${formatNumber(Math.round(mbPerSec))}MB/s`;
22
- }
23
- result = {
24
- language: "javascript",
25
- description,
26
- elapsed,
27
- bytes: bytesPerOp,
28
- operations: ops,
29
- features: [],
30
- mbps: mbPerSec
31
- };
32
- console.log(log + "\n");
33
- }
34
- export function dumpToFile(suite, type) {
35
- writeFile("./build/logs/js/" + suite+"."+type+".js.json", JSON.stringify(result));
36
- }
37
- function formatNumber(n) {
38
- let str = n.toString();
39
- let len = str.length;
40
- let result = "";
41
- let commaOffset = len % 3;
42
- for (let i = 0; i < len; i++) {
43
- if (i > 0 && (i - commaOffset) % 3 === 0)
44
- result += ",";
45
- result += str.charAt(i);
46
- }
47
- return result;
48
- }
49
-
50
- export function blackbox(x) {
51
- %PerformMicrotaskCheckpoint();
52
- return x;
53
- }
@@ -1,217 +0,0 @@
1
- // chartplot.ts (Bun/ESNext compatible)
2
- import { readFileSync, writeFileSync } from "fs";
3
- import { basename } from "path";
4
-
5
- type RawBench = {
6
- description: string;
7
- elapsed: number; // ms
8
- bytes: number; // bytes per operation
9
- operations: number;
10
- features: string[];
11
- };
12
-
13
- type BenchmarkResult = {
14
- library: string;
15
- payload: string; // e.g., "small", "medium", "large", "abc", "vec3"
16
- gbPerSec: number;
17
- };
18
-
19
- type ChartData = {
20
- title: string;
21
- payloads: string[]; // ordered list of payload names
22
- results: BenchmarkResult[];
23
- };
24
-
25
- if (import.meta.main) {
26
- const args = process.argv.slice(2);
27
- if (!args.length) {
28
- console.error(
29
- "Usage:\n bun ./chartplot.ts <bench1.json> <bench2.json> [...] [-o output.svg]"
30
- );
31
- process.exit(1);
32
- }
33
-
34
- let outputFile = "benchmark-chart.svg";
35
- const inputFiles: string[] = [];
36
-
37
- for (let i = 0; i < args.length; i++) {
38
- if (args[i] === "-o") {
39
- if (i + 1 >= args.length) {
40
- console.error("Error: -o requires a filename");
41
- process.exit(1);
42
- }
43
- outputFile = args[++i];
44
- } else {
45
- inputFiles.push("./build/logs/" +args[i]);
46
- }
47
- }
48
-
49
- if (!inputFiles.length) {
50
- console.error("Error: no input files provided");
51
- process.exit(1);
52
- }
53
-
54
- generateBarChartFromFiles(inputFiles, outputFile);
55
- }
56
-
57
- function generateBarChartFromFiles(files: string[], outputFile: string) {
58
- const results: BenchmarkResult[] = [];
59
-
60
- for (const file of files) {
61
- const raw: RawBench = JSON.parse(readFileSync(file, "utf-8"));
62
- const impl = inferImplementation(file);
63
- const payload = inferPayload(file);
64
-
65
- const gbPerSec = (raw.bytes * raw.operations) / (raw.elapsed * 1e6);
66
-
67
- results.push({ library: impl, payload, gbPerSec });
68
- }
69
-
70
- // Group by payload and sort payloads logically
71
- const payloadOrder = ["abc", "vec3", "small", "medium", "large"];
72
- const uniquePayloads = [...new Set(results.map(r => r.payload))].sort(
73
- (a, b) => payloadOrder.indexOf(a) - payloadOrder.indexOf(b)
74
- );
75
-
76
- const uniqueLibraries = [...new Set(results.map(r => r.library))];
77
- const colors = ["#3b82f6", "#10b981", "#f59e0b", "#ef4444", "#8b5cf6"];
78
-
79
- const chart: ChartData = {
80
- title: "JSON Throughput by Payload Size",
81
- payloads: uniquePayloads,
82
- results,
83
- };
84
-
85
- const svg = generateGroupedBarSVG(chart, uniqueLibraries, colors);
86
- writeFileSync(outputFile, svg, "utf-8");
87
- console.log(`✅ Bar chart written to ${outputFile}`);
88
- }
89
-
90
- function inferImplementation(file: string): string {
91
- return basename(file)
92
- .replace(".log.json", "")
93
- .replace(/\.bench\./g, " ")
94
- .replace(/\./g, " ")
95
- .trim();
96
- }
97
-
98
- function inferPayload(file: string): string {
99
- const name = basename(file);
100
- if (name.includes("abc.bench")) return "abc";
101
- if (name.includes("vec3.bench")) return "vec3";
102
- if (name.includes("small.bench")) return "small";
103
- if (name.includes("medium.bench")) return "medium";
104
- if (name.includes("large.bench")) return "large";
105
- return "unknown";
106
- }
107
-
108
- function generateGroupedBarSVG(
109
- data: ChartData,
110
- libraries: string[],
111
- colors: string[]
112
- ): string {
113
- const width = 900;
114
- const height = 550;
115
- const padding = { top: 80, right: 200, bottom: 80, left: 80 };
116
- const chartWidth = width - padding.left - padding.right;
117
- const chartHeight = height - padding.top - padding.bottom;
118
-
119
- const barPadding = 0.1; // space between groups
120
- const groupWidth = chartWidth / data.payloads.length;
121
- const barWidth = groupWidth / libraries.length * (1 - barPadding);
122
-
123
- const allValues = data.results.map(r => r.gbPerSec);
124
- const yMax = Math.max(...allValues, 0.1) * 1.1;
125
-
126
- const yScale = (v: number) =>
127
- padding.top + chartHeight - (v / yMax) * chartHeight;
128
-
129
- let svg = `<?xml version="1.0" encoding="UTF-8"?>
130
- <svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg">
131
- <defs>
132
- <style>
133
- .title { font: bold 20px sans-serif; fill: #1f2937; }
134
- .axis-label { font: 14px sans-serif; fill: #374151; }
135
- .tick { font: 12px sans-serif; fill: #6b7280; }
136
- .grid { stroke: #e5e7eb; stroke-dasharray: 3,3; }
137
- .axis { stroke: #9ca3af; stroke-width: 1.5; }
138
- .bar-label { font: bold 11px sans-serif; fill: white; text-anchor: middle; }
139
- .legend-text { font: 13px sans-serif; fill: #374151; }
140
- </style>
141
- </defs>
142
-
143
- <rect width="${width}" height="${height}" fill="#fff"/>
144
-
145
- <!-- Title -->
146
- <text x="${width / 2}" y="40" text-anchor="middle" class="title">
147
- ${data.title}
148
- </text>
149
-
150
- <!-- Y Axis Grid & Labels -->
151
- `;
152
- for (let i = 0; i <= 8; i++) {
153
- const v = (yMax / 8) * i;
154
- const y = yScale(v);
155
- svg += `
156
- <line x1="${padding.left}" y1="${y}" x2="${width - padding.right}" y2="${y}" class="grid"/>
157
- <text x="${padding.left - 10}" y="${y + 4}" text-anchor="end" class="tick">
158
- ${v.toFixed(2)} GB/s
159
- </text>`;
160
- }
161
-
162
- // X Axis Labels (Payloads)
163
- data.payloads.forEach((payload, i) => {
164
- const x = padding.left + groupWidth * (i + 0.5);
165
- svg += `<text x="${x}" y="${height - padding.bottom + 40}" text-anchor="middle" class="tick">
166
- ${payload.toUpperCase()}
167
- </text>`;
168
- });
169
-
170
- // Axes
171
- svg += `
172
- <line x1="${padding.left}" y1="${padding.top}" x2="${padding.left}" y2="${height - padding.bottom}" class="axis"/>
173
- <line x1="${padding.left}" y1="${height - padding.bottom}" x2="${width - padding.right}" y2="${height - padding.bottom}" class="axis"/>
174
-
175
- <text x="${width / 2}" y="${height - 20}" text-anchor="middle" class="axis-label">
176
- Payload Type
177
- </text>
178
- <text x="-${height / 2}" y="20" transform="rotate(-90)" text-anchor="middle" class="axis-label">
179
- Throughput (GB/s)
180
- </text>
181
- `;
182
-
183
- // Bars
184
- data.payloads.forEach((payload, payloadIdx) => {
185
- const groupX = padding.left + groupWidth * payloadIdx;
186
-
187
- libraries.forEach((lib, libIdx) => {
188
- const result = data.results.find(r => r.payload === payload && r.library === lib);
189
- if (!result) return;
190
-
191
- const x = groupX + (libIdx + 0.1) * (groupWidth / libraries.length);
192
- const barHeight = chartHeight - yScale(result.gbPerSec);
193
- const y = yScale(result.gbPerSec);
194
-
195
- const color = colors[libIdx % colors.length];
196
-
197
- svg += `<rect x="${x}" y="${y}" width="${barWidth}" height="${barHeight}" fill="${color}" rx="4"/>
198
- <text x="${x + barWidth / 2}" y="${y + 16}" class="bar-label">
199
- ${result.gbPerSec.toFixed(2)}
200
- </text>`;
201
- });
202
- });
203
-
204
- // Legend
205
- libraries.forEach((lib, i) => {
206
- const y = padding.top + i * 30;
207
- const color = colors[i % colors.length];
208
- svg += `
209
- <rect x="${width - padding.right + 20}" y="${y - 10}" width="18" height="18" fill="${color}" rx="4"/>
210
- <text x="${width - padding.right + 50}" y="${y + 5}" class="legend-text">
211
- ${lib}
212
- </text>`;
213
- });
214
-
215
- return svg + "</svg>";
216
- }
217
- // bun ./bench/lib/chart.ts abc.bench.incremental.simd.as.log.json vec3.bench.incremental.simd.as.log.json small.bench.incremental.simd.as.log.json medium.bench.incremental.simd.as.log.json large.bench.incremental.simd.as.log.json -o throughput-comparison.svg
@@ -1,68 +0,0 @@
1
- import { bench, blackbox, dumpToFile } from "./lib/bench.js";
2
-
3
- class UserPreferences {
4
- theme: string = "dark";
5
- notifications: boolean = true;
6
- language: string = "en-US";
7
- timezone: string = "America/Los_Angeles";
8
- privacy_level: string = "friends_only";
9
- two_factor_enabled: boolean = false;
10
- }
11
-
12
- class RecentActivity {
13
- action: string = "";
14
- timestamp: string = "";
15
- target: string = "";
16
- }
17
-
18
- class MediumAPIResponse {
19
- id: number = 42;
20
- username: string = "jairus";
21
- full_name: string = "Jairus Tanaka";
22
- email: string = "me@jairus.dev";
23
- avatar_url: string = "https://avatars.githubusercontent.com/u/123456?v=4";
24
- bio: string = "I like compilers, elegant algorithms, bare metal, simd, and wasm.";
25
- website: string = "https://jairus.dev/";
26
- location: string = "Seattle, WA";
27
- joined_at: string = "2020-01-15T08:30:00Z";
28
- is_verified: boolean = true;
29
- is_premium: boolean = true;
30
- follower_count: number = 61;
31
- following_count: number = 39;
32
-
33
- preferences: UserPreferences = new UserPreferences();
34
-
35
- tags: string[] = ["typescript", "webassembly", "performance", "rust", "assemblyscript", "json"];
36
-
37
- recent_activity: RecentActivity[] = [
38
- { action: "starred", timestamp: "2025-12-22T10:15:00Z", target: "assemblyscript/json-as" },
39
- { action: "commented", timestamp: "2025-12-22T09:42:00Z", target: "issue #142" },
40
- { action: "pushed", timestamp: "2025-12-21T23:58:00Z", target: "main branch" },
41
- { action: "forked", timestamp: "2025-12-21T18:20:00Z", target: "fast-json-wasm" },
42
- { action: "created", timestamp: "2025-12-21T14:10:00Z", target: "new benchmark suite" },
43
- ];
44
- }
45
-
46
- const v1 = new MediumAPIResponse();
47
-
48
- const v2 = JSON.stringify(v1);
49
-
50
- bench(
51
- "Serialize Medium API Response",
52
- () => {
53
- blackbox(JSON.stringify(v1));
54
- },
55
- 500_000,
56
- v2.length << 1
57
- );
58
- dumpToFile("medium", "serialize")
59
-
60
- bench(
61
- "Deserialize Medium API Response",
62
- () => {
63
- blackbox(JSON.parse(v2));
64
- },
65
- 500_000,
66
- v2.length << 1
67
- );
68
- dumpToFile("medium", "deserialize")