Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pouya-eghbali/sia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 099fcad0e685aa0f105f498ba08d20852276730b
Choose a base ref
..
head repository: pouya-eghbali/sia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6b0f8cd8dfe1de5fade9aa436cdd31bcb4b3fed4
Choose a head ref
Showing with 46 additions and 28 deletions.
  1. +1 −0 package.json
  2. +4 −0 src/benchmark/index.ts
  3. +33 −0 src/benchmark/tests/seqproto.ts
  4. +8 −28 yarn.lock
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
"avsc": "^5.7.7",
"cbor-x": "^1.6.0",
"msgpackr": "^1.11.2",
"seqproto": "^0.2.3",
"sializer": "0",
"tinybench": "^3.0.6",
"ts-proto": "^2.4.2",
4 changes: 4 additions & 0 deletions src/benchmark/index.ts
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ import { avscFiveThousandUsers, avscFiveThousandUsersDecode } from "./tests/avsc
import { furyFiveThousandUsers, furyFiveThousandUsersDecode } from "./tests/fury.js";
import { msgpackrRecordsFiveThousandUsers, msgpackrRecordsFiveThousandUsersDecode } from "./tests/msgpackr-records.js";
import { v8FiveThousandUsers, v8FiveThousandUsersDecode } from "./tests/v8.js";
import { seqprotoFiveThousandUsers, seqprotoFiveThousandUsersDecode } from "./tests/seqproto.js";

const bench = new Bench({ name: "serialization", time: 60 * 1000 });

@@ -40,6 +41,7 @@ bench.add("MsgPackr (records)", () => msgpackrRecordsFiveThousandUsers());
bench.add("Protobuf", () => protobufFiveThousandUsers());
bench.add("avsc", () => avscFiveThousandUsers());
bench.add("Fury", () => furyFiveThousandUsers());
bench.add("SeqProto", () => seqprotoFiveThousandUsers());
bench.add("V8", () => v8FiveThousandUsers());

console.log(`Running ${bench.name} benchmark...`);
@@ -61,6 +63,7 @@ deserializeBench.add("MsgPackr (records)", () => msgpackrRecordsFiveThousandUser
deserializeBench.add("Protobuf", () => protobufFiveThousandUsersDecode());
deserializeBench.add("avsc", () => avscFiveThousandUsersDecode());
deserializeBench.add("Fury", () => furyFiveThousandUsersDecode());
deserializeBench.add("SeqProto", () => seqprotoFiveThousandUsersDecode());
deserializeBench.add("V8", () => v8FiveThousandUsersDecode());

console.log(`Running ${deserializeBench.name} benchmark...`);
@@ -77,4 +80,5 @@ console.log("CBOR-X file size:", msgpackrFiveThousandUsers().length);
console.log("Protobuf file size:", protobufFiveThousandUsers().length);
console.log("avsc file size:", avscFiveThousandUsers().length);
console.log("Fury file size:", furyFiveThousandUsers().length);
console.log("SeqProto file size:", seqprotoFiveThousandUsers().byteLength);
console.log("V8 file size:", v8FiveThousandUsers().length);
33 changes: 33 additions & 0 deletions src/benchmark/tests/seqproto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { fiveThousandUsers } from "./common.js";
import { createSer, createDes } from "seqproto";

const ser = createSer();

export const seqprotoFiveThousandUsers = () => {
ser.reset();
ser.serializeArray(fiveThousandUsers, (ser, user) => {
ser.serializeString(user.userId);
ser.serializeString(user.username);
ser.serializeString(user.email);
ser.serializeString(user.avatar);
ser.serializeString(user.password);
ser.serializeUInt32(user.birthdate.getTime());
ser.serializeUInt32(user.registeredAt.getTime());
});
return ser.getBuffer();
};

const encoded = seqprotoFiveThousandUsers();

export const seqprotoFiveThousandUsersDecode = () => {
const des = createDes(encoded);
return des.deserializeArray((des) => ({
userId: des.deserializeString(),
username: des.deserializeString(),
email: des.deserializeString(),
avatar: des.deserializeString(),
password: des.deserializeString(),
birthdate: new Date(des.deserializeUInt32()),
registeredAt: new Date(des.deserializeUInt32()),
}));
};
36 changes: 8 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -71,17 +71,6 @@ __metadata:
languageName: node
linkType: hard

"@furyjs/hps@npm:^0.0.6":
version: 0.0.6
resolution: "@furyjs/hps@npm:0.0.6"
dependencies:
bindings: "npm:~1.2.1"
nan: "npm:^2.17.0"
node-gyp: "npm:^9.4.0"
checksum: 10c0/cc5e345d77c5bd226c43803a9337a0a031f24eba1a42b0903c792100c15657c34e5420b4e26a60c60019f456ce5dabc2fd6daccd0920e14d673158c485233f83
languageName: node
linkType: hard

"@gar/promisify@npm:^1.1.3":
version: 1.1.3
resolution: "@gar/promisify@npm:1.1.3"
@@ -338,13 +327,6 @@ __metadata:
languageName: node
linkType: hard

"bindings@npm:~1.2.1":
version: 1.2.1
resolution: "bindings@npm:1.2.1"
checksum: 10c0/361a7a2be8f5be3650f9e7e9bc577e2b20a22c1906f220f2b4ec0801f15d18c6cde7d5d084d90bc7252d18e381593729470c84591618b29209a3299fc1845a47
languageName: node
linkType: hard

"brace-expansion@npm:^1.1.7":
version: 1.1.11
resolution: "brace-expansion@npm:1.1.11"
@@ -1170,15 +1152,6 @@ __metadata:
languageName: node
linkType: hard

"nan@npm:^2.17.0":
version: 2.22.0
resolution: "nan@npm:2.22.0"
dependencies:
node-gyp: "npm:latest"
checksum: 10c0/d5d31aefdb218deba308d44867c5f432b4d3aabeb57c70a2b236d62652e9fee7044e5d5afd380d9fef022fe7ebb2f2d6c85ca3cbcac5031aaca3592c844526bb
languageName: node
linkType: hard

"negotiator@npm:^0.6.3":
version: 0.6.4
resolution: "negotiator@npm:0.6.4"
@@ -1412,6 +1385,13 @@ __metadata:
languageName: node
linkType: hard

"seqproto@npm:^0.2.3":
version: 0.2.3
resolution: "seqproto@npm:0.2.3"
checksum: 10c0/d0f8c133c495261d08563bbf253b8f29736b02b7add33f2c72bcdb97821cb41b4d6231ec2986fac596685e5b9312e4366242536ab5cb551c405a13402a1f1e1a
languageName: node
linkType: hard

"set-blocking@npm:^2.0.0":
version: 2.0.0
resolution: "set-blocking@npm:2.0.0"
@@ -1451,12 +1431,12 @@ __metadata:
dependencies:
"@faker-js/faker": "npm:^9.2.0"
"@furyjs/fury": "npm:^0.0.18"
"@furyjs/hps": "npm:^0.0.6"
"@types/node": "npm:^22.9.0"
"@types/ws": "npm:^8"
avsc: "npm:^5.7.7"
cbor-x: "npm:^1.6.0"
msgpackr: "npm:^1.11.2"
seqproto: "npm:^0.2.3"
sializer: "npm:0"
tinybench: "npm:^3.0.6"
ts-proto: "npm:^2.4.2"