Skip to content

Commit

Permalink
release: v0.9.18
Browse files Browse the repository at this point in the history
  • Loading branch information
JairusSW committed Jul 23, 2024
1 parent 432efc9 commit b63f7fe
Show file tree
Hide file tree
Showing 25 changed files with 1,415 additions and 1,408 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github: [JairusSW]
github: [JairusSW]
9 changes: 4 additions & 5 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@ on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Install Wasmtime
uses: jcbhmr/setup-wasmtime@v2

- name: Setup Bun
uses: oven-sh/setup-bun@v1

- name: Install Dependencies
run: bun install

- name: Build Tests
run: bun run pretest

- name: Run Tests
run: bun run test
run: bun run test
4 changes: 2 additions & 2 deletions .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 16

- name: Install Wasmtime
uses: jcbhmr/setup-wasmtime@v2
Expand All @@ -22,7 +22,7 @@ jobs:
- name: Install dependencies
if: steps.node-cache.outputs.cache-hit != 'true'
run: yarn

- name: Build tests
run: yarn run tests:build

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ v0.9.14 - Ignore properties of type Function
v0.9.15 - Support JSON.Raw blocks
v0.9.16 - JSON.Raw should be completely untouched
v0.9.17 - A schema's parent's fields should be included properly
v0.9.18 - Should be able to use @alias and @omit*** or JSON.Raw

[UNRELEASED] v1.0.0
- Allow nullable primitives
Expand Down
94 changes: 27 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__| || __|| || | | ___ | _ || __|
| | ||__ || | || | | ||___|| ||__ |
|_____||_____||_____||_|___| |__|__||_____|
v0.9.17
v0.9.18
</pre>
</h5>

Expand Down Expand Up @@ -118,51 +118,13 @@ const serialized = JSON.stringify(arr);
const parsed = JSON.parse<Base[]>(serialized);
```

It also supports arbitrary-length integers with [@hypercubed/as-mpz](https://github.com/Hypercubed/as-mpz)

```js
import { MpZ } from "@hypercubed/as-mpz";

const a = MpZ.from(18448972);
const b = MpZ.from('7881297289452930');
const c = a.add(b);

const serialized = JSON.stringify(c);
// 7881297307901902
const parsed = JSON.parse<MpZ>(serialized);
```

It also supports nullable primitive types, something that AssemblyScript usually can't do

```js
@json
class Vec2 {
x: f64 | null = 1.0;
y: f32 | null = 2.0;
}

const vec: Vec2 = {
x: 1.0,
y: null
}

vec.y = 2.0;

if (vec.y) {
// do something
}
```

NOTE: There are a few quirks to using nullable primitives. First, you'll get a warning about usize (ignore it, its fine) and secondly, you'll get a wasm validation error if you do not have a `!` operator after accessing an element. Eg. `console.log(vec.y.toString())` fails, but `console.log(vec.y!.toString())` works.

You can also add it to your `asconfig.json`

{
// ...
"options": {
"transform": ["json-as/transform"],
"disableWarning": [226]
}
// ...
"options": {
"transform": ["json-as/transform"]
}
}

If you use this project in your codebase, consider dropping a [star](https://github.com/JairusSW/as-json). I would really appreciate it!
Expand All @@ -185,41 +147,39 @@ Run or view the benchmarks [here](https://github.com/JairusSW/as-json/tree/maste

Below are benchmark results comparing JavaScript's built-in JSON implementation and `JSON-AS`

My library beats JSON (written in C++) on all counts *and*, I see many places where I can pull at least a 60% uplift in performance if I implement it.
My library beats JSON (written in C++) on all counts _and_, I see many places where I can pull at least a 60% uplift in performance if I implement it.

Note: SIMD is in-development and only available on the `v1` branch on GitHub

Serialization Benchmarks:

| 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 |


| 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 |

Deserialization Benchmarks:

| Value | JavaScript (ops/s) | JSON-AS (ops/s) | Difference|
|----------------------------|--------------------|-----------------|-----------|
| "hello world" | 12,210,131 | 24,274,496 | + 98% |
| "12345" | 21,376,873 | 254,640,930 | + 1,191% |
| 1.2345 | 23,193,902 | 221,869,840 | + 987% |
| [[],[[]],[[],[[]]]] | 4,777,227 | 74,921,123 | + 1,568% |
| { x: f64, y: f64, z: f64 } | 10,973,723 | 25,214,019 | + 230% |
| Value | JavaScript (ops/s) | JSON-AS (ops/s) | Difference |
| -------------------------- | ------------------ | --------------- | ---------- |
| "hello world" | 12,210,131 | 24,274,496 | + 98% |
| "12345" | 21,376,873 | 254,640,930 | + 1,191% |
| 1.2345 | 23,193,902 | 221,869,840 | + 987% |
| [[],[[]],[[],[[]]]] | 4,777,227 | 74,921,123 | + 1,568% |
| { x: f64, y: f64, z: f64 } | 10,973,723 | 25,214,019 | + 230% |

And my PC specs:

| Component | Specification |
|-----------------|--------------------------------------|
| Wasmer Version | v4.3.0 |
| CPU | AMD Ryzen 7 7800x3D @ 6.00 GHz |
| Memory | T-Force DDR5 6000 MHz |
| OS | Ubuntu WSL2 |
| Component | Specification |
| -------------- | ------------------------------ |
| Wasmer Version | v4.3.0 |
| CPU | AMD Ryzen 7 7800x3D @ 6.00 GHz |
| Memory | T-Force DDR5 6000 MHz |
| OS | Ubuntu WSL2 |

## Issues

Please submit an issue to https://github.com/JairusSW/as-json/issues if you find anything wrong with this library
Please submit an issue to https://github.com/JairusSW/as-json/issues if you find anything wrong with this library
8 changes: 3 additions & 5 deletions as-test.config.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"input": [
"./assembly/__tests__/*.spec.ts"
],
"input": ["./assembly/__tests__/*.spec.ts"],
"outDir": "./build",
"config": "none",
"plugins": {
"coverage": false
},
"buildOptions": {
"args": [],
"args": ["--transform ./transform"],
"target": "wasi"
},
"runOptions": {
Expand All @@ -17,4 +15,4 @@
"run": "wasmtime <file>"
}
}
}
}
Loading

0 comments on commit b63f7fe

Please sign in to comment.