Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exp: Testing superjson performance #2204

Closed
wants to merge 2 commits into from
Closed

Exp: Testing superjson performance #2204

wants to merge 2 commits into from

Conversation

RobinTail
Copy link
Owner

@RobinTail RobinTail commented Nov 23, 2024

This thing seems to be involved into tRPC protocol according to #2180

Claimed by superjson documentation:

  • Negligible runtime footprint

Fact checking:

   ✓ Experiment on serialization (2) 1350ms
     name                                    hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · JSON.stringify()                328,889.59  0.0028  0.1905  0.0030  0.0030  0.0047  0.0049  0.0267  ±0.25%   164445   fastest
   · JSON.stringify() with replacer  236,611.42  0.0039  0.3153  0.0042  0.0041  0.0055  0.0064  0.0308  ±0.32%   118306
   · superjson.serialize()            62,360.65  0.0146  0.3626  0.0160  0.0156  0.0326  0.0451  0.2140  ±0.66%    31181   slowest

 BENCH  Summary

  JSON.stringify() - tests/bench/experiment.bench.ts > Experiment on serialization
    1.39x faster than JSON.stringify() with replacer
    5.27x faster than superjson.serialize()

Related issue flightcontrolhq/superjson#68

In general, I admire the idea, but it seems to have a massive performance flaw that makes its usage in IO operation questionable. However, it's more powerful and fixes several issues of JSON methods, like circular references.

@RobinTail RobinTail added the unclear Is it a bug or a feature? label Nov 23, 2024
Copy link

coveralls-official bot commented Nov 23, 2024

Coverage Status

coverage: 100.0%. remained the same
when pulling efe99a6 on try-superjson
into 9a2c66e on master.

@RobinTail RobinTail closed this Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unclear Is it a bug or a feature?
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant