Ascendro Blog

Displaying 1-2 of 2 results.
0 Comments

Yii ArrayDataProvider and lots of records

Here is a short tip from our team that helps you optimize the page load speed.

In one of our applications we have a page listing patients of a practice. As the practices grew their business, we noticed a slowdown when loading that page.

The initial implementation was using a CArrayDataProvider with the data retrieved using an SQL query. Therefore the slowdowns' cause was that on every page load the data was retrieved from the database, and after only the 10 needed results were taken out and displayed. The solution was replacing the implementation with CSqlDataProvider

read more

2 Comments

Handling large strings in PHP

We recently needed to write an algorithm to unpack a specific file from a proprietary archive format.

The fun part is that the initial task quickly transformed into a research task as our colleague Michael wanted to dig deeper in the topic. Here is the story behind the performance boost.

I never worked with binary files before in PHP so I decided to first get it working and care about optimisations later. 

My straight forward approach of using file_get_contents and normal string operations resulted in very low performing and memory hungry process.

For getting a 10kb file out of an 2MB archive the algorithm took ~1.200ms and ~14mb memory at its peak.

This had to be optimized ... and I succeeded to bring it down to 30ms and 1MB memory at its peak ...

read more