├── .gitignore ├── README.md ├── benchmark.php ├── cakephp └── composer.json ├── curl └── composer.json ├── guzzle5 └── composer.json ├── guzzle6 └── composer.json ├── react └── composer.json ├── server.php ├── socket └── composer.json └── zend └── composer.json /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | composer.lock -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Disclaimer 2 | 3 | Yes it's a useless benchmark that doesn't take all use cases into account, 4 | but i did this for my own curiosity. So if X library is not well configured because of Y feel 5 | free to do a PR or we can discuss it into an issue. 6 | 7 | ## cakephp 8 | 9 | Request counts : 50000 10 | Average time per request : 0.22ms 11 | Request per second : 4545.4545454545 12 | Total time 11 13 | 14 | ## curl 15 | 16 | Request counts : 50200 17 | Average time per request : 0.2191235059761ms 18 | Request per second : 4563.6363636364 19 | Total time 11 20 | 21 | ## guzzle5 22 | 23 | Request counts : 34800 24 | Average time per request : 0.31609195402299ms 25 | Request per second : 3163.6363636364 26 | Total time 11 27 | 28 | ## guzzle6 29 | 30 | Request counts : 41800 31 | Average time per request : 0.26315789473684ms 32 | Request per second : 3800 33 | Total time 11 34 | 35 | ## react 36 | 37 | Request counts : 37800 38 | Average time per request : 0.29100529100529ms 39 | Request per second : 3436.3636363636 40 | Total time 11 41 | 42 | ## socket 43 | 44 | Request counts : 66100 45 | Average time per request : 0.16641452344932ms 46 | Request per second : 6009.0909090909 47 | Total time 11 48 | 49 | ## zend 50 | 51 | Request counts : 36600 52 | Average time per request : 0.30054644808743ms 53 | Request per second : 3327.2727272727 54 | Total time 11 55 | -------------------------------------------------------------------------------- /benchmark.php: -------------------------------------------------------------------------------- 1 | \Http\Adapter\Zend\Client::class, 'condition' => \Http\Adapter\Zend\Client::class], 12 | ['class' => \Http\Adapter\Cake\Client::class, 'condition' => \Http\Adapter\Cake\Client::class] 13 | ]; 14 | } 15 | }; 16 | 17 | \Http\Discovery\HttpClientDiscovery::appendStrategy(MissingStrategies::class); 18 | 19 | $client = \Http\Discovery\HttpClientDiscovery::find(); 20 | $pluginClient = new \Http\Client\Common\PluginClient($client, [ 21 | new \Http\Client\Common\Plugin\ContentLengthPlugin(), 22 | new \Http\Client\Common\Plugin\DecoderPlugin() 23 | ]); 24 | 25 | $httpClient = new \Http\Client\Common\HttpMethodsClient($pluginClient, \Http\Discovery\MessageFactoryDiscovery::find()); 26 | 27 | $duration = 10; 28 | $start = time(); 29 | $request = 0; 30 | 31 | while (true) { 32 | $httpClient->get('http://127.0.0.1:8081'); 33 | $request++; 34 | 35 | if (($request % 100) === 0) { 36 | if ((time() - $start) > $duration) { 37 | break; 38 | } 39 | } 40 | } 41 | 42 | $totalTime = time() - $start; 43 | 44 | echo "Request counts : " . $request . "\n"; 45 | echo "Average time par request : " . ($totalTime / $request) * 1000 . "ms\n"; 46 | echo "Request per second : " . $request / $totalTime . "\n"; 47 | echo "Total time " . $totalTime . "\n"; 48 | 49 | -------------------------------------------------------------------------------- /cakephp/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jwurtz/http-client-benchmark-curl", 3 | "type": "project", 4 | "require": { 5 | "php-http/cakephp-adapter": "dev-master", 6 | "php-http/httplug": "^1.1", 7 | "php-http/discovery": "^1.2", 8 | "php-http/client-common": "^1.4", 9 | "php-http/message-factory": "^1.0", 10 | "php-http/message": "^1.5", 11 | "guzzlehttp/psr7": "^1.4" 12 | }, 13 | "license": "MIT", 14 | "authors": [ 15 | { 16 | "name": "Joel Wurtz", 17 | "email": "jwurtz@jolicode.com" 18 | } 19 | ], 20 | "minimum-stability": "stable" 21 | } 22 | -------------------------------------------------------------------------------- /curl/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jwurtz/http-client-benchmark-curl", 3 | "type": "project", 4 | "require": { 5 | "php-http/curl-client": "^1.7", 6 | "php-http/httplug": "^1.1", 7 | "php-http/discovery": "^1.2", 8 | "php-http/client-common": "^1.4", 9 | "php-http/message-factory": "^1.0", 10 | "php-http/message": "^1.5", 11 | "guzzlehttp/psr7": "^1.4" 12 | }, 13 | "license": "MIT", 14 | "authors": [ 15 | { 16 | "name": "Joel Wurtz", 17 | "email": "jwurtz@jolicode.com" 18 | } 19 | ], 20 | "minimum-stability": "stable" 21 | } 22 | -------------------------------------------------------------------------------- /guzzle5/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jwurtz/http-client-benchmark-curl", 3 | "type": "project", 4 | "require": { 5 | "php-http/guzzle5-adapter": "^1.0", 6 | "php-http/httplug": "^1.1", 7 | "php-http/discovery": "^1.2", 8 | "php-http/client-common": "^1.4", 9 | "php-http/message-factory": "^1.0", 10 | "php-http/message": "^1.5", 11 | "guzzlehttp/psr7": "^1.4" 12 | }, 13 | "license": "MIT", 14 | "authors": [ 15 | { 16 | "name": "Joel Wurtz", 17 | "email": "jwurtz@jolicode.com" 18 | } 19 | ], 20 | "minimum-stability": "stable" 21 | } 22 | -------------------------------------------------------------------------------- /guzzle6/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jwurtz/http-client-benchmark-curl", 3 | "type": "project", 4 | "require": { 5 | "php-http/guzzle6-adapter": "^1.1", 6 | "php-http/httplug": "^1.1", 7 | "php-http/discovery": "^1.2", 8 | "php-http/client-common": "^1.4", 9 | "php-http/message-factory": "^1.0", 10 | "php-http/message": "^1.5", 11 | "guzzlehttp/psr7": "^1.4" 12 | }, 13 | "license": "MIT", 14 | "authors": [ 15 | { 16 | "name": "Joel Wurtz", 17 | "email": "jwurtz@jolicode.com" 18 | } 19 | ], 20 | "minimum-stability": "stable" 21 | } 22 | -------------------------------------------------------------------------------- /react/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jwurtz/http-client-benchmark-curl", 3 | "type": "project", 4 | "require": { 5 | "php-http/react-adapter": "^0.3", 6 | "php-http/httplug": "^1.1", 7 | "php-http/discovery": "^1.2", 8 | "php-http/client-common": "^1.4", 9 | "php-http/message-factory": "^1.0", 10 | "php-http/message": "^1.5", 11 | "guzzlehttp/psr7": "^1.4" 12 | }, 13 | "license": "MIT", 14 | "authors": [ 15 | { 16 | "name": "Joel Wurtz", 17 | "email": "jwurtz@jolicode.com" 18 | } 19 | ], 20 | "minimum-stability": "stable" 21 | } 22 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 |