What's faster? JSON or Events?

Discussion and feedback on Construct 2

Post » Thu Jul 10, 2014 11:42 pm

I'm using an Array since I can't index variables and wanted to know if anyone knows if loading JSON from a file or just setting each value using actions, on startup is faster?

I'd imagine JSON would be faster since there's only 1 event... :?:
B
25
S
6
G
3
Posts: 197
Reputation: 3,355

Post » Fri Jul 11, 2014 12:24 am

traditionally file I/O is slower than things done in memory.

I haven't used anything with JSON yet but I have used the CSV plugin by rexrainbow and I know that is definitely "slower" than events.

So it would make sense that Events are fast since this is done in RAM opposed to going to a file and opening it etc..
B
100
S
33
G
16
Posts: 1,204
Reputation: 16,865

Post » Fri Jul 11, 2014 11:41 am

@jobel Makes sense, thank you :)
B
25
S
6
G
3
Posts: 197
Reputation: 3,355

Post » Fri Jul 11, 2014 11:54 am

@TwinTails @jobel : that's true, it's always better to populate an array or variables with all of the data you need. With the JSON plugin, it's very easy as you can loop through items and populate an array quickly. It's not as efficient with object variables though, as you have to use the dropdown menu to pick a variable to set up... do one of you know of a work-around for that?

Cheers,
Nathan
B
79
S
22
G
4
Posts: 311
Reputation: 12,814

Post » Fri Jul 11, 2014 5:11 pm

@Valerien I haven't used the JSON plugin so I'm not sure, sorry.
B
25
S
6
G
3
Posts: 197
Reputation: 3,355

Post » Sat Jul 12, 2014 2:34 am

TwinTails wrote: just setting each value using actions, on startup is faster?


oh I assumed you meant "faster" as in, which happens quicker..i.e computer speeds. Information I've loaded from tables are slower than loading information from variables or direct assigning. I've had to add Waits before executing certain code blocks because loading data from a table is slower than a tick. Whereas assigning table data through direct assigning happens in 1 tick.
B
100
S
33
G
16
Posts: 1,204
Reputation: 16,865

Post » Sat Jul 12, 2014 4:48 pm

jobel wrote:
TwinTails wrote: just setting each value using actions, on startup is faster?


oh I assumed you meant "faster" as in, which happens quicker..i.e computer speeds. Information I've loaded from tables are slower than loading information from variables or direct assigning. I've had to add Waits before executing certain code blocks because loading data from a table is slower than a tick. Whereas assigning table data through direct assigning happens in 1 tick.


Adding wait is not best way to do it. Most efficient way to build certain chain reactions is state machine. Unless you have some massive array to deal with, like a big level, arrays are fast enough.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
91
S
30
G
22
Posts: 1,985
Reputation: 20,149

Post » Sun Jul 13, 2014 6:27 pm

megatronx wrote:Adding wait is not best way to do it. Most efficient way to build certain chain reactions is state machine. Unless you have some massive array to deal with, like a big level, arrays are fast enough.


right..just illustrating a point...

I've loaded data using the CSV plugin, when loading that information into memory that process takes longer than a tick, so you have to "wait" for it to be loaded since the game loop happens every tick... you have to build in something that will not execute code that assumes the data has been refreshed (especially if that code only happens once, like in an OnClicked Event for example)...you have to wait for the data to be finished loading. You can do this with flags or in some cases a simple System Wait might work, but it obviously needs to be tested. The Wait command is less reliable since all machines have different speeds and it greatly depends on the size of your data; a 0.1 Wait on one computer might not be long enough on another. However, there are simple cases where a Wait would suffice depending on what you are doing.

I think the OP was probably just asking what is faster to build...
B
100
S
33
G
16
Posts: 1,204
Reputation: 16,865


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 14 guests