Skip to content

Commit

Permalink
release: v0.9.9
Browse files Browse the repository at this point in the history
  • Loading branch information
JairusSW committed Jul 2, 2024
1 parent 44510e5 commit a975aad
Show file tree
Hide file tree
Showing 12 changed files with 18,480 additions and 5,665 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__| || __|| || | | ___ | _ || __|
| | ||__ || | || | | ||___|| ||__ |
|_____||_____||_____||_|___| |__|__||_____|
v0.9.8b
v0.9.9
</pre>
</h5>

Expand Down Expand Up @@ -190,13 +190,13 @@ My library beats JSON (written in C++) on all counts *and*, I see many places wh

Serialization Benchmarks:

| Value | JavaScript (ops/s) | JSON-as (ops/s) | Difference |
|----------------------------|--------------------|-----------------|------------|
| "hello world" | 28,629,598 | 64,210,666 | + 124% |
| 12345 | 31,562,431 | 56,329,066 | + 78% |
| 1.2345 | 15,977,278 | 20,322,939 | + 27% |
| [[],[[]],[[],[[]]]] | 8,998,624 | 34,453,102 | + 283% |
| { x: f64, y: f64, z: f64 } | 15,583,686 | 17,604,821 | + 12% |
| Value | JavaScript (ops/s) | JSON-AS (ops/s) | JSON-AS (Pages) | JSON-AS (SIMD+Pages)| Max Throughput |
|----------------------------|--------------------|--------------------|---------------------|---------------------|----------------|
| "hello world" | 7,124,361 | 44,290,480 (6.2x) | 73,601,235 (10.3x) | NOT IMPLEMENTED | 1.91 GB/s |
| 12345 | 9,611,677 | 66,900,642 (6.9x) | 145,924,333 (15.2x) | NOT IMPLEMENTED | 0.58 GB/s |
| 1.2345 | 7,227,259 | 20,322,939 (2.8x) | NOT IMPLEMENTED | NOT IMPLEMENTED | 0.16 GB/s |
| [[],[[]],[[],[[]]]] | 5,655,429 | 34,453,102 (6.0x) | NOT IMPLEMENTED | NOT IMPLEMENTED | 1.32 GB/s |
| { 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 |



Expand Down
43 changes: 35 additions & 8 deletions assembly/test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
import { JSON } from "json-as/assembly";
import * as console from "as-console";
import { JSON } from ".";

@json
class Yo {
map: Map<string, u64>;
class TokenMetaData {
id: u64;
name: string;
uri: string;

constructor(id: u64, name: string, uri: string) {
this.id = id;
this.name = name;
this.uri = uri;
}
}

@json
class NonFungibleToken {
owner: string;
counter: u64;
tokens: Map<u64, TokenMetaData>;
owners: Map<u64, string>;
balances: Map<string, u64[]>;
constructor() {
this.map = new Map();
this.owner = "";
this.counter = 0;
this.tokens = new Map<u64, TokenMetaData>();
this.owners = new Map<u64, string>();
this.balances = new Map<string, u64[]>();
}
}

let y = new Yo();
y.map.set("bhavya", 3000);
console.log(JSON.stringify(y));

let state = JSON.parse<NonFungibleToken>(
'"{"owner":"","counter":0,"tokens":{},"owners":{},"balances":{}}"'
);
// let state = new NonFungibleToken();

if (!state.balances.has("bhavya")) {
state.balances.set("bhavya", []);
}
console.log(JSON.stringify(state))
Binary file modified build/test.spec.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion build/test.spec.wasm.map

Large diffs are not rendered by default.

75 changes: 71 additions & 4 deletions build/test.spec.wat
Original file line number Diff line number Diff line change
Expand Up @@ -69943,13 +69943,13 @@
(func $assembly/__tests__/types/DerivedObject#__INITIALIZE (param $0 i32) (result i32)
(local $1 i32)
global.get $~lib/memory/__stack_pointer
i32.const 4
i32.const 8
i32.sub
global.set $~lib/memory/__stack_pointer
call $~stack_check
global.get $~lib/memory/__stack_pointer
i32.const 0
i32.store
i64.const 0
i64.store
i32.const 19248
local.set $1
global.get $~lib/memory/__stack_pointer
Expand All @@ -69960,7 +69960,33 @@
local.get $0
local.set $1
global.get $~lib/memory/__stack_pointer
i32.const 4
local.get $1
i32.store
local.get $1
i32.const 832
local.set $1
global.get $~lib/memory/__stack_pointer
local.get $1
i32.store offset=4
local.get $1
call $assembly/__tests__/types/BaseObject#set:a
local.get $0
local.set $1
global.get $~lib/memory/__stack_pointer
local.get $1
i32.store
local.get $1
i32.const 832
local.set $1
global.get $~lib/memory/__stack_pointer
local.get $1
i32.store offset=4
local.get $1
call $assembly/__tests__/types/DerivedObject#set:b
local.get $0
local.set $1
global.get $~lib/memory/__stack_pointer
i32.const 8
i32.add
global.set $~lib/memory/__stack_pointer
local.get $1
Expand Down Expand Up @@ -78878,6 +78904,47 @@
local.get $1
i32.store
local.get $1
i32.const 832
local.set $1
global.get $~lib/memory/__stack_pointer
local.get $1
i32.store offset=4
local.get $1
call $assembly/__tests__/types/Player#set:firstName
local.get $0
local.set $1
global.get $~lib/memory/__stack_pointer
local.get $1
i32.store
local.get $1
i32.const 832
local.set $1
global.get $~lib/memory/__stack_pointer
local.get $1
i32.store offset=4
local.get $1
call $assembly/__tests__/types/Player#set:lastName
local.get $0
local.set $1
global.get $~lib/memory/__stack_pointer
local.get $1
i32.store
local.get $1
i32.const 0
i32.const 0
call $~lib/array/Array<i32>#constructor
local.set $1
global.get $~lib/memory/__stack_pointer
local.get $1
i32.store offset=4
local.get $1
call $assembly/__tests__/types/Player#set:lastActive
local.get $0
local.set $1
global.get $~lib/memory/__stack_pointer
local.get $1
i32.store
local.get $1
i32.const 24
i32.const 39
call $~lib/rt/itcms/__new
Expand Down
Binary file modified build/test.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion build/test.wasm.map

Large diffs are not rendered by default.

Loading

0 comments on commit a975aad

Please sign in to comment.