Last active
October 9, 2018 12:22
-
-
Save pilshchikov/b4351d78ad59e9cd923689c2e387bc80 to your computer and use it in GitHub Desktop.
Ignite PHP thin client bench
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
<?php | |
require_once '[path]\php\vendor\autoload.php'; | |
use Apache\Ignite\Client; | |
use Apache\Ignite\ClientConfiguration; | |
class PhpBench | |
{ | |
const ENDPOINT = '[grid ip]:10800'; | |
const CACHE_NAME = 'php_bench'; | |
public function start(): void | |
{ | |
$client = new Client(); | |
$client->connect(new ClientConfiguration(PhpBench::ENDPOINT)); | |
$cache = $client->getOrCreateCache(PhpBench::CACHE_NAME); | |
$start_time = time(); | |
$end_time = time() + 120; | |
$counter = 0; | |
$last_key = 0; | |
$last_display_time = time(); | |
while (time() < $end_time) { | |
if (time() != $last_display_time) { | |
$last_display_time = time(); | |
$time_from_start = time() - $start_time; | |
echo("time: $time_from_start | counter: $counter | values count: $last_key" . PHP_EOL); | |
$counter = 0; | |
} | |
$last_key = $last_key + 1; | |
$cache->put($last_key, $last_key * 2); | |
$counter = $counter + 1; | |
} | |
$client->destroyCache(PhpBench::CACHE_NAME); | |
} | |
} | |
(new PhpBench())->start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment