json-as 0.5.56 → 0.5.58
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.
- package/README.md +45 -29
- package/assembly/__tests__/as-json.spec.ts +1 -1
- package/assembly/src/json.ts +16 -16
- package/assembly/test.ts +3 -9
- package/bench/bench-node.js +17 -0
- package/bench/benchmark.ts +10 -156
- package/package.json +3 -2
- package/transform/package.json +1 -1
- package/bench-results/INTEGER-PARSING.md +0 -52
package/README.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# AS-JSON
|
|
2
2
|
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-
|
|
6
3
|
JSON for AssemblyScript focused on performance, low-overhead, and ease-of-use.
|
|
7
4
|
|
|
8
5
|
## Installation
|
|
@@ -21,6 +18,7 @@ Alternatively, add it to your `asconfig.json`
|
|
|
21
18
|
|
|
22
19
|
```
|
|
23
20
|
{
|
|
21
|
+
// ...
|
|
24
22
|
"options": {
|
|
25
23
|
"transform": ["json-as/transform"]
|
|
26
24
|
}
|
|
@@ -68,41 +66,59 @@ const stringified = JSON.stringify<Player>(player);
|
|
|
68
66
|
const parsed = JSON.parse<Player>(stringified);
|
|
69
67
|
```
|
|
70
68
|
|
|
69
|
+
If you use this project in your codebase, consider dropping a [star](https://github.com/JairusSW/as-json). I would really appreciate it!
|
|
71
70
|
## Performance
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
Run or view the benchmarks [here](https://github.com/JairusSW/as-json/tree/master/bench)
|
|
73
|
+
|
|
74
|
+
Below are benchmark results comparing JavaScript, WAVM (WebAssembly Virtual Machine), and Wasmtime environments.
|
|
75
|
+
|
|
76
|
+
JavaScript Results
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
NodeJS v20.5.1 - TinyBench v2.5.0 (V8)
|
|
80
|
+
┌───────────────────────────┬───────────────┐
|
|
81
|
+
│ Task Name │ ops / sec │
|
|
82
|
+
├───────────────────────────┼───────────────┤
|
|
83
|
+
│ 'Stringify Object (Vec3)' │ '1,191,221' │
|
|
84
|
+
│ 'Parse Object (Vec3)' │ '897,759' │
|
|
85
|
+
│ 'Stringify Number Array' │ '1,552,255' │
|
|
86
|
+
│ 'Parse Number Array' │ '1,225,325' │
|
|
87
|
+
│ 'Stringify String' │ '1,761,011' │
|
|
88
|
+
│ 'Parse String' │ '80,845' │
|
|
89
|
+
└───────────────────────────┴───────────────┘
|
|
90
|
+
```
|
|
75
91
|
|
|
76
|
-
|
|
92
|
+
AssemblyScript Results
|
|
77
93
|
|
|
78
|
-
JavaScript Results (TinyBench/NodeJS 19)
|
|
79
94
|
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
│
|
|
85
|
-
│
|
|
86
|
-
│
|
|
87
|
-
│
|
|
88
|
-
│
|
|
89
|
-
|
|
95
|
+
WAVM v0.0.0-prerelease - as-bench v0.0.0-alpha (LLVM)
|
|
96
|
+
┌───────────────────────────┬───────────────┐
|
|
97
|
+
│ Task Name │ ops / sec │
|
|
98
|
+
├───────────────────────────┼───────────────┤
|
|
99
|
+
│ 'Stringify Object (Vec3)' │ '6,270,322' │
|
|
100
|
+
│ 'Parse Object (Vec3)' │ '8,000,195' |
|
|
101
|
+
│ 'Stringify Number Array' │ '6,664,937' │
|
|
102
|
+
│ 'Parse Number Array' │ '6,557,357' │
|
|
103
|
+
│ 'Stringify String' │ '6,946,947' │
|
|
104
|
+
│ 'Parse String' │ '10,952,502' │
|
|
105
|
+
└───────────────────────────┴───────────────┘
|
|
90
106
|
```
|
|
91
107
|
|
|
92
|
-
AssemblyScript Results (Runtime Minimal)
|
|
93
108
|
```
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
│
|
|
99
|
-
│
|
|
100
|
-
│
|
|
101
|
-
│
|
|
102
|
-
│
|
|
103
|
-
|
|
109
|
+
Wasmtime v11.0.1 - as-bench v0.0.0-alpha (Cranelift)
|
|
110
|
+
┌───────────────────────────┬───────────────┐
|
|
111
|
+
│ Task Name │ ops / sec │
|
|
112
|
+
├───────────────────────────┼───────────────┤
|
|
113
|
+
│ 'Stringify Object (Vec3)' │ '2,038,684' │
|
|
114
|
+
│ 'Parse Object (Vec3)' │ '4,623,337' |
|
|
115
|
+
│ 'Stringify Number Array' │ '2,500,947' │
|
|
116
|
+
│ 'Parse Number Array' │ '2,959,180' │
|
|
117
|
+
│ 'Stringify String' │ '3,236,896' │
|
|
118
|
+
│ 'Parse String' │ '5,634,594' │
|
|
119
|
+
└───────────────────────────┴───────────────┘
|
|
104
120
|
```
|
|
105
121
|
|
|
106
122
|
## Issues
|
|
107
123
|
|
|
108
|
-
Please submit an issue to https://github.com/JairusSW/as-json/issues if you find anything wrong with this library
|
|
124
|
+
Please submit an issue to https://github.com/JairusSW/as-json/issues if you find anything wrong with this library
|
|
@@ -89,7 +89,7 @@ describe("Ser/de Array", () => {
|
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
it("should ser/de string arrays", () => {
|
|
92
|
-
canSerde<string[]>(['string \"with random spa\nces and \nnewlines\n\n\n']);
|
|
92
|
+
canSerde<string[]>(['string \"with random spa\nces and \nnewlines\n\n\n'], '["string \\"with random spa\\nces and \\nnewlines\\n\\n\\n"]');
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
it("should ser/de nested integer arrays", () => {
|
package/assembly/src/json.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
uCode,
|
|
22
22
|
emptyArrayWord,
|
|
23
23
|
falseWord,
|
|
24
|
+
newLineCode,
|
|
24
25
|
} from "./chars";
|
|
25
26
|
import { snip_fast, unsafeCharCodeAt } from "./util";
|
|
26
27
|
import { Virtual } from "as-virtual/assembly";
|
|
@@ -219,7 +220,7 @@ export namespace JSON {
|
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
// @ts-ignore: Decorator
|
|
222
|
-
@inline
|
|
223
|
+
@inline function serializeString(data: string): string {
|
|
223
224
|
let result = new StringSink('"');
|
|
224
225
|
|
|
225
226
|
let last: i32 = 0;
|
|
@@ -230,7 +231,6 @@ export namespace JSON {
|
|
|
230
231
|
result.write(<string>data, last, i);
|
|
231
232
|
result.writeCodePoint(backSlashCode);
|
|
232
233
|
last = i;
|
|
233
|
-
//i++;
|
|
234
234
|
} else if (char <= 13 && char >= 8) {
|
|
235
235
|
result.write(<string>data, last, i);
|
|
236
236
|
last = i + 1;
|
|
@@ -270,45 +270,45 @@ export namespace JSON {
|
|
|
270
270
|
|
|
271
271
|
// @ts-ignore: Decorator
|
|
272
272
|
@inline function parseString(data: string): string {
|
|
273
|
-
let result =
|
|
273
|
+
let result = new StringSink();
|
|
274
274
|
let last = 1;
|
|
275
275
|
for (let i = 1; i < data.length - 1; i++) {
|
|
276
276
|
// \\"
|
|
277
277
|
if (unsafeCharCodeAt(data, i) === backSlashCode) {
|
|
278
278
|
const char = unsafeCharCodeAt(data, ++i);
|
|
279
|
-
result
|
|
279
|
+
result.write(data, last, i - 1);
|
|
280
280
|
if (char === 34) {
|
|
281
|
-
result
|
|
281
|
+
result.writeCodePoint(quoteCode);
|
|
282
282
|
last = i + 1;
|
|
283
283
|
} else if (char >= 92 && char <= 117) {
|
|
284
284
|
switch (char) {
|
|
285
285
|
case 92: {
|
|
286
|
-
result
|
|
286
|
+
result.writeCodePoint(backSlashCode);
|
|
287
287
|
last = i + 1;
|
|
288
288
|
break;
|
|
289
289
|
}
|
|
290
290
|
case 98: {
|
|
291
|
-
result
|
|
291
|
+
result.write("\b");
|
|
292
292
|
last = i + 1;
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
295
|
case 102: {
|
|
296
|
-
result
|
|
296
|
+
result.write("\f");
|
|
297
297
|
last = i + 1;
|
|
298
298
|
break;
|
|
299
299
|
}
|
|
300
300
|
case 110: {
|
|
301
|
-
result
|
|
301
|
+
result.writeCodePoint(newLineCode);
|
|
302
302
|
last = i + 1;
|
|
303
303
|
break;
|
|
304
304
|
}
|
|
305
305
|
case 114: {
|
|
306
|
-
result
|
|
306
|
+
result.write("\r");
|
|
307
307
|
last = i + 1;
|
|
308
308
|
break;
|
|
309
309
|
}
|
|
310
310
|
case 116: {
|
|
311
|
-
result
|
|
311
|
+
result.write("\t");
|
|
312
312
|
last = i + 1;
|
|
313
313
|
break;
|
|
314
314
|
}
|
|
@@ -318,7 +318,7 @@ export namespace JSON {
|
|
|
318
318
|
load<u64>(changetype<usize>(data) + <usize>((i + 1) << 1)) ===
|
|
319
319
|
27584753879220272
|
|
320
320
|
) {
|
|
321
|
-
result
|
|
321
|
+
result.write("\u000b");
|
|
322
322
|
i += 4;
|
|
323
323
|
last = i + 1;
|
|
324
324
|
}
|
|
@@ -328,8 +328,8 @@ export namespace JSON {
|
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
|
|
332
|
-
return result;
|
|
331
|
+
if ((data.length - 1) > last) result.write(data, last, data.length - 1);
|
|
332
|
+
return result.toString();
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
// @ts-ignore: Decorator
|
|
@@ -340,7 +340,7 @@ export namespace JSON {
|
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
// @ts-ignore: Decorator
|
|
343
|
-
@inline
|
|
343
|
+
@inline function parseNumber<T>(data: string): T {
|
|
344
344
|
if (isInteger<T>()) {
|
|
345
345
|
// @ts-ignore
|
|
346
346
|
return snip_fast<T>(data);
|
|
@@ -596,7 +596,7 @@ export namespace JSON {
|
|
|
596
596
|
}
|
|
597
597
|
|
|
598
598
|
// @ts-ignore: Decorator
|
|
599
|
-
@inline
|
|
599
|
+
@inline function parseObjectArray<T extends unknown[]>(data: string): T {
|
|
600
600
|
const result = instantiate<T>();
|
|
601
601
|
let lastPos: u32 = 1;
|
|
602
602
|
let depth: u32 = 0;
|
package/assembly/test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bench, blackbox } from "
|
|
2
|
-
import { JSON
|
|
1
|
+
import { bench, blackbox } from "as-bench/assembly/bench";
|
|
2
|
+
import { JSON } from "./src/json";
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
@json
|
|
5
5
|
class Vec3 {
|
|
@@ -45,12 +45,6 @@ console.log("Implemented: " + JSON.stringify(JSON.parse<Vec3>('{"x":3.4,"y":1.2,
|
|
|
45
45
|
console.log("Original: " + JSON.stringify(player));
|
|
46
46
|
//console.log("Revised: " + vec.__JSON_Deserialize('{"x":3,"y":1,"z":8}').__JSON_Serialize());
|
|
47
47
|
console.log("Implemented: " + JSON.stringify(JSON.parse<Player>('{"firstName":"Emmet","lastName":"West","lastActive":[8,27,2022],"age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true}')));
|
|
48
|
-
|
|
49
|
-
console.log("Serialized String: " + serializeString('st"ring" w""ith quotes"'));
|
|
50
|
-
|
|
51
|
-
bench("New Stringify String", () => {
|
|
52
|
-
blackbox<string>(serializeString(blackbox<string>('st"ring" w""ith quotes"')));
|
|
53
|
-
});
|
|
54
48
|
/*
|
|
55
49
|
// 9,325,755
|
|
56
50
|
bench("Stringify Object (Vec3)", () => {
|
|
@@ -58,7 +52,7 @@ bench("Stringify Object (Vec3)", () => {
|
|
|
58
52
|
});
|
|
59
53
|
|
|
60
54
|
// 17,747,531 -> 55,517,015
|
|
61
|
-
|
|
55
|
+
bench("New Parse Object (Vec3)", () => {
|
|
62
56
|
blackbox<Vec3>(vec.__JSON_Deserialize(blackbox<string>('{"x":0,"y":0,"z":0}')));
|
|
63
57
|
});
|
|
64
58
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import { WASI } from "wasi";
|
|
3
|
+
import { argv, env } from 'node:process';
|
|
4
|
+
|
|
5
|
+
const wasm = readFileSync("./benchmark.wasm");
|
|
6
|
+
|
|
7
|
+
const wasi = new WASI({
|
|
8
|
+
version: 'preview1',
|
|
9
|
+
args: argv,
|
|
10
|
+
env,
|
|
11
|
+
preopens: {},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const mod = new WebAssembly.Module(wasm);
|
|
15
|
+
const instance = new WebAssembly.Instance(mod, wasi.getImportObject());
|
|
16
|
+
|
|
17
|
+
wasi.start(instance);
|
package/bench/benchmark.ts
CHANGED
|
@@ -1,158 +1,12 @@
|
|
|
1
|
-
import { bench, blackbox } from "
|
|
2
|
-
import { __atoi_fast
|
|
1
|
+
import { bench, blackbox } from "as-bench/assembly/bench";
|
|
2
|
+
import { __atoi_fast } from "../assembly/src/util";
|
|
3
3
|
import { JSON } from "../assembly";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
@json
|
|
6
6
|
class Vec3 {
|
|
7
7
|
x: i32;
|
|
8
8
|
y: i32;
|
|
9
9
|
z: i32;
|
|
10
|
-
@inline
|
|
11
|
-
__JSON_Serialize(): string {
|
|
12
|
-
return `{"x":${this.x.toString()},"y":${this.y.toString()},"z":${this.z.toString()}}`;
|
|
13
|
-
}
|
|
14
|
-
@inline
|
|
15
|
-
__JSON_Set_Key(key: string, value: string): void {
|
|
16
|
-
if (key == "x") {
|
|
17
|
-
this.x = ____parseObjectValue<i32>(value);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (key == "y") {
|
|
21
|
-
this.y = ____parseObjectValue<i32>(value);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (key == "z") {
|
|
25
|
-
this.z = ____parseObjectValue<i32>(value);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
@inline
|
|
30
|
-
__JSON_Deserialize(data: string): Vec3 {
|
|
31
|
-
let schema: nonnull<Vec3> = changetype<nonnull<Vec3>>(
|
|
32
|
-
__new(offsetof<nonnull<Vec3>>(), idof<nonnull<Vec3>>())
|
|
33
|
-
);
|
|
34
|
-
let key = "";
|
|
35
|
-
let isKey = false;
|
|
36
|
-
let depth = 0;
|
|
37
|
-
let outerLoopIndex = 1;
|
|
38
|
-
for (; outerLoopIndex < data.length - 1; outerLoopIndex++) {
|
|
39
|
-
const char = unsafeCharCodeAt(data, outerLoopIndex);
|
|
40
|
-
if (char === leftBracketCode) {
|
|
41
|
-
for (
|
|
42
|
-
let arrayValueIndex = outerLoopIndex;
|
|
43
|
-
arrayValueIndex < data.length - 1;
|
|
44
|
-
arrayValueIndex++
|
|
45
|
-
) {
|
|
46
|
-
const char = unsafeCharCodeAt(data, arrayValueIndex);
|
|
47
|
-
if (char === leftBracketCode) {
|
|
48
|
-
depth++;
|
|
49
|
-
} else if (char === rightBracketCode) {
|
|
50
|
-
depth--;
|
|
51
|
-
if (depth === 0) {
|
|
52
|
-
++arrayValueIndex;
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
schema.__JSON_Set_Key(
|
|
55
|
-
key,
|
|
56
|
-
data.slice(outerLoopIndex, arrayValueIndex)
|
|
57
|
-
);
|
|
58
|
-
outerLoopIndex = arrayValueIndex;
|
|
59
|
-
isKey = false;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
} else if (char === leftBraceCode) {
|
|
65
|
-
for (
|
|
66
|
-
let objectValueIndex = outerLoopIndex;
|
|
67
|
-
objectValueIndex < data.length - 1;
|
|
68
|
-
objectValueIndex++
|
|
69
|
-
) {
|
|
70
|
-
const char = unsafeCharCodeAt(data, objectValueIndex);
|
|
71
|
-
if (char === leftBraceCode) {
|
|
72
|
-
depth++;
|
|
73
|
-
} else if (char === rightBraceCode) {
|
|
74
|
-
depth--;
|
|
75
|
-
if (depth === 0) {
|
|
76
|
-
++objectValueIndex;
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
schema.__JSON_Set_Key(
|
|
79
|
-
key,
|
|
80
|
-
data.slice(outerLoopIndex, objectValueIndex)
|
|
81
|
-
);
|
|
82
|
-
outerLoopIndex = objectValueIndex;
|
|
83
|
-
isKey = false;
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
} else if (char === quoteCode) {
|
|
89
|
-
for (
|
|
90
|
-
let stringValueIndex = ++outerLoopIndex;
|
|
91
|
-
stringValueIndex < data.length - 1;
|
|
92
|
-
stringValueIndex++
|
|
93
|
-
) {
|
|
94
|
-
const char = unsafeCharCodeAt(data, stringValueIndex);
|
|
95
|
-
if (
|
|
96
|
-
char === quoteCode &&
|
|
97
|
-
unsafeCharCodeAt(data, stringValueIndex - 1) !== backSlashCode
|
|
98
|
-
) {
|
|
99
|
-
if (isKey === false) {
|
|
100
|
-
key = data.slice(outerLoopIndex, stringValueIndex);
|
|
101
|
-
isKey = true;
|
|
102
|
-
} else {
|
|
103
|
-
// @ts-ignore
|
|
104
|
-
schema.__JSON_Set_Key(
|
|
105
|
-
key,
|
|
106
|
-
data.slice(outerLoopIndex, stringValueIndex)
|
|
107
|
-
);
|
|
108
|
-
isKey = false;
|
|
109
|
-
}
|
|
110
|
-
outerLoopIndex = ++stringValueIndex;
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
} else if (char == nCode) {
|
|
115
|
-
// @ts-ignore
|
|
116
|
-
schema.__JSON_Set_Key(key, nullWord);
|
|
117
|
-
isKey = false;
|
|
118
|
-
} else if (
|
|
119
|
-
char === tCode &&
|
|
120
|
-
unsafeCharCodeAt(data, ++outerLoopIndex) === rCode &&
|
|
121
|
-
unsafeCharCodeAt(data, ++outerLoopIndex) === uCode &&
|
|
122
|
-
unsafeCharCodeAt(data, ++outerLoopIndex) === eCode
|
|
123
|
-
) {
|
|
124
|
-
// @ts-ignore
|
|
125
|
-
schema.__JSON_Set_Key(key, trueWord);
|
|
126
|
-
isKey = false;
|
|
127
|
-
} else if (
|
|
128
|
-
char === fCode &&
|
|
129
|
-
unsafeCharCodeAt(data, ++outerLoopIndex) === "a".charCodeAt(0) &&
|
|
130
|
-
unsafeCharCodeAt(data, ++outerLoopIndex) === "l".charCodeAt(0) &&
|
|
131
|
-
unsafeCharCodeAt(data, ++outerLoopIndex) === "s".charCodeAt(0) &&
|
|
132
|
-
unsafeCharCodeAt(data, ++outerLoopIndex) === eCode
|
|
133
|
-
) {
|
|
134
|
-
// @ts-ignore
|
|
135
|
-
schema.__JSON_Set_Key(key, "false");
|
|
136
|
-
isKey = false;
|
|
137
|
-
} else if ((char >= 48 && char <= 57) || char === 45) {
|
|
138
|
-
let numberValueIndex = ++outerLoopIndex;
|
|
139
|
-
for (; numberValueIndex < data.length; numberValueIndex++) {
|
|
140
|
-
const char = unsafeCharCodeAt(data, numberValueIndex);
|
|
141
|
-
if (char === commaCode || char === rightBraceCode || isSpace(char)) {
|
|
142
|
-
// @ts-ignore
|
|
143
|
-
schema.__JSON_Set_Key(
|
|
144
|
-
key,
|
|
145
|
-
data.slice(outerLoopIndex - 1, numberValueIndex)
|
|
146
|
-
);
|
|
147
|
-
outerLoopIndex = numberValueIndex;
|
|
148
|
-
isKey = false;
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return schema;
|
|
155
|
-
}
|
|
156
10
|
}
|
|
157
11
|
|
|
158
12
|
const vec: Vec3 = {
|
|
@@ -172,13 +26,13 @@ bench("Parse Number ATOI", () => {
|
|
|
172
26
|
bench("Parse Number STDLIB", () => {
|
|
173
27
|
blackbox<i32>(i32.parse("12345"));
|
|
174
28
|
});
|
|
175
|
-
|
|
29
|
+
*/
|
|
176
30
|
bench("Stringify Object (Vec3)", () => {
|
|
177
|
-
blackbox<string>(
|
|
178
|
-
})
|
|
31
|
+
blackbox<string>(JSON.stringify(vec));
|
|
32
|
+
});
|
|
179
33
|
|
|
180
34
|
bench("Parse Object (Vec3)", () => {
|
|
181
|
-
blackbox<Vec3>(
|
|
35
|
+
blackbox<Vec3>(JSON.parse<Vec3>('{"x":0,"y":0,"z":0}'));
|
|
182
36
|
});
|
|
183
37
|
|
|
184
38
|
bench("Stringify Number Array", () => {
|
|
@@ -196,11 +50,11 @@ bench("Stringify String", () => {
|
|
|
196
50
|
bench("Parse String", () => {
|
|
197
51
|
blackbox<string>(JSON.parse<string>(blackbox('"Hello "World!"')));
|
|
198
52
|
});
|
|
199
|
-
|
|
53
|
+
/*
|
|
200
54
|
bench("Stringify Boolean Array", () => {
|
|
201
55
|
blackbox(JSON.stringify<boolean[]>([true, false, true]));
|
|
202
56
|
});
|
|
203
57
|
|
|
204
58
|
bench("Stringify String Array", () => {
|
|
205
59
|
blackbox(JSON.stringify<string[]>(["a", "b", "c"]));
|
|
206
|
-
})
|
|
60
|
+
});*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-as",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.58",
|
|
4
4
|
"description": "JSON encoder/decoder for AssemblyScript",
|
|
5
5
|
"types": "assembly/index.ts",
|
|
6
6
|
"author": "Jairus Tanaka",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@as-pect/cli": "^8.0.1",
|
|
32
32
|
"@as-tral/cli": "^2.0.1",
|
|
33
33
|
"@assemblyscript/wasi-shim": "^0.1.0",
|
|
34
|
+
"as-bench": "^0.0.0-alpha",
|
|
34
35
|
"assemblyscript": "^0.27.9",
|
|
35
36
|
"assemblyscript-prettier": "^2.0.2",
|
|
36
37
|
"benchmark": "^2.1.4",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"as-string-sink": "^0.5.3",
|
|
46
47
|
"as-variant": "^0.4.1",
|
|
47
|
-
"as-virtual": "^0.1.
|
|
48
|
+
"as-virtual": "^0.1.9"
|
|
48
49
|
},
|
|
49
50
|
"repository": {
|
|
50
51
|
"type": "git",
|
package/transform/package.json
CHANGED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# Comparison between integer parsing algorithms
|
|
2
|
-
|
|
3
|
-
SNIP: 261M iterations over 5000ms
|
|
4
|
-
ATOI: 285M iterations over 5000ms
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
### Log
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
yarn run v1.22.19
|
|
11
|
-
$ astral -Ospeed --noAssert --uncheckedBehavior always --runtime stub
|
|
12
|
-
Compiling assembly/__benches__/as-json.ts
|
|
13
|
-
|
|
14
|
-
Benchmarking Parse Number SNIP: Warming up for 3000ms
|
|
15
|
-
Benchmarking Parse Number SNIP: Collecting 100 samples in estimated 5000ms (261M iterations)
|
|
16
|
-
Benchmarking Parse Number SNIP: Analyzing
|
|
17
|
-
Parse Number SNIP time: [18.146ns 18.381ns 18.624ns]
|
|
18
|
-
change: [-13.073% -10.614% -8.1347%] (p = 0.00 < 0.05)
|
|
19
|
-
Performance has improved.
|
|
20
|
-
Found 9 outliers among 100 measurements (9%)
|
|
21
|
-
8 (8%) high mild
|
|
22
|
-
1 (1%) high severe
|
|
23
|
-
|
|
24
|
-
Benchmarking Parse Number ATOI: Warming up for 3000ms
|
|
25
|
-
Benchmarking Parse Number ATOI: Collecting 100 samples in estimated 5000ms (285M iterations)
|
|
26
|
-
Benchmarking Parse Number ATOI: Analyzing
|
|
27
|
-
Parse Number ATOI time: [16.962ns 17.219ns 17.501ns]
|
|
28
|
-
change: [-3.5659% -0.8496% +2.0516%] (p = 0.00 < 0.05)
|
|
29
|
-
Change within noise threshold.
|
|
30
|
-
Found 7 outliers among 100 measurements (7%)
|
|
31
|
-
2 (2%) high mild
|
|
32
|
-
5 (5%) high severe
|
|
33
|
-
|
|
34
|
-
Benchmarking Parse Number STDLIB: Warming up for 3000ms
|
|
35
|
-
Benchmarking Parse Number STDLIB: Collecting 100 samples in estimated 5000ms (176M iterations)
|
|
36
|
-
Benchmarking Parse Number STDLIB: Analyzing
|
|
37
|
-
Parse Number STDLIB time: [28.298ns 28.763ns 29.383ns]
|
|
38
|
-
change: [-3.3724% -1.5367% +0.1796%] (p = 0.00 < 0.05)
|
|
39
|
-
Change within noise threshold.
|
|
40
|
-
Found 5 outliers among 100 measurements (5%)
|
|
41
|
-
3 (3%) high mild
|
|
42
|
-
2 (2%) high severe
|
|
43
|
-
|
|
44
|
-
Benchmarking Parse Number OLD: Warming up for 3000ms
|
|
45
|
-
Benchmarking Parse Number OLD: Collecting 100 samples in estimated 5000ms (171M iterations)
|
|
46
|
-
Benchmarking Parse Number OLD: Analyzing
|
|
47
|
-
Parse Number OLD time: [28.888ns 29.341ns 29.804ns]
|
|
48
|
-
change: [-2.123% -0.5458% +1.1939%] (p = 0.00 < 0.05)
|
|
49
|
-
Change within noise threshold.
|
|
50
|
-
Found 3 outliers among 100 measurements (3%)
|
|
51
|
-
3 (3%) high mild
|
|
52
|
-
```
|