json-as 0.5.57 → 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 +5 -7
- package/assembly/test.ts +3 -22
- package/bench/benchmark.ts +1 -1
- package/package.json +1 -1
- package/transform/package.json +1 -1
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,12 +66,12 @@ 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
|
-
I took the benchmarks using the stub runtime which doesn't call the Garbage Collector, so you may expect a 10% to 40% decrease from low to high throughput.
|
|
72
|
+
Run or view the benchmarks [here](https://github.com/JairusSW/as-json/tree/master/bench)
|
|
75
73
|
|
|
76
|
-
|
|
74
|
+
Below are benchmark results comparing JavaScript, WAVM (WebAssembly Virtual Machine), and Wasmtime environments.
|
|
77
75
|
|
|
78
76
|
JavaScript Results
|
|
79
77
|
|
|
@@ -123,4 +121,4 @@ Wasmtime v11.0.1 - as-bench v0.0.0-alpha (Cranelift)
|
|
|
123
121
|
|
|
124
122
|
## Issues
|
|
125
123
|
|
|
126
|
-
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
|
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,25 +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
|
-
console.log("Parsed Array: " + JSON.stringify(parseStringArray('["st\\"ring\\" w\\"\\"ith quotes\\""]')));
|
|
51
|
-
console.log("Parsed Array: " + JSON.stringify(parseStringArrayVirtual('["st\\"ring\\" w\\"\\"ith quotes\\""]')));
|
|
52
|
-
bench("New Stringify String", () => {
|
|
53
|
-
blackbox<string>(serializeString(blackbox<string>('st"ring" w""ith quotes"')));
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
bench("New Parse String", () => {
|
|
57
|
-
blackbox<string>(parseString(blackbox<string>('"st\\"ring\\" w\\"\\"ith quotes\\""')))
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
bench("Old Parse String Array", () => {
|
|
61
|
-
blackbox<string[]>(parseStringArray('["st\\"ring\\" w\\"\\"ith quotes\\""]'));
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
bench("New Parse String Array", () => {
|
|
65
|
-
blackbox<string[]>(parseStringArrayVirtual('["st\\"ring\\" w\\"\\"ith quotes\\""]'));
|
|
66
|
-
});
|
|
67
48
|
/*
|
|
68
49
|
// 9,325,755
|
|
69
50
|
bench("Stringify Object (Vec3)", () => {
|
|
@@ -71,7 +52,7 @@ bench("Stringify Object (Vec3)", () => {
|
|
|
71
52
|
});
|
|
72
53
|
|
|
73
54
|
// 17,747,531 -> 55,517,015
|
|
74
|
-
|
|
55
|
+
bench("New Parse Object (Vec3)", () => {
|
|
75
56
|
blackbox<Vec3>(vec.__JSON_Deserialize(blackbox<string>('{"x":0,"y":0,"z":0}')));
|
|
76
57
|
});
|
|
77
58
|
|
package/bench/benchmark.ts
CHANGED
package/package.json
CHANGED