Jump to content

Recommended Posts

Posted
TCPStartup()
;
Local $nListen = TCPListen('127.0.0.1', 61000)
Local $timer, $timerdiff, $nSocket
;
Do
    $timer = TimerInit()
    $nSocket = TCPAccept($nListen)
    $timerdiff = TimerDiff($timer)
    MsgBox(0, '', Round($timerdiff, 1) & ' ms', 2)
Until $nSocket > 0

Function:
TCPAccept()

Affected:
All versions from v3.3.10.0 to v3.3.15.0.

Problem:
Depending on what computer and OS is used, TCPAccept is 7 to 10 times
slower than v3.3.8.1.

Explanation:
Some time ago, I noticed that TCPRecv loops seemed slower than with
previous versions. I had no idea what the problem could be, nor did
I have the time to trouble-shoot the problem. The loop was working,
but not as fast as before. I had been using my own WSA code for TCP,
so I wasn't too concerned about it.

After some extensive testing, trying to figure out an unrelated issue
from one of our members, I discovered that TCPAccept was the problem.

The reproducer script will show the difference between v3.3.8.1 and
newer versions, starting with v3.3.10.0.

My Timer Results using v3.3.8.1:
0.85 to 15.0 ms

My Timer Results using newer versions:
102.0 to 110.0 ms

Conclusion:
This problem may not appear to be a big issue, but when you're
transferring data 7 to 10 times slower than normal, it makes a
difference. Especially, since typical TCPRecv speed is 10ms and
TCPAccept is in the same main loop.

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted

Deye,

Thanks for the link, but this is specific to the internal code of AutoIt.
It will benefit the AutoIt community to correct it by a developer.

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted

Here is a TCPAccept alternative which was made as an #include.

From my tests, it's faster than 3.3.8.1 -- runs at about 1 ms or less.

Here is the test script for it...

#include 'WSA_TCPAccept.au3'

TCPStartup()
;
Local $nListen = TCPListen('127.0.0.1', 61000)
Local $timer, $timerdiff, $nSocket, $error
;
Do
    $timer = TimerInit()
    $nSocket = _WSA_TCPAccept($nListen)
    $error = @error
    $timerdiff = TimerDiff($timer)
    MsgBox(0, 'Error: ' & $error, Round($timerdiff, 3) & ' ms', 2)
Until $nSocket > 0
;
TCPShutdown()

And here is the include...

WSA_TCPAccept.au3

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...