Jump to content

[ Solved ] Need little help from an expert how to calculate


Recommended Posts

Hello

What to do for calculate the $bytes send to calculate the tranfer time.

If I want to send Example a file called test.exe and the size is 17 MB then

I want to calculate the tranfer time depending on the transfer speed.

Is there anybody here can told me or give some code example to show me what I must do

or which formel to do this calculate ?

When I send I use this:

$bytes+=TCPSend($_sock,$data)

Edited by Borje
Link to comment
Share on other sites

  • Moderators

FileGetSize() will give you the file size in bytes.

I would imagine using TimerInit() to start the time before TCPSend() and then TimerDiff() after TCPSend(), then divide that by the number of bytes sent, then multiply it by the number of bytes left to send should give you the milliseconds left.

My God, I don't even know if that makes sense to me!

Something like this maybe:

Local $s_file_to_send = "SomeFile.txt"
Local $i_total_bytes_left = FileGetSize($s_file_to_send)
Local $i_bytes_sent = 0
Local $i_timer, $i_timer_diff
Local $i_send_speed, $i_send_time_left

; Do whatever you're doing in your loop
$i_timer = TimerInit()
$i_bytes_sent = TCPSend(...)
$i_timer_diff = TimerDiff($i_timer)
$i_send_speed = $i_timer_diff / $i_bytes_sent
$i_total_bytes_left -= $i_bytes_sent
$i_send_time_left = ($i_total_bytes_left * $i_send_speed); In milliseconds
This is of course if you're not sending the data in binary hex mode. If that's the case, then you'll need to multiply the original filesize by 2.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Thanks Smoke n for your example

I have test that but can not have that to work

Out of curiousity... are you sending all the data at once?

Also, you'll need to post a replication script so myself or others can see what exactly you did or are doing.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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