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?
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With