stable

Clone or download

Read-only

request #8696: Optimize transformation of statistics export to CSV

Also add indexes to speed up MySQL queries. Given the following code snippet: $data_line = array('Data1,', 'Data 2', 'Data 3', 'Data 4', 'Data5'); $statistics_formatter = new Statistics_Formatter('', '', ','); for($i = 0; $i < 20000; $i++) { $statistics_formatter->addHeader('Title'); $statistics_formatter->addLine($data_line); $statistics_formatter->addEmptyLine(); $statistics_formatter->addLine($data_line); } $statistics_formatter->getCsvContent(); I get these results on my dev instances: Before optimization: 6.04s After optimization: 250ms Both implementation have a similar memory cost. Change-Id: Id75c10d0001cdd68079dd4ea2f66d1517ace77f6

Modified Files

Name
M plugins/docman/db/install.sql +2 −0 Go to diff View file
A plugins/docman/db/mysql/updates/2015/201512291430_add_indexes_for_docman_statistics.php +38 −0 Go to diff View file
M plugins/git/db/install.sql +2 −1 Go to diff View file
A plugins/git/db/mysql/updates/2015/201512291430_add_index_for_git_statistics.php +35 −0 Go to diff View file
M plugins/statistics/include/Statistics_Formatter.class.php +20 −36 Go to diff View file
M plugins/statistics/include/Statistics_Formatter_Scm.class.php +3 −2 Go to diff View file
A plugins/statistics/tests/Statistics_FormatterTest.php +62 −0 Go to diff View file
M plugins/statistics/www/scm_stats.php +2 −1 Go to diff View file
M plugins/statistics/www/services_usage.php +2 −1 Go to diff View file
M src/common/autoload.php +2 −2 Go to diff View file
M src/db/mysql/database_structure.sql +3 −1 Go to diff View file
A src/db/mysql/updates/2015/201512291430_add_indexes_for_statistics.php +38 −0 Go to diff View file