-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTMLDiff Performance inhancement (#54)
* Trying to squize more performance out of the HTMLDiffer * Initial array_slice_cached. cacheToken key breaks the differ * Added setters for the oldWords and newWords to make sure the cache is reset * Documentation * Expected output * AbstractTest, for DRY functions * Fixed scrutinizer complained
- Loading branch information
1 parent
11d3493
commit 272a3ba
Showing
11 changed files
with
262 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ vendor/ | |
/demo/bower_components | ||
/demo/node_modules | ||
.DS_Store | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Caxy\Tests; | ||
|
||
abstract class AbstractTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
protected function stripExtraWhitespaceAndNewLines($text) | ||
{ | ||
return trim( | ||
preg_replace( | ||
'/>\s+</', | ||
'><', | ||
preg_replace('/\s+/S', " ", preg_replace("/[\n\r]/", '', $text)) | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Caxy\Tests\HtmlDiff\Performance; | ||
|
||
use Caxy\HtmlDiff\HtmlDiff; | ||
use Caxy\Tests\AbstractTest; | ||
|
||
class PerformanceTest extends AbstractTest | ||
{ | ||
/** | ||
* @group performance | ||
*/ | ||
public function testParagraphPerformance() | ||
{ | ||
$fixturesPath = __DIR__ . '/../../../../fixtures/Performance/'; | ||
|
||
$expected = file_get_contents($fixturesPath . 'paragraphs_expected.html'); | ||
|
||
$diff = new HtmlDiff( | ||
file_get_contents($fixturesPath . 'paragraphs.html'), | ||
file_get_contents($fixturesPath . 'paragraphs_changed.html'), | ||
'UTF-8', array() | ||
); | ||
|
||
$output = $diff->build(); | ||
|
||
$this->assertSame($this->stripExtraWhitespaceAndNewLines($output), $this->stripExtraWhitespaceAndNewLines($expected)); | ||
} | ||
} |
Oops, something went wrong.