std.net.curl : Performance

Daniel Kozak kozzi11 at gmail.com
Mon Nov 9 20:21:34 UTC 2020


Just delete it

On Mon, Nov 9, 2020 at 9:00 PM Vino via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com> wrote:

> Hi All,
>
>    Request your help to on how to improve the performance of the
> below code.
>
> import std.conv: to;
> import std.net.curl : get, HTTP, CurlOption;
> import std.parallelism: parallel;
> import std.range: chain, only;
> import std.typecons: Tuple, tuple;
>
> void main ()
> {
>   Array!(Tuple!(int,string)) apidata;
>   Row[] result;
>   string apihost = "abc.com"; int apiport = 1830; string apiuri =
> /getdata;
>   string apiuser = "user"; string apipass = "pass";
>   foreach(i, k; parallel(result,1))
>      {
>        string url = chain(apihost, only(':'), to!string(apiport),
> apiuri).to!string;
>        string usrpass = chain(apiuser, only(':'),
> apipass).to!string;
>        auto https = HTTP();
>        https.handle.set(CurlOption.buffersize, 512000);
>        https.handle.set(CurlOption.userpwd, usrpass);
>        https.handle.set(CurlOption.connecttimeout, 600);
>        https.handle.set(CurlOption.tcp_nodelay, 1);
>        https.handle.set(CurlOption.http_version, 2);
>        https.handle.set(CurlOption.sslversion,  1;
>        https.handle.set(CurlOption.use_ssl,  3);
>        https.handle.set(CurlOption.ssl_verifypeer, 0);
>        https.handle.set(CurlOption.url, url);
>        https.method(HTTP.Method.get);
>        https.StatusLine st;
>        https.onReceiveStatusLine = (https.StatusLine st) { if
> (st.code != 200) { throw new Exception(st.reason); } };
>        ubyte[] content;
>        https.onReceive = (ubyte[] data) { content ~= data; return
> data.length; };
>        https.perform();
>        scope(failure) { https.shutdown; exit(-4); } scope(exit)
> https.shutdown;
>        apidata.insert(tuple(seq, cast(string) content));
>   }
>   return apidata[].sort;
> }
>
> From,
> Vino.B
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20201109/676d7dfb/attachment.htm>


More information about the Digitalmars-d-learn mailing list