#1 2019-05-23 16:48:41

DKA
Member
Registered: 2016-07-05
Posts: 39

TWinHTTP.Get Elapsed time

Hello mORMot users,

I'm using my own OSRM routing service on my virtual machine.
I'm running an OSM query (someting like http://127.0.0.1:5000/route/v1/driving/...) over a delphi program (XE 6 Ent).
the CMD window show me the elapsed time (2 lines per call)

Examples:

[info] 23-05-2019 18:26:47 4.29234ms 127.0.0.1 - Mozilla/5.0 (Windows; mORMot 1.18 TWinHTTP) 200 /route/v1/driving/...
[info] 23-05-2019 18:26:48 5.1023ms 127.0.0.1 - Mozilla/5.0 (Windows; mORMot 1.18 TWinHTTP) 200 /route/v1/driving/...

[info] 23-05-2019 18:26:49 5.11134ms 127.0.0.1 - Mozilla/5.0 (Windows; mORMot 1.18 TWinHTTP) 200 /route/v1/driving/...
[info] 23-05-2019 18:26:50 4.87088ms 127.0.0.1 - Mozilla/5.0 (Windows; mORMot 1.18 TWinHTTP) 200 /route/v1/driving/...

The sum is arround 10 milliseconds.

The Delphi program is looking like that:
...
  httpVar :=  'http://127.0.0.1:5000/route/v1/driving/...';
  Stopwatch := TStopwatch.StartNew;
  JSONContent := _Json(TWinHTTP.Get(httpVar));  //JSONContent is mORMot RawJSON Type
  Elapsed := Stopwatch.Elapsed;
  MilliSeconds:=elapsed.Milliseconds;
  MemResult.lines.Add(FloatToStr(MilliSeconds) + ' ms');
...
The elapsed time is arround 50 milliseconds.

Is this difference normal? Do I have a way to reduce this duration in Delphi?

Thanks.

Last edited by DKA (2019-05-23 16:52:12)

Offline

#2 2019-05-24 10:56:37

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,570
Website

Re: TWinHTTP.Get Elapsed time

Are you shure in your measurement tool? Try to use SynCommons.TPrecisionTimer instead

var t: TPrecisionTimer
...
t.Start;
// do task
t.stop;
MemResult.lines.Add(t.time)

Offline

#3 2019-05-27 09:23:51

DKA
Member
Registered: 2016-07-05
Posts: 39

Re: TWinHTTP.Get Elapsed time

Thanks a lot MPV for answering.

First you are rigth about the measurement tool. Accurate for 1 call but not accurate for 1000 call.

Second, if I use TPrecisionTimer, the result is the same: 50 ms per call (cmd windows still showing 5 or 6 ms).

Offline

#4 2019-05-27 11:05:35

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,612
Website

Re: TWinHTTP.Get Elapsed time

On the localhost/loopback interface, we should expect better numbers, you are right.

I have observed that TWinHTTP may be slower in some cases, due to some obscure Windows or AntiVirus security "features".

Try to use the client socket version instead - which is the best option for plain http over 127.0.0.1.

Offline

#5 2019-05-27 12:50:28

DKA
Member
Registered: 2016-07-05
Posts: 39

Re: TWinHTTP.Get Elapsed time

Thanks ab, I will check this.

Offline

Board footer

Powered by FluxBB