mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
benchmarks
19 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b30b8cae73
|
Merge pull request #2207 from bf4/benchmarks
Add payload (regression) validation to benchmarks |
||
|
|
2c21197bdd | Document compare.sh | ||
|
|
0de40a4cbb | Give compare.sh execute | ||
|
|
89cbb28cfa | Make CI no-op | ||
|
|
68720cef4d |
Confirmed difference from jsonapi vs AMS not significant
pretty clear now that the ONLY difference
rendering a `user` with `include: 'posts.comments'`
is that the included post's user relationship
in jsonapirb is `meta: { included: false }`
and AMS is `data: { id: 1, type: users}`
which I guess is to avoid the user's
post's comment from looking up the user?
similarly, the included comment's post relationship
for jsonapi-rb is `meta: { included: false}`
and AMS is `data: { id: 2, type: posts }`
took a bit of jq and diff to figure this out
|
||
|
|
4bb5272b77 | Fancier compare | ||
|
|
9a58ab1000 | Compare by pattern | ||
|
|
38af67024a | Make all ids increment for uniquness and sortability | ||
|
|
0f8d447969 | Compare bash | ||
|
|
f8f7935535 |
Assert no regressions in gem-specific JSON document
NOTE: the two gems are generating different JSON
Essential difference
- Including a user's posts's comments differ in that
the included resource's relationship
is `meta: {included: false}` instead of `data: { id: 20, type: :posts}`
```diff
id: 39,
type: comments
attributes: { author: me, comment: wazzup }
relationships: {
post: {
- data: { id: 20, type: posts }
+ meta: { included: false }
}
}
}
```
Unimportant differences:
- data: { type, id } vs. data: { id, type }
Complete diff
```bash
diff --side-by-side support/json_document-ams.json support/json_document-jsonapi_rb.json
```
```diff
{ {
"data": { "data": {
"id": "1", "id": "1",
"type": "users", "type": "users",
"attributes": { "attributes": {
"first_name": "Diana", "first_name": "Diana",
"last_name": "Prince", "last_name": "Prince",
"birthday": "2017-07-01 05:00:00 UTC", "birthday": "2017-07-01 05:00:00 UTC",
"created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"posts": { "posts": {
"data": [ "data": [
{ {
"id": "1", | "type": "posts",
"type": "posts" | "id": "1"
}, },
{ {
"id": "2", | "type": "posts",
"type": "posts" | "id": "2"
}, },
{ {
"id": "3", | "type": "posts",
"type": "posts" | "id": "3"
}, },
{ {
"id": "4", | "type": "posts",
"type": "posts" | "id": "4"
}, },
{ {
"id": "5", | "type": "posts",
"type": "posts" | "id": "5"
}, },
{ {
"id": "6", | "type": "posts",
"type": "posts" | "id": "6"
}, },
{ {
"id": "7", | "type": "posts",
"type": "posts" | "id": "7"
}, },
{ {
"id": "8", | "type": "posts",
"type": "posts" | "id": "8"
}, },
{ {
"id": "9", | "type": "posts",
"type": "posts" | "id": "9"
}, },
{ {
"id": "10", | "type": "posts",
"type": "posts" | "id": "10"
}, },
{ {
"id": "11", | "type": "posts",
"type": "posts" | "id": "11"
}, },
{ {
"id": "12", | "type": "posts",
"type": "posts" | "id": "12"
}, },
{ {
"id": "13", | "type": "posts",
"type": "posts" | "id": "13"
}, },
{ {
"id": "14", | "type": "posts",
"type": "posts" | "id": "14"
}, },
{ {
"id": "15", | "type": "posts",
"type": "posts" | "id": "15"
}, },
{ {
"id": "16", | "type": "posts",
"type": "posts" | "id": "16"
}, },
{ {
"id": "17", | "type": "posts",
"type": "posts" | "id": "17"
}, },
{ {
"id": "18", | "type": "posts",
"type": "posts" | "id": "18"
}, },
{ {
"id": "19", | "type": "posts",
"type": "posts" | "id": "19"
}, },
{ {
"id": "20", | "type": "posts",
"type": "posts" | "id": "20"
} }
] ]
} }
} }
}, },
"included": [ "included": [
{ {
"id": "1", "id": "1",
"type": "posts", "type": "posts",
"attributes": { "attributes": {
"title": "Some Post", "title": "Some Post",
"body": "awesome content", "body": "awesome content",
"created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"user": { "user": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, },
"comments": { "comments": {
"data": [ "data": [
{ {
"id": "1", | "type": "comments",
"type": "comments" | "id": "1"
}, },
{ {
"id": "2", | "type": "comments",
"type": "comments" | "id": "2"
} }
] ]
} }
} }
}, },
{ {
"id": "1", | "id": "2",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "3"
> },
> {
> "type": "comments",
> "id": "4"
> }
> ]
} }
} }
}, },
{ {
"id": "2", | "id": "3",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "5"
> },
> {
> "type": "comments",
> "id": "6"
> }
> ]
} }
} }
}, },
{ {
"id": "2", | "id": "4",
"type": "posts", "type": "posts",
"attributes": { "attributes": {
"title": "Some Post", "title": "Some Post",
"body": "awesome content", "body": "awesome content",
"created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"user": { "user": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, },
"comments": { "comments": {
"data": [ "data": [
{ {
"id": "3", | "type": "comments",
"type": "comments" | "id": "7"
}, },
{ {
"id": "4", | "type": "comments",
"type": "comments" | "id": "8"
} }
] ]
} }
} }
}, },
{ {
"id": "3", | "id": "5",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "2", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "9"
> },
> {
> "type": "comments",
> "id": "10"
> }
> ]
} }
} }
}, },
{ {
"id": "4", | "id": "6",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "2", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "11"
> },
> {
> "type": "comments",
> "id": "12"
> }
> ]
} }
} }
}, },
{ {
"id": "3", | "id": "7",
"type": "posts", "type": "posts",
"attributes": { "attributes": {
"title": "Some Post", "title": "Some Post",
"body": "awesome content", "body": "awesome content",
"created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"user": { "user": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, },
"comments": { "comments": {
"data": [ "data": [
{ {
"id": "5", | "type": "comments",
"type": "comments" | "id": "13"
}, },
{ {
"id": "6", | "type": "comments",
"type": "comments" | "id": "14"
} }
] ]
} }
} }
}, },
{ {
"id": "5", | "id": "8",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "3", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "15"
> },
> {
> "type": "comments",
> "id": "16"
> }
> ]
} }
} }
}, },
{ {
"id": "6", | "id": "9",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "3", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "17"
> },
> {
> "type": "comments",
> "id": "18"
> }
> ]
} }
} }
}, },
{ {
"id": "4", | "id": "10",
"type": "posts", "type": "posts",
"attributes": { "attributes": {
"title": "Some Post", "title": "Some Post",
"body": "awesome content", "body": "awesome content",
"created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"user": { "user": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, },
"comments": { "comments": {
"data": [ "data": [
{ {
"id": "7", | "type": "comments",
"type": "comments" | "id": "19"
}, },
{ {
"id": "8", | "type": "comments",
"type": "comments" | "id": "20"
} }
] ]
} }
} }
}, },
{ {
"id": "7", | "id": "11",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "4", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "21"
> },
> {
> "type": "comments",
> "id": "22"
> }
> ]
} }
} }
}, },
{ {
"id": "8", | "id": "12",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "4", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "23"
> },
> {
> "type": "comments",
> "id": "24"
> }
> ]
} }
} }
}, },
{ {
"id": "5", | "id": "13",
"type": "posts", "type": "posts",
"attributes": { "attributes": {
"title": "Some Post", "title": "Some Post",
"body": "awesome content", "body": "awesome content",
"created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"user": { "user": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, },
"comments": { "comments": {
"data": [ "data": [
{ {
"id": "9", | "type": "comments",
"type": "comments" | "id": "25"
}, },
{ {
"id": "10", | "type": "comments",
"type": "comments" | "id": "26"
} }
] ]
} }
} }
}, },
{ {
"id": "9", | "id": "14",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "5", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "27"
> },
> {
> "type": "comments",
> "id": "28"
> }
> ]
} }
} }
}, },
{ {
"id": "10", | "id": "15",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "5", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "29"
> },
> {
> "type": "comments",
> "id": "30"
> }
> ]
} }
} }
}, },
{ {
"id": "6", | "id": "16",
"type": "posts", "type": "posts",
"attributes": { "attributes": {
"title": "Some Post", "title": "Some Post",
"body": "awesome content", "body": "awesome content",
"created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"user": { "user": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, },
"comments": { "comments": {
"data": [ "data": [
{ {
"id": "11", | "type": "comments",
"type": "comments" | "id": "31"
}, },
{ {
"id": "12", | "type": "comments",
"type": "comments" | "id": "32"
} }
] ]
} }
} }
}, },
{ {
"id": "11", | "id": "17",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "6", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "33"
> },
> {
> "type": "comments",
> "id": "34"
> }
> ]
} }
} }
}, },
{ {
"id": "12", | "id": "18",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "6", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "35"
> },
> {
> "type": "comments",
> "id": "36"
> }
> ]
} }
} }
}, },
{ {
"id": "7", | "id": "19",
"type": "posts", "type": "posts",
"attributes": { "attributes": {
"title": "Some Post", "title": "Some Post",
"body": "awesome content", "body": "awesome content",
"created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"user": { "user": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, },
"comments": { "comments": {
"data": [ "data": [
{ {
"id": "13", | "type": "comments",
"type": "comments" | "id": "37"
}, },
{ {
"id": "14", | "type": "comments",
"type": "comments" | "id": "38"
} }
] ]
} }
} }
}, },
{ {
"id": "13", | "id": "20",
"type": "comments", | "type": "posts",
"attributes": { "attributes": {
"author": "me", | "title": "Some Post",
"comment": "nice blog" | "body": "awesome content",
> "created_at": "2017-07-01 05:00:00 UTC",
> "updated_at": "2017-07-01 05:00:00 UTC"
}, },
"relationships": { "relationships": {
"post": { | "user": {
"data": { | "meta": {
"id": "7", | "included": false
"type": "posts" <
} }
> },
> "comments": {
> "data": [
> {
> "type": "comments",
> "id": "39"
> },
> {
> "type": "comments",
> "id": "40"
> }
> ]
} }
} }
}, },
{ {
"id": "14", | "id": "1",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "7", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "8", | "id": "2",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "15", <
"type": "comments" <
}, <
{ <
"id": "16", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "15", | "id": "3",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "8", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "16", | "id": "4",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "8", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "9", | "id": "5",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "17", <
"type": "comments" <
}, <
{ <
"id": "18", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "17", | "id": "6",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "9", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "18", | "id": "7",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "9", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "10", | "id": "8",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "19", <
"type": "comments" <
}, <
{ <
"id": "20", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "19", | "id": "9",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "10", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "20", | "id": "10",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "10", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "11", "id": "11",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "21", <
"type": "comments" <
}, <
{ <
"id": "22", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "21", | "id": "12",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "11", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "22", | "id": "13",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "11", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "12", | "id": "14",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "23", <
"type": "comments" <
}, <
{ <
"id": "24", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "23", | "id": "15",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "12", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "24", | "id": "16",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "12", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "13", | "id": "17",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "25", <
"type": "comments" <
}, <
{ <
"id": "26", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "25", | "id": "18",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "13", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "26", | "id": "19",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "13", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "14", | "id": "20",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "27", <
"type": "comments" <
}, <
{ <
"id": "28", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "27", | "id": "21",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "14", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "28", | "id": "22",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "14", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "15", | "id": "23",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "29", <
"type": "comments" <
}, <
{ <
"id": "30", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "29", | "id": "24",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "15", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "30", | "id": "25",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "15", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "16", | "id": "26",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "31", <
"type": "comments" <
}, <
{ <
"id": "32", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "31", | "id": "27",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "16", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "32", | "id": "28",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "16", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "17", | "id": "29",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "33", <
"type": "comments" <
}, <
{ <
"id": "34", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "33", | "id": "30",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "17", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "34", | "id": "31",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "17", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "18", | "id": "32",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "35", <
"type": "comments" <
}, <
{ <
"id": "36", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "35", | "id": "33",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "18", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "36", | "id": "34",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "18", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "19", | "id": "35",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "37", <
"type": "comments" <
}, <
{ <
"id": "38", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "37", | "id": "36",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "19", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "38", | "id": "37",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "19", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "20", | "id": "38",
"type": "posts", | "type": "comments",
"attributes": { "attributes": {
"title": "Some Post", | "author": "me",
"body": "awesome content", | "comment": "nice blog"
"created_at": "2017-07-01 05:00:00 UTC", <
"updated_at": "2017-07-01 05:00:00 UTC" <
}, },
"relationships": { "relationships": {
"user": { | "post": {
"data": { | "meta": {
"id": "1", | "included": false
"type": "users" <
} }
}, <
"comments": { <
"data": [ <
{ <
"id": "39", <
"type": "comments" <
}, <
{ <
"id": "40", <
"type": "comments" <
} <
] <
} }
} }
}, },
{ {
"id": "39", "id": "39",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "20", | "included": false
"type": "posts" <
} }
} }
} }
}, },
{ {
"id": "40", "id": "40",
"type": "comments", "type": "comments",
"attributes": { "attributes": {
"author": "me", "author": "me",
"comment": "nice blog" "comment": "nice blog"
}, },
"relationships": { "relationships": {
"post": { "post": {
"data": { | "meta": {
"id": "20", | "included": false
"type": "posts" <
} }
} }
} }
} }
] ]
} }
```
|
||
|
|
d0ef3d1c89 | Remove sqlite db from version control | ||
|
|
6c90fc98c1 |
Turn off (slow) AMS case transform
```
$ bundle exec ruby benchmark.rb
-- create_table("comments", {:force=>:cascade})
-> 0.0127s
-- create_table("posts", {:force=>:cascade})
-> 0.0030s
-- create_table("users", {:force=>:cascade})
-> 0.0018s
Warming up --------------------------------------
ams 1.000 i/100ms
jsonapi-rb 4.000 i/100ms
ams eager 2.000 i/100ms
jsonapi-rb eager 9.000 i/100ms
Calculating -------------------------------------
ams 16.572 (± 1.4%) i/s - 164.000 in 10.003051s
jsonapi-rb 45.722 (± 0.9%) i/s - 460.000 in 10.084399s
ams eager 21.037 (± 0.8%) i/s - 212.000 in 10.099436s
jsonapi-rb eager 97.010 (± 1.3%) i/s - 972.000 in 10.069614s
with 95.0% confidence
Comparison:
jsonapi-rb eager: 97.0 i/s
jsonapi-rb : 45.7 i/s - 2.12x (± 0.03) slower
ams eager: 21.0 i/s - 4.61x (± 0.07) slower
ams : 16.6 i/s - 5.85x (± 0.11) slower
with 95.0% confidence
Calculating -------------------------------------
ams 3.793M memsize ( 185.000k retained)
44.737k objects ( 2.549k retained)
50.000 strings ( 40.000 retained)
jsonapi-rb 1.873M memsize ( 0.000 retained)
21.424k objects ( 0.000 retained)
50.000 strings ( 0.000 retained)
ams eager 2.923M memsize ( 180.848k retained)
34.285k objects ( 2.433k retained)
50.000 strings ( 46.000 retained)
jsonapi-rb eager 899.226k memsize ( 0.000 retained)
9.485k objects ( 0.000 retained)
50.000 strings ( 0.000 retained)
Comparison:
jsonapi-rb eager: 899226 allocated
jsonapi-rb : 1873384 allocated - 2.08x more
ams eager: 2922890 allocated - 3.25x more
ams : 3792800 allocated - 4.22x more
```
|
||
|
|
919feafa0a | Clarify code a bit | ||
|
|
5d3ecb2f16 | Consistent records | ||
|
|
3fd3a04396 | Correct readme | ||
|
|
f7da64f7e7 | Benchamrks are an app which requires us to track the Gemfile.lock | ||
|
|
5ca3e96914 |
Fix JSONAPI:Serializer test
```
$ bundle exec ruby benchmark.rb
-- create_table("comments", {:force=>:cascade})
-> 0.0066s
-- create_table("posts", {:force=>:cascade})
-> 0.0029s
-- create_table("users", {:force=>:cascade})
-> 0.0017s
Warming up --------------------------------------
ams 2.000 i/100ms
jsonapi-rb 7.000 i/100ms
ams eager 2.000 i/100ms
jsonapi-rb eager 12.000 i/100ms
Calculating -------------------------------------
ams 20.397 (± 1.7%) i/s - 204.000 in 10.097255s
jsonapi-rb 74.981 (± 0.8%) i/s - 756.000 in 10.100857s
ams eager 23.117 (± 0.6%) i/s - 232.000 in 10.047664s
jsonapi-rb eager 125.521 (± 0.8%) i/s - 1.260k in 10.054734s
with 95.0% confidence
Comparison:
jsonapi-rb eager: 125.5 i/s
jsonapi-rb : 75.0 i/s - 1.67x (± 0.02) slower
ams eager: 23.1 i/s - 5.43x (± 0.05) slower
ams : 20.4 i/s - 6.15x (± 0.12) slower
with 95.0% confidence
Calculating -------------------------------------
ams 2.688M memsize ( 188.498k retained)
33.331k objects ( 2.554k retained)
50.000 strings ( 50.000 retained)
jsonapi-rb 1.038M memsize ( 0.000 retained)
11.784k objects ( 0.000 retained)
50.000 strings ( 0.000 retained)
ams eager 2.470M memsize ( 184.410k retained)
30.534k objects ( 2.439k retained)
50.000 strings ( 50.000 retained)
jsonapi-rb eager 715.124k memsize ( 0.000 retained)
7.500k objects ( 0.000 retained)
50.000 strings ( 0.000 retained)
Comparison:
jsonapi-rb eager: 715124 allocated
jsonapi-rb : 1037676 allocated - 1.45x more
ams eager: 2469640 allocated - 3.45x more
ams : 2688112 allocated - 3.76x more
```
|
||
|
|
0a366b4ca9 | Remove commented out code | ||
|
|
43c1518cff | compare ams with jsonapi-rb |