Skip to content

Commit

Permalink
release: v0.9.28
Browse files Browse the repository at this point in the history
  • Loading branch information
JairusSW committed Jan 14, 2025
1 parent 0e85c90 commit 6853212
Show file tree
Hide file tree
Showing 5 changed files with 1,068 additions and 75 deletions.
83 changes: 15 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
<h5 align="center">
<pre> __ _____ _____ _____ _____ _____
__| || __|| || | | ___ | _ || __|
| | ||__ || | || | | ||___|| ||__ |
|_____||_____||_____||_|___| |__|__||_____|
v0.9.27
</pre>
<pre>
<span style="font-size: 0.8em;"> ██ ███████ ██████ ███ ██ █████ ███████
██ ██ ██ ██ ████ ██ ██ ██ ██
██ ███████ ██ ██ ██ ██ ██ █████ ███████ ███████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
█████ ███████ ██████ ██ ████ ██ ██ ███████
</span>
AssemblyScript - v0.9.28
</pre>
</h5>

## Installation

```bash
npm install json-as
npm install json-as visitor-as
```

Add the transform to your `asc` command (e.g. in package.json)
Add the `--transform` to your `asc` command (e.g. in package.json)

```bash
--transform json-as/transform
```

Alternatively, add it to your `asconfig.json`

```
```json
{
// ...
"options": {
Expand Down Expand Up @@ -107,69 +110,13 @@ const serialized = JSON.stringify(arr);
const parsed = JSON.parse<Base[]>(serialized);
```

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

```json
{
// ...
"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!

## Notes

If you want a feature, drop an issue (and again, maybe a star). I'll likely add it in less than 7 days.

## Contact

Contact me at:

Email: `[email protected]`
GitHub: `JairusSW`
Discord: `jairussw`

## Performance

Run or view the benchmarks [here](https://github.com/JairusSW/as-json/tree/master/bench)

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.

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 |

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

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 |
- [Email](mailto:[email protected])
- [GitHub](https://github.com/JairusSW)
- [Discord](discord.com/users/600700584038760448)

## Issues

Expand Down
7 changes: 2 additions & 5 deletions assembly/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ export namespace JSON {
* @param data T
* @returns string
*/
// @ts-ignore: Decorator
@inline export function stringify<T>(data: T/*, options: SerializeOptions = DEFAULT_SERIALIZE_OPTIONS*/): string {
export function stringify<T>(data: T/*, options: SerializeOptions = DEFAULT_SERIALIZE_OPTIONS*/): string {
if (isBoolean<T>()) {
return serializeBool(data as bool);
} else if (isInteger<T>() && nameof<T>() == "usize" && data == 0) {
Expand Down Expand Up @@ -215,9 +214,7 @@ export namespace JSON {
* @param data string
* @returns T
*/

// @ts-ignore: Decorator
@inline export function parse<T>(data: string): T {
export function parse<T>(data: string): T {
if (isBoolean<T>()) {
return deserializeBoolean(data) as T;
} else if (isInteger<T>()) {
Expand Down
Loading

0 comments on commit 6853212

Please sign in to comment.