-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remaining relay cached commands (#99)
* Add SUNION, SDIFF, and SINTERCARD benchmarks. * Add LINDEX benchmark and minor LRANGE refactor.
- Loading branch information
1 parent
ad6b142
commit 9b2086f
Showing
7 changed files
with
138 additions
and
62 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace CacheWerk\Relay\Benchmarks\Cases; | ||
|
||
use CacheWerk\Relay\Benchmarks\Support\Benchmark; | ||
|
||
class BenchmarkLINDEX extends Benchmark | ||
{ | ||
/** | ||
* @var array<int, string> | ||
*/ | ||
protected array $keys; | ||
|
||
public static function flags(): int | ||
{ | ||
return self::LIST | self::READ; | ||
} | ||
|
||
public function setUp(): void | ||
{ | ||
$this->flush(); | ||
$this->setUpClients(); | ||
$this->seed(); | ||
} | ||
|
||
public function seed(): void | ||
{ | ||
$this->keys = $this->seedSimpleKeys(); | ||
} | ||
|
||
public function warmup(int $times, string $method): void { | ||
if ($times == 0) { | ||
return; | ||
} | ||
|
||
parent::warmup($times, $method); | ||
$this->readSimpleKeys($this->keys); | ||
} | ||
|
||
protected function runBenchmark($client): int | ||
{ | ||
foreach ($this->keys as $i => $key) { | ||
$client->lindex($key, $i % 32); | ||
} | ||
|
||
return count($this->keys); | ||
} | ||
} |
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,10 @@ | ||
<?php | ||
|
||
namespace CacheWerk\Relay\Benchmarks\Cases; | ||
|
||
use CacheWerk\Relay\Benchmarks\Support\BenchmarkMultiSetCommand; | ||
|
||
class BenchmarkSDIFF extends BenchmarkMultiSetCommand | ||
{ | ||
// | ||
} |
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,10 @@ | ||
<?php | ||
|
||
namespace CacheWerk\Relay\Benchmarks\Cases; | ||
|
||
use CacheWerk\Relay\Benchmarks\Support\BenchmarkMultiSetCommand; | ||
|
||
class BenchmarkSINTERCARD extends BenchmarkMultiSetCommand | ||
{ | ||
// | ||
} |
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,10 @@ | ||
<?php | ||
|
||
namespace CacheWerk\Relay\Benchmarks\Cases; | ||
|
||
use CacheWerk\Relay\Benchmarks\Support\BenchmarkMultiSetCommand; | ||
|
||
class BenchmarkSUNION extends BenchmarkMultiSetCommand | ||
{ | ||
// | ||
} |
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,56 @@ | ||
<?php | ||
|
||
namespace CacheWerk\Relay\Benchmarks\Support; | ||
|
||
use CacheWerk\Relay\Benchmarks\Support\Benchmark; | ||
|
||
class BenchmarkMultiSetCommand extends Benchmark | ||
{ | ||
const KeysPerCall = 8; | ||
|
||
/** | ||
* @var array<int, array<int, string>> | ||
*/ | ||
protected array $keyChunks; | ||
|
||
public static function flags(): int | ||
{ | ||
return self::SET | self::READ; | ||
} | ||
|
||
public function setUp(): void | ||
{ | ||
$this->flush(); | ||
$this->setUpClients(); | ||
$this->seed(); | ||
} | ||
|
||
public function warmup(int $times, string $method): void | ||
{ | ||
if ($times == 0) { | ||
return; | ||
} | ||
|
||
parent::warmup($times, $method); | ||
|
||
foreach ($this->keyChunks as $chunk) { | ||
$this->readSimpleKeys($chunk); | ||
} | ||
} | ||
|
||
public function seed(): void | ||
{ | ||
$this->keyChunks = array_chunk($this->seedSimpleKeys(), self::KeysPerCall); | ||
} | ||
|
||
protected function runBenchmark($client): int | ||
{ | ||
$cmd = $this->command(); | ||
|
||
foreach ($this->keyChunks as $chunk) { | ||
$client->$cmd($chunk); | ||
} | ||
|
||
return count($this->keyChunks); | ||
} | ||
} |