Skip to content

Instantly share code, notes, and snippets.

@pilshchikov
Last active October 9, 2018 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pilshchikov/b4351d78ad59e9cd923689c2e387bc80 to your computer and use it in GitHub Desktop.
Save pilshchikov/b4351d78ad59e9cd923689c2e387bc80 to your computer and use it in GitHub Desktop.
Ignite PHP thin client bench
<?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