Running HttpSoft implementation agains set of tests
vasily-kartashov opened this issue · 3 comments
I compiled this list of tests for http-message spec: https://github.com/hamlet-framework/http-message-spec
The tests are kept as traits, so it shouldn't be a problem to reuse in your project if the need arises. In any case, there are few issues, feel free to check out the latest master and run all tests/HttpSoft*
for more details. One notable issue is how you handle Host
header.
Also, my benchmark results look quite different from yours:
Comprehensive test
+----------------------+--------------------+-------------------+--------------+
| Function description | Execution time (s) | Memory usage (mb) | Times faster |
+----------------------+--------------------+-------------------+--------------+
| ring-central | 4.0299 | 0.0970 | 14% |
| nyholm | 4.5991 | 0.1470 | 12% |
| guzzle | 5.1903 | 0.3000 | 13% |
| hamlet-framework | 5.8748 | 0.3160 | 31% |
| zend-diactoros | 7.6987 | 0.1780 | 3% |
| http-soft | 7.9331 | 0.1530 | 25% |
| wind-walker | 9.9951 | 0.3440 | 0 |
+----------------------+--------------------+-------------------+--------------+
Fetching test
+----------------------+--------------------+-------------------+--------------+
| Function description | Execution time (s) | Memory usage (mb) | Times faster |
+----------------------+--------------------+-------------------+--------------+
| hamlet-framework | 1.7709 | 0.0000 | 17% |
| ring-central | 2.0741 | 0.0000 | 3% |
| nyholm | 2.1567 | 0.0000 | 4% |
| guzzle | 2.2612 | 0.0000 | 44% |
| zend-diactoros | 3.2708 | 0.0010 | 12% |
| wind-walker | 3.6730 | 0.0010 | 6% |
| http-soft | 3.9247 | 0.0000 | 0 |
+----------------------+--------------------+-------------------+--------------+
Thanks.
As I understand it, you are testing a request, it is slower than the others due to the creation of a thread https://github.com/httpsoft/http-message/blob/master/src/StreamTrait.php#L344.
The "Host" header is processed in accordance with: https://tools.ietf.org/html/rfc7230#section-5.4.
Here https://github.com/devanych/psr-http-benchmark a simple creating objects of all classes, including all factories.
This is the code for benchmark: https://github.com/hamlet-framework/http-message-spec/blob/master/scripts/benchmarks.php As you can see the code is identical across different implementations of http-message. How does it disadvantage httpsoft/http-message
?
Request only: https://github.com/hamlet-framework/http-message-spec/blob/master/scripts/benchmarks.php
If the stream was not passed, the request slows down because of this: https://github.com/httpsoft/http-message/blob/master/src/StreamTrait.php#L344.