Accelerating performance

Hi,

I am using a Particle Core to display uptime, temperature and LED status on web page. I am accessing the Spark data using Python and the Flask web framework; it works well. Generally, it takes around 2 seconds to display the page which I think is due to the three spark variable calls on page load.

In contrast, I wrote another version of the app that does the exact same thing using a Raspberry Pi and Arduino Leonardo with the communication between the two over USB/serial. The code is very similar in both cases, but this unit loads pages about 2x as fast. One of the big differences is that I send more information in this model (this sensor also provides humidity) and transmit it in comma delimited format which Python decodes.

All of this brings me to my question, would it be significantly faster to pass the data in the first approach in a single comma delimited Spark variable and then decode it in Python versus making three separate calls? I am guessing that it might but am not sure. Has anyone actually tested and compared these two approaches? (I will eventually test this, but my current Core is being used and so I will have to test it on one of my Photons when they arrive.)

Thank you in advance!

JL

Hi @JL_678

I know for me on the East Coast of the US, I am about 125ms from the Spark Cloud so the minimum round-trip time is around a 1/4 of second per cloud transaction. In practice I can do about 2 cloud transactions per second with no data loss.

I would heartily recommend switching to one Spark variable char array and encoding all the data in some minimal way like comma separators.

1 Like

@bko, thank for this advice! I went ahead and made the change this afternoon and the performance difference is huge! Page load times dropped in half! I previous saw loads between 1.8 and 2.0 seconds and it is now between .7 and 1.0 seconds. A massive improvement and best of all, I think that the resulting code is a bit more efficient as well. :smile:

1 Like