Slow deserialization for specific input
ev8dev opened this issue · 1 comments
ev8dev commented
So I'm using this library with different input data. I have certain inputs of 700 lines with as many relations as below that take 50ms to deserialize (output file: 2800 lines). This input though, takes more than 1200ms! I tried so much, but nothing solves it. Removing all desk relations but 1, makes it take 220ms which is also pretty slow.
I really can't figure out what I'm doing wrong. Could anyone help me with this?
Expected Behavior
+/- 50ms
Actual Behavior
1200ms+
Steps to Reproduce the Problem
new jsonSerializer.Deserializer({keyForAttribute: 'camelCase'}).deserialize(data);
data
:
{
data: {
type: 'tickets',
id: 584297,
attributes: {
name: 'A18',
created: '2021-11-23T14:02:16+00:00',
ticket_called: '2021-11-23T15:08:21+00:00',
ticket_set_to_waiting_list: null,
ticket_called_from_waiting_list: null,
ticket_finished: null,
waiting_list: 0,
service_id: 51,
dispenser_id: 26,
desk_id: 92,
metadata: '{}',
waiting_tickets_per_service: 1,
total_waiting_tickets: 1,
total_waiting_priority_tickets: 0,
ticket_created: '2021-11-23T14:02:16+00:00'
},
relationships: {
desks: {
data: [
{ type: 'desks', id: 92 },
{ type: 'desks', id: 93 },
{ type: 'desks', id: 94 },
{ type: 'desks', id: 95 },
{ type: 'desks', id: 96 },
{ type: 'desks', id: 97 },
{ type: 'desks', id: 98 },
{ type: 'desks', id: 100 }
]
}
}
},
included: [
{
type: 'desks',
id: 92,
attributes: { name: 'Desk 1', setup_id: 24, open: 1 }
},
{
type: 'desks',
id: 93,
attributes: { name: 'Desk 2', setup_id: 24, open: 0 }
},
{
type: 'desks',
id: 94,
attributes: { name: 'Desk 3', setup_id: 24, open: 0 }
},
{
type: 'desks',
id: 95,
attributes: { name: 'Desk 4', setup_id: 24, open: 0 }
},
{
type: 'desks',
id: 96,
attributes: { name: 'Desk 5', setup_id: 24, open: 0 }
},
{
type: 'desks',
id: 97,
attributes: { name: 'Desk 6', setup_id: 24, open: 0 }
},
{
type: 'desks',
id: 98,
attributes: { name: 'Desk 7', setup_id: 24, open: 0 }
},
{
type: 'desks',
id: 100,
attributes: { name: 'Desk 9', setup_id: 24, open: 0 }
}
]
}
Specifications
- Version: 3.6.4 (due to #223)
ev8dev commented
So I ended up forking this project, using 3.6.7
and applying the fix @danielpigott proposed in #223. Went from 1200ms to 2ms.