json-as 0.9.8-b → 0.9.9

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  __| || __|| || | | ___ | _ || __|
4
4
  | | ||__ || | || | | ||___|| ||__ |
5
5
  |_____||_____||_____||_|___| |__|__||_____|
6
- v0.9.8b
6
+ v0.9.9
7
7
  </pre>
8
8
  </h5>
9
9
 
@@ -190,13 +190,13 @@ My library beats JSON (written in C++) on all counts *and*, I see many places wh
190
190
 
191
191
  Serialization Benchmarks:
192
192
 
193
- | Value | JavaScript (ops/s) | JSON-as (ops/s) | Difference |
194
- |----------------------------|--------------------|-----------------|------------|
195
- | "hello world" | 28,629,598 | 64,210,666 | + 124% |
196
- | 12345 | 31,562,431 | 56,329,066 | + 78% |
197
- | 1.2345 | 15,977,278 | 20,322,939 | + 27% |
198
- | [[],[[]],[[],[[]]]] | 8,998,624 | 34,453,102 | + 283% |
199
- | { x: f64, y: f64, z: f64 } | 15,583,686 | 17,604,821 | + 12% |
193
+ | Value | JavaScript (ops/s) | JSON-AS (ops/s) | JSON-AS (Pages) | JSON-AS (SIMD+Pages)| Max Throughput |
194
+ |----------------------------|--------------------|--------------------|---------------------|---------------------|----------------|
195
+ | "hello world" | 7,124,361 | 44,290,480 (6.2x) | 73,601,235 (10.3x) | NOT IMPLEMENTED | 1.91 GB/s |
196
+ | 12345 | 9,611,677 | 66,900,642 (6.9x) | 145,924,333 (15.2x) | NOT IMPLEMENTED | 0.58 GB/s |
197
+ | 1.2345 | 7,227,259 | 20,322,939 (2.8x) | NOT IMPLEMENTED | NOT IMPLEMENTED | 0.16 GB/s |
198
+ | [[],[[]],[[],[[]]]] | 5,655,429 | 34,453,102 (6.0x) | NOT IMPLEMENTED | NOT IMPLEMENTED | 1.32 GB/s |
199
+ | { x: f64, y: f64, z: f64 } | 3,878,604 | 44,557,996 (11.5x) | 113,203,242 (29.2x) | 172,023,231 (44.4x) | 8.61 GB/s |
200
200
 
201
201
 
202
202
 
package/assembly/test.ts CHANGED
@@ -1,14 +1,41 @@
1
- import { JSON } from "json-as/assembly";
2
- import * as console from "as-console";
1
+ import { JSON } from ".";
2
+
3
3
  @json
4
- class Yo {
5
- map: Map<string, u64>;
4
+ class TokenMetaData {
5
+ id: u64;
6
+ name: string;
7
+ uri: string;
8
+
9
+ constructor(id: u64, name: string, uri: string) {
10
+ this.id = id;
11
+ this.name = name;
12
+ this.uri = uri;
13
+ }
14
+ }
6
15
 
16
+ @json
17
+ class NonFungibleToken {
18
+ owner: string;
19
+ counter: u64;
20
+ tokens: Map<u64, TokenMetaData>;
21
+ owners: Map<u64, string>;
22
+ balances: Map<string, u64[]>;
7
23
  constructor() {
8
- this.map = new Map();
24
+ this.owner = "";
25
+ this.counter = 0;
26
+ this.tokens = new Map<u64, TokenMetaData>();
27
+ this.owners = new Map<u64, string>();
28
+ this.balances = new Map<string, u64[]>();
9
29
  }
10
30
  }
11
31
 
12
- let y = new Yo();
13
- y.map.set("bhavya", 3000);
14
- console.log(JSON.stringify(y));
32
+
33
+ let state = JSON.parse<NonFungibleToken>(
34
+ '"{"owner":"","counter":0,"tokens":{},"owners":{},"balances":{}}"'
35
+ );
36
+ // let state = new NonFungibleToken();
37
+
38
+ if (!state.balances.has("bhavya")) {
39
+ state.balances.set("bhavya", []);
40
+ }
41
+ console.log(JSON.stringify(state))
Binary file