Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lowest Memory Cache Method for PHPExcel

I tried using the different caching methods in section 4.2.1 of PHPExcel manual.

did a benchmark with 100k rows and here are the results

gzip = time=50,memoryused=177734904
ser  = time=34,memoryused=291654272
phptm= time=41,memoryused=325973456
isamm= time=39,memoryused=325972824

the manual says that the phptmp and isamm methods use disk instead of memory. Hence, they should use the least memory, but it seems that this was the opposite.

Here is the code I used to test:

                $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip;
//              $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory_serialized;
//              $cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_phpTemp;
//          $cacheSettings = array( 'memoryCacheSize'  => '8MB');               
//              $cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_discISAM;

                PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);

                $xlsReader = PHPExcel_IOFactory::createReader($fileType);
                $xlsReader->setReadDataOnly(true);

Anyone can shed light on this mystery?

like image 502
user813801 Avatar asked Dec 22 '14 17:12

user813801


1 Answers

This depends on many factors including PHP version, content of cells (numeric, string, rich text, etc), extensions enabled for PHP, etc; so it is impossible for anybody other than yourself to actually answer, because it is unique for your situation.

However, all methods retain some information about each cell in memory, with the exception of SQLite, so using an SQLite database is the most memory efficient option.

EDIT

I ran some tests with different caching methods against different versions of PHP some months ago, and the following summarises the results

enter image description here

enter image description here

These are still fairly arbitrary result, disk speed and other factors will affect performance for some caching methods like discisam and phptemp, and any configuration settings for options like phptemp will also have some affect; but it should give a relative guideline for working out which options are better for memory, and which are better for speed of execution.

like image 90
Mark Baker Avatar answered Jan 01 '23 13:01

Mark Baker