On Friday, 17 June 2016 at 17:31:55 UTC, ikod wrote:
On Tuesday, 14 June 2016 at 14:59:37 UTC, Andrei Alexandrescu wrote:
On 6/11/16 7:03 PM, ikod wrote:
Hello,

Dlang-requests is library created under influence of Python-requests,
with primary goal of easy to use and performance.

...

Thanks! Does the project have a dub presence? How does it compare feature-wise and speed-wise with curl? -- Andrei

Hello,

Finally, I made some improvements and run minimal performance tests against command-line curl. I wrote simple code for file download using dlang-requests, run it and curl for the same urls(httpbin server on my notebook) and compare "total", "system", and "user" time for different cases. You can find numbers and code below. So my conclusion is - performances are comparable for these cases, but there is some field for improvement in dlang-requests.

Case 1 - 50Mb of random data, no any encoding
Case 2 - 50Mb of random data, transfer chunked
Case 3 - 50Mb of random data, transfer chunked, content gzip

          measured times, sec
-----------------------------------------
     |   user    |   system  |   total
 Case|-----------|-----------|-----------
     | d-r | curl|  d-r| curl| d-r | curl
-----|-----|-----|-----|-----|-----|-----
  1  | 0.17| 0.14| 0.20| 0.32| 51.7| 52.2
  2  | 0.19| 0.11| 0.15| 0.21| 51.8| 51.9
  3  | 0.21| 0.15| 0.11| 0.15| 51.5| 52.1

Finally after all unnecessary memory movements were cleaned up, results for dlang-requests and curl almost equals.

          measured times, sec
 -----------------------------------------
      |   user    |   system  |   total
  Case|-----------|-----------|-----------
      | d-r | curl|  d-r| curl| d-r | curl
 -----|-----|-----|-----|-----|-----|-----
   1  | 0.14| 0.14| 0.15| 0.32| 53.3| 52.2
   2  | 0.13| 0.11| 0.11| 0.21| 51.1| 51.9
   3  | 0.18| 0.15| 0.08| 0.15| 51.2| 52.1



import std.stdio;
import requests;

pragma(lib, "ssl");
pragma(lib, "crypto");

void main()
{
    auto sink = File("/dev/null", "wb");
    auto rq = Request();
    rq.useStreaming = true;
auto rs = rq.get("http://127.0.0.1:8080/stream-bytes/51200000";);
    auto stream = rs.receiveAsRange();
    while(!stream.empty) {
        sink.rawWrite(stream.front);
        stream.popFront;
    }
}


Reply via email to