diff --git a/README.md b/README.md index 6b85296e07..ef2f4c2ead 100644 --- a/README.md +++ b/README.md @@ -196,3 +196,34 @@ $client->deleteDatabase("my.name"); // delete an existing database with name "my Actually only queryable adapters can handle databases (implements the `QueryableInterface`) +## Benchmark + +### Adapters + +The impact using UDP or HTTP adapters + +``` +Corley\Benchmarks\InfluxDB\AdapterEvent + Method Name Iterations Average Time Ops/second + ------------------------ ------------ -------------- ------------- + sendDataUsingHttpAdapter: [1,000 ] [0.0026700308323] [374.52751] + sendDataUsingUdpAdapter : [1,000 ] [0.0000436344147] [22,917.69026] +``` + + +### Filter + +Just what append when you apply the `ColumnsPointsFilter` + +``` +Corley\Benchmarks\InfluxDB\FilterEvent + Method Name Iterations Average Time Ops/second + ------------------------ ------------ -------------- ------------- + get10PointDirectData : [10,000 ] [0.0001383633137] [7,227.34931] + get10PointFilteredData : [10,000 ] [0.0001662570953] [6,014.78089] + get100PointDirectData : [1,000 ] [0.0002406690121] [4,155.08416] + get100PointFilteredData : [1,000 ] [0.0008374640942] [1,194.08104] + get1000PointDirectData : [100 ] [0.0011058974266] [904.24299] + get1000PointFilteredData: [100 ] [0.0074790692329] [133.70648] +``` + diff --git a/VERSION b/VERSION index 0ea3a944b3..0c62199f16 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.0 +0.2.1 diff --git a/benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php b/benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php new file mode 100644 index 0000000000..55b4183588 --- /dev/null +++ b/benchmarks/Corley/Benchmarks/InfluxDB/AdapterEvent.php @@ -0,0 +1,48 @@ +setUsername("root"); + $options->setPassword("root"); + $options->setDatabase("bench"); + $client->setAdapter( + new GuzzleAdapter(new HttpClient(), $options) + ); + $this->httpClient = $client; + + $client = new Client(); + $client->setAdapter(new UdpAdapter(new Options())); + $this->udpClient = $client; + } + + /** + * @iterations 1000 + */ + public function sendDataUsingHttpAdapter() + { + $this->httpClient->mark("metric.name", ["key" => "value"]); + } + + /** + * @iterations 1000 + */ + public function sendDataUsingUdpAdapter() + { + $this->udpClient->mark("metric.name", ["key" => "value"]); + } +} diff --git a/benchmarks/Corley/Benchmarks/InfluxDB/FilterEvent.php b/benchmarks/Corley/Benchmarks/InfluxDB/FilterEvent.php new file mode 100644 index 0000000000..e12ebaf4d6 --- /dev/null +++ b/benchmarks/Corley/Benchmarks/InfluxDB/FilterEvent.php @@ -0,0 +1,111 @@ +testData = [ + (object)[ + "name" => "test", + "columns" => [ + "time", + "sequence_number", + "value", + ], + "points" => [ + ], + ] + ]; + + $prophet = new Prophet; + $adapter = $prophet->prophesize('InfluxDB\Adapter\GuzzleAdapter'); + $adapter->query(Argument::any(), Argument::Any())->willReturn($this->testData); + + $this->withFilter = new Client(); + $this->withFilter->setAdapter($adapter->reveal()); + $this->withFilter->setFilter(new ColumnsPointsFilter()); + + $this->withoutFilter = new Client(); + $this->withoutFilter->setAdapter($adapter->reveal()); + } + + /** + * @iterations 10000 + */ + public function get10PointDirectData() + { + for ($i=0; $i<10; $i++) { + $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; + } + + $this->withoutFilter->query("THE QUERY", "s"); + } + + /** + * @iterations 10000 + */ + public function get10PointFilteredData() + { + for ($i=0; $i<10; $i++) { + $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; + } + $this->withFilter->query("THE QUERY", "s"); + } + + /** + * @iterations 1000 + */ + public function get100PointDirectData() + { + for ($i=0; $i<100; $i++) { + $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; + } + + $this->withoutFilter->query("THE QUERY", "s"); + } + + /** + * @iterations 1000 + */ + public function get100PointFilteredData() + { + for ($i=0; $i<100; $i++) { + $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; + } + $this->withFilter->query("THE QUERY", "s"); + } + + /** + * @iterations 100 + */ + public function get1000PointDirectData() + { + for ($i=0; $i<1000; $i++) { + $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; + } + + $this->withoutFilter->query("THE QUERY", "s"); + } + + /** + * @iterations 100 + */ + public function get1000PointFilteredData() + { + for ($i=0; $i<1000; $i++) { + $this->testData[0]->points[] = [1985718957, 12519287519, 12589175198]; + } + $this->withFilter->query("THE QUERY", "s"); + } +} diff --git a/composer.json b/composer.json index 83bc0818cb..29649d848f 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ }, "require-dev": { "phpspec/phpspec": "2.*", - "phpunit/phpunit": "4.*" + "phpunit/phpunit": "4.*", + "athletic/athletic": "~0.1" }, "homepage": "http://www.corley.it/", "keywords": ["influxdb", "udp", "sdk"], @@ -30,7 +31,8 @@ ], "autoload": { "psr-0": { - "InfluxDB\\": ["./src/", "./tests"] + "InfluxDB\\": ["./src/", "./tests"], + "Corley\\": ["./benchmarks/"] } }, "suggests": { diff --git a/composer.lock b/composer.lock index 6fda5d2a8d..0cfbc69fa7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "5647460e792745752274202f2289a0cc", + "hash": "fef5f885184ca64f876e4cba2d1de5c3", "packages": [ { "name": "guzzlehttp/guzzle", @@ -275,6 +275,151 @@ } ], "packages-dev": [ + { + "name": "athletic/athletic", + "version": "v0.1.8", + "source": { + "type": "git", + "url": "https://github.com/polyfractal/athletic.git", + "reference": "51fe4b6e5298dd8af187825a4e57745898e37f0e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/polyfractal/athletic/zipball/51fe4b6e5298dd8af187825a4e57745898e37f0e", + "reference": "51fe4b6e5298dd8af187825a4e57745898e37f0e", + "shasum": "" + }, + "require": { + "nategood/commando": "0.2.1", + "php": ">=5.3.9", + "pimple/pimple": ">=1.0,<3.0", + "zeptech/annotations": "1.1.*" + }, + "require-dev": { + "mikey179/vfsstream": "1.2.*", + "mockery/mockery": "0.8.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "0.6.*" + }, + "bin": [ + "bin/athletic" + ], + "type": "library", + "autoload": { + "psr-0": { + "Athletic": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Zachary Tong" + } + ], + "description": "PHP Benchmarking Framework", + "keywords": [ + "benchmark", + "benchmarking", + "profiling" + ], + "time": "2014-06-03 18:32:22" + }, + { + "name": "kevinlebrun/colors.php", + "version": "0.2.0", + "source": { + "type": "git", + "url": "https://github.com/kevinlebrun/colors.php.git", + "reference": "b13d23b9365ece519abc0eaa77cd3061c5810d30" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kevinlebrun/colors.php/zipball/b13d23b9365ece519abc0eaa77cd3061c5810d30", + "reference": "b13d23b9365ece519abc0eaa77cd3061c5810d30", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Colors": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Le Brun", + "email": "lebrun.k@gmail.com", + "homepage": "http://kevinlebrun.fr", + "role": "developer" + } + ], + "description": "Colors for PHP CLI scripts", + "homepage": "https://github.com/kevinlebrun/colors.php", + "keywords": [ + "cli", + "color", + "colors", + "console", + "shell" + ], + "time": "2012-03-25 18:18:10" + }, + { + "name": "nategood/commando", + "version": "0.2.1", + "source": { + "type": "git", + "url": "https://github.com/nategood/commando.git", + "reference": "b8e475d08a6ff1c0f2b89391e777c4e71fc1a6e1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nategood/commando/zipball/b8e475d08a6ff1c0f2b89391e777c4e71fc1a6e1", + "reference": "b8e475d08a6ff1c0f2b89391e777c4e71fc1a6e1", + "shasum": "" + }, + "require": { + "kevinlebrun/colors.php": "0.2.*", + "php": ">=5.3" + }, + "type": "library", + "autoload": { + "psr-0": { + "Commando": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nate Good", + "email": "me@nategood.com", + "homepage": "http://nategood.com" + } + ], + "description": "PHP CLI Commando Style", + "homepage": "http://github.com/nategood/commando", + "keywords": [ + "automation", + "cli", + "command", + "command line", + "command line interface", + "scripting" + ], + "time": "2012-10-07 15:35:37" + }, { "name": "ocramius/instantiator", "version": "1.1.3", @@ -978,6 +1123,52 @@ ], "time": "2014-09-06 17:32:37" }, + { + "name": "pimple/pimple", + "version": "v2.1.1", + "source": { + "type": "git", + "url": "https://github.com/fabpot/Pimple.git", + "reference": "ea22fb2880faf7b7b0e17c9809c6fe25b071fd76" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fabpot/Pimple/zipball/ea22fb2880faf7b7b0e17c9809c6fe25b071fd76", + "reference": "ea22fb2880faf7b7b0e17c9809c6fe25b071fd76", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "Pimple": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Pimple is a simple Dependency Injection Container for PHP 5.3", + "homepage": "http://pimple.sensiolabs.org", + "keywords": [ + "container", + "dependency injection" + ], + "time": "2014-07-24 07:10:08" + }, { "name": "sebastian/comparator", "version": "1.0.0", @@ -1451,6 +1642,46 @@ "description": "Symfony Yaml Component", "homepage": "http://symfony.com", "time": "2014-08-31 03:22:04" + }, + { + "name": "zeptech/annotations", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/pgraham/php-annotations.git", + "reference": "9cd042daa9ace184d04b49f0605edf73f19a9c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pgraham/php-annotations/zipball/9cd042daa9ace184d04b49f0605edf73f19a9c71", + "reference": "9cd042daa9ace184d04b49f0605edf73f19a9c71", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "zpt\\anno": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "authors": [ + { + "name": "Philip Graham", + "email": "philip@zeptech.ca" + } + ], + "description": "DOC Block annotation parsing for PHP", + "homepage": "https://github.com/pgraham/php-annotations", + "keywords": [ + "annotations" + ], + "time": "2013-05-29 02:35:23" } ], "aliases": [