Skip to content

Commit

Permalink
Testing superjson performance.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail committed Nov 23, 2024
1 parent 9a2c66e commit d82cebf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
"prettier": "3.3.3",
"semver": "^7.6.3",
"snakify-ts": "^2.3.0",
"superjson": "^2.2.1",
"swagger-ui-express": "^5.0.0",
"tsup": "^8.0.0",
"tsx": "^4.6.2",
Expand Down
16 changes: 8 additions & 8 deletions tests/bench/experiment.bench.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { bench } from "vitest";
import { retrieveUserEndpoint } from "../../example/endpoints/retrieve-user";
import { DependsOnMethod } from "../../src";
import { walkRouting } from "../../src/routing-walker";
import { serialize } from "superjson";

const routing = {
a: {
Expand All @@ -13,9 +11,7 @@ const routing = {
g: {
h: {
i: {
j: new DependsOnMethod({
post: retrieveUserEndpoint,
}),
j: new Date(),
},
},
},
Expand All @@ -30,7 +26,11 @@ const routing = {
};

describe("Experiment for routing walker", () => {
bench("featured", () => {
walkRouting({ routing, onEndpoint: vi.fn() });
bench("JSON.stringify()", () => {
JSON.stringify(routing);
});

bench("superjson.serialize()", () => {
serialize(routing);
});
});
19 changes: 19 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,13 @@ [email protected]:
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.7.1.tgz#2f73c42142d5d5cf71310a74fc4ae61670e5dbc9"
integrity sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==

copy-anything@^3.0.2:
version "3.0.5"
resolved "https://registry.yarnpkg.com/copy-anything/-/copy-anything-3.0.5.tgz#2d92dce8c498f790fa7ad16b01a1ae5a45b020a0"
integrity sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w==
dependencies:
is-what "^4.1.8"

core-js-compat@^3.38.1:
version "3.39.0"
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.39.0.tgz#b12dccb495f2601dc860bdbe7b4e3ffa8ba63f61"
Expand Down Expand Up @@ -2233,6 +2240,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-4.0.0.tgz#42ff9f84206c1991d26debf520dd5c01042dd2f3"
integrity sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==

is-what@^4.1.8:
version "4.1.16"
resolved "https://registry.yarnpkg.com/is-what/-/is-what-4.1.16.tgz#1ad860a19da8b4895ad5495da3182ce2acdd7a6f"
integrity sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==

isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
Expand Down Expand Up @@ -3258,6 +3270,13 @@ sucrase@^3.35.0:
pirates "^4.0.1"
ts-interface-checker "^0.1.9"

superjson@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/superjson/-/superjson-2.2.1.tgz#9377a7fa80fedb10c851c9dbffd942d4bcf79733"
integrity sha512-8iGv75BYOa0xRJHK5vRLEjE2H/i4lulTjzpUXic3Eg8akftYjkmQDa8JARQ42rlczXyFR3IeRoeFCc7RxHsYZA==
dependencies:
copy-anything "^3.0.2"

supports-color@^7.0.0, supports-color@^7.1.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
Expand Down

0 comments on commit d82cebf

Please sign in to comment.