sebastianbergmann / dbunit

DbUnit port for PHP/PHPUnit.
https://phpunit.de/
Other
225 stars 186 forks source link

Performance of PHPUnit_Extensions_Database_Operation_RowBased::execute() #187

Closed jzskca closed 6 years ago

jzskca commented 7 years ago

I've been using a patch for some time now which noticeably improves database test performance. On a workload of about 50% database tests, unpatched PHPUnit 5.7.9:

Time: 2.84 minutes, Memory: 108.50MB OK (1677 tests, 5858 assertions)

versus patched PHPUnit 5.7.9:

Time: 1.84 minutes, Memory: 102.00MB OK (1677 tests, 5858 assertions)

The patch:

--- orig/dbunit/Extensions/Database/Operation/RowBased.php  2016-11-21 12:15:14.011053320 -0600
+++ tmp/dbunit/Extensions/Database/Operation/RowBased.php   2016-11-21 12:16:21.318565321 -0600
@@ -62,7 +62,7 @@
             if($rowCount == 0) continue;

             /* @var $table PHPUnit_Extensions_Database_DataSet_ITable */
-            $databaseTableMetaData = $databaseDataSet->getTableMetaData($table->getTableMetaData()->getTableName());
+            $databaseTableMetaData = $table->getTableMetaData();
             $query                 = $this->buildOperationQuery($databaseTableMetaData, $table, $connection);
             $disablePrimaryKeys    = $this->disablePrimaryKeys($databaseTableMetaData, $table, $connection);

I originally found this patch here: http://digitalsandwich.com/adding-database-tests-to-existing-phpunit-test-cases/#comment-302

sebastianbergmann commented 6 years ago

@mlively What do you think?

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had activity within the last 60 days. It will be closed after 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 6 years ago

This issue has been automatically closed because it has not had activity since it was marked as stale. Thank you for your contributions.