Comments (13)
Thanks for reaching out. We are putting together a longer writeup. Our benchmarks can be run very easily If you just run rspec you will see the results. More information about how the benchmarks are setup take a look at this file
https://github.com/Netflix/fast_jsonapi/blob/master/spec/lib/object_serializer_performance_spec.rb
We had a very specific goal in mind so we got the speed increase by sacrificing some flexibility, focusing just on JSON API and assuming homogenous lists.
from fast_jsonapi.
@shishirmk Thank you for sharing this and thinking about putting together a longer writeout. It would be great if you could add one or two sentences about why fast_jsonapi is faster than AMS. I am very interested in this sort of performance optimization, but I currently have no clue about where to start or what techniques to avoid in order to become/stay fast.
from fast_jsonapi.
benchmark against jsonapi-rb
added in #52
from fast_jsonapi.
@NullVoxPopuli @shishirmk Here is the link to the performance doc. Hopefully it helps in answering your question.
from fast_jsonapi.
I did some benchmarking with script and results (Iterations per second) were,
Warming up --------------------------------------
jsonapi-rb 10.000 i/100ms
Calculating -------------------------------------
jsonapi-rb 111.401 (±20.6%) i/s - 1.580k in 15.058330s
Warming up --------------------------------------
fastjson-api 118.000 i/100ms
Calculating -------------------------------------
fastjson-api 1.270k (± 9.6%) i/s - 18.880k in 15.014813s
Can someone confirm these results ? Let me know if I am doing anything wrong here. Thanks.
from fast_jsonapi.
@amitsuryavanshi
Here is the benchmark i see on my laptop based on #52 by @minsikzzang
Serialize to Ruby Hash 1000 records
Serializer Records Time
AMS serializer 1000 376.51 ms
jsonapi-rb serializer 1000 42.34 ms
Fast serializer 1000 9.8 ms
Serialize to Ruby Hash 250 records
Serializer Records Time
AMS serializer 250 89.47 ms
jsonapi-rb serializer 250 8.54 ms
Fast serializer 250 2.09 ms
from fast_jsonapi.
I would expect fast_jsonapi
to be faster than jsonapi-rb
as it is more specialized, but a fair comparison would make jsonapi-rb
use Oj
as well for JSON serialization.
from fast_jsonapi.
@beauby I have some benchmarks here with different scenarios if you're curious: #81
Right now the biggest difference is relationship performance. (in favor of jsonapi-rb)
fast_jsonapi wins the most with flat lists of resources
from fast_jsonapi.
Switching all the serializers to FastJsonapi::MultiToJson.to_json
:
Serialize to JSON string 10000 records
Serializer Records Time Speed Up
Fast serializer 10000 144.85 ms
AMS serializer 10000 3413.27 ms 23.56x ✘
jsonapi-rb serializer 10000 406.75 ms 2.81x ✔
jsonapi-serializers 10000 356.9 ms 2.46x ✔
Serialize to Ruby Hash 10000 records
Serializer Records Time Speed Up
Fast serializer 10000 115.26 ms
AMS serializer 10000 3358.11 ms 29.14x ✔
jsonapi-rb serializer 10000 399.27 ms 3.46x ✔
jsonapi-serializers 10000 303.01 ms 2.63x ✔
from fast_jsonapi.
@guilleiguaran do you have code for those benchmarks? they look fishy
from fast_jsonapi.
@NullVoxPopuli those are the benchmarks shipped with fast_jsonapi
, see #96 for my changes.
from fast_jsonapi.
ah ok. cool. @guilleiguaran, there are more in-depth benchmarks here, if you want to play with those #81
from fast_jsonapi.
Released as a part of version 1.1.0
from fast_jsonapi.
Related Issues (20)
- How can I reference dynamic attributes inside of other dynamic attributes? HOT 1
- Relationship scope HOT 1
- do i need to always give serializer name or it can auto pick HOT 1
- Any way to globally output 'pretty' JSON? HOT 1
- Is this project abandoned? No PR's merged or versions released in nearly a year! HOT 10
- Customize JSON Response HOT 3
- passing in list of params for collection?
- Thoughts on adding a value transform option or a 'type' option to Attribute?
- Unexpected behavior when object belongs_to :size HOT 2
- set_id value not respected in relationships HOT 1
- FYI > this repo has been FORKED and is active at new repository HOT 1
- uninitialized constant FooBar::OrganizationSerializer::FastJsonapi HOT 2
- #serialized_json for empty collection HOT 1
- circular association troubles HOT 1
- Integers and Floats are represented as strings HOT 1
- Bug: Associations that have an attribute or method named `map` cannot be serialized HOT 1
- ObjectSerializer not working for single object HOT 2
- Alternative to this gem -> Alba HOT 1
- Issue with accessor with a proc shortcut in ruby 3.0 HOT 1
- Single attribute with serializer parameter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fast_jsonapi.