Jump to content

SpeedTest


Recommended Posts

I'm having some real trouble getting my speed test to work. All I want to do is download/upload a file and time how long it takes.

Seems easy but it just isn't working. Am I supposed to release Timerinit()? Do I keep adding to the same variable somehow? That's really what it looks like is happening but I'm pretty new to this.

$DownTime = TimerInit()
FileCopy("data1FrontUtilitytestfilerandom.jpg","c:testfile.jpg",1)
$DownTimeEnd = TimerDiff($DownTime)
$PreRound = TimerDiff($DownTimeEnd / 1000)
$DSpeed = Round($PreRound,2)
$UptTime = TimerInit()
FileCopy("c:testfile.jpg","data1FrontUtilitytestfileuser.jpg",1)
$UptTimeEnd = Round(TimerDiff($UptTime / 1000),2) ; Is this too many things to do at once??
FileDelete("data1FrontUtilitytestfileuser.jpg")
MsgBox(1,"Down " & $DSpeed, "Up " & $UptTimeEnd)

I'm really banging my head against the wall on this.

I had a different version that also worked ok but certainly better than the upper code did. The upper solution is a much better solution if it would work.

Local $begin = TimerInit()
Local $hDownload = InetGet("http://upload.wikimedia.org/wikipedia/en/2/2f/EN004_Moon_with_a_Past.jpg", @TempDir & "Moon.jpg", 1, 0)
$EndCount = TimerDiff($begin / 1000)
$hDownloadSize = InetGetSize("http://upload.wikimedia.org/wikipedia/en/2/2f/EN004_Moon_with_a_Past.jpg", 1)
$avg = ($hDownloadSize / ($EndCount / 1000))
Local $nBytes = InetGetInfo($hDownload, 0)
InetClose($hDownload) ; Close the handle to release resources.

FileWrite($file, "Bytes read: " & (Round(($hDownloadSize / 1024), 2)) & "KB" & " , at " & Round($avg, 2) & "MB per second" & @CRLF)
Edited by Robonglious
Link to comment
Share on other sites

I'm having some real trouble getting my speed test to work. All I want to do is download/upload a file and time how long it takes.

Seems easy but it just isn't working. Am I supposed to release Timerinit()? Do I keep adding to the same variable somehow? That's really what it looks like is happening but I'm pretty new to this.

$DownTime = TimerInit()
FileCopy("\\data1\Front\Utility\test\file\random.jpg","c:\test\file.jpg",1)
$DownTimeEnd = TimerDiff($DownTime)
$PreRound = TimerDiff($DownTimeEnd / 1000)
$DSpeed = Round($PreRound,2)
$UptTime = TimerInit()
FileCopy("c:\test\file.jpg","\\data1\Front\Utility\test\file\user.jpg",1)
$UptTimeEnd = Round(TimerDiff($UptTime / 1000),2) ; Is this too many things to do at once??
FileDelete("\\data1\Front\Utility\test\file\user.jpg")
MsgBox(1,"Down " & $DSpeed, "Up " & $UptTimeEnd)

I'm really banging my head against the wall on this.

I had a different version that also worked ok but certainly better than the upper code did. The upper solution is a much better solution if it would work.

Local $begin = TimerInit()
Local $hDownload = InetGet("http://upload.wikimedia.org/wikipedia/en/2/2f/EN004_Moon_with_a_Past.jpg", @TempDir & "\Moon.jpg", 1, 0)
$EndCount = TimerDiff($begin / 1000)
$hDownloadSize = InetGetSize("http://upload.wikimedia.org/wikipedia/en/2/2f/EN004_Moon_with_a_Past.jpg", 1)
$avg = ($hDownloadSize / ($EndCount / 1000))
Local $nBytes = InetGetInfo($hDownload, 0)
InetClose($hDownload) ; Close the handle to release resources.

FileWrite($file, "Bytes read: " & (Round(($hDownloadSize / 1024), 2)) & "KB" & " , at " & Round($avg, 2) & "MB per second" & @CRLF)

See TimerDiff function in AutoIt help file.

Dividing the handle parameter by 1000 is wrong.

Link to comment
Share on other sites

  • 2 weeks later...

It still doesn't work very well. I've changed the code around a few times but I've probably just made another mistake.

Most of the time the result of the web lookup is zero, other times the result is way too fast or slow.

You won't be able to run this code but any help would be very helpful.

This code should have three tests, one internet download test, one network file download test and one network upload test.

;internet download test
$begin = TimerInit()
$hDownload = InetGet("https://*****.com/Office%20Listing/Corporate%20Directory/Corporate%20Directory%202012.xls", "c:filespackages.xls", 1, 0)
$EndCount = TimerDiff($begin)
$hDownloadSize = FileGetSize("c:filespackages.xls")
FileDelete("c:filespackages.xls")
$EndCountSec = $EndCount / 1000
$avg = (($hDownloadSize / 1024) / $EndCountSec)
InetClose($hDownload)
GUICtrlSetData($Progress1, ($i / $Time) * 100)
;network download test
$DownTime = TimerInit()
FileCopy("data1FrontUtilitytestfilerandom.jpg", "c:filesfile.jpg", 1)
$DownTimeEnd = TimerDiff($DownTime)
$hData1DLS = FileGetSize("c:filesfile.jpg")
$hDataKB = $hData1DLS / 1024
$PreRound = $DownTimeEnd / 1000
$DSpeed = Round($PreRound, 2)
;network upload test
$UpTime = TimerInit()
FileCopy("c:filesfile.jpg", "data1FrontUtilitytestfileuser" & $Ran & ".jpg", 1)
$UptTimeEnd = TimerDiff($UpTime)
$PreRoundUp = $UptTimeEnd / 1000
$UPSpeed = Round($PreRoundUp, 2)
FileDelete("data1FrontUtilitytestfileuser" & $Ran & ".jpg")
Edited by Robonglious
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...