Skip to content

Commit

Permalink
Add very basic performance test for save()
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmollenhour committed Aug 20, 2024
1 parent d403f44 commit c2e14be
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ docker build . -t cm-cache-backend-redis

Then start a Redis server, install Composer dependencies and run tests like so:
```shell
docker run --rm -d -p 6379 --name cm-cache-backend-redis redis
docker run --rm -d -p 6379 --name cm-cache-backend-redis redis --maxmemory 20m --maxmemory-policy noeviction
cm-cache-backend-redis composer install
cm-cache-backend-redis composer run-script test
cm-cache-backend-redis composer run-script php-cs-fixer -- --dry-run
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"scripts": {
"test": "vendor/bin/phpunit tests",
"test-performance": "PERFORMANCE=1 vendor/bin/phpunit tests --filter testLargePayloadLoop",
"php-cs-fixer": "vendor/bin/php-cs-fixer fix --diff"
}
}
14 changes: 14 additions & 0 deletions tests/RedisBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ public function testCompression(): void
$this->assertTrue($this->_instance->load('long') == $longString);
}

public function testLargePayloadLoop()
{
if (getenv('PERFORMANCE')) {
$longString = file_get_contents(__FILE__);
$tags = ['one','two','three','four','five','six','seven','eight','nine','ten'];
for ($i = 0; $i < 1000; $i++) {
$this->_instance->save($longString, $tags[$i % 10], $tags);
}
$this->assertTrue(true);
} else {
$this->markTestSkipped('Skipping large payload test');
}
}

public function testExpiredCleanup(): void
{
$this->assertTrue($this->_instance->clean());
Expand Down

0 comments on commit c2e14be

Please sign in to comment.