This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

File transfer speed calculator

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
a
andrii
Voice
Posts: 3
Joined: Mon Dec 08, 2008 6:30 am

File transfer speed calculator

Post by andrii »

Hello guys.

I'm wondering that does there already exist, or can any of you tell me how to create a script that calculates data transfer speed and estimated time?

Lets say: I need to download a 100mb file, and i can dl it like 20kb/s.

The script should calculate the time for 100megs if the average dl speed is 20kilobytes/sec. And It should also work another way around. We want to know how much data we can move in 1 hours, if the transferring speed is 20kb/s.

I don't have that strong programming skills that I could create something like this on my own. However, If i can get access to some sort of source, I may be able to finish it myself.



Humbly,

Andrii
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

100 / 0.02 = ~5000 seconds

1 hour = 3600 sec
3600 * 0.02 = ~72MB

but this depeds from many other things, this is just simple calculating, its hard to get real speed :)

u can always calculate like 1MB = 1024 KB, not 1000

but this still will be only theoretical
a
andrii
Voice
Posts: 3
Joined: Mon Dec 08, 2008 6:30 am

Post by andrii »

tomekk wrote:100 / 0.02 = ~5000 seconds

1 hour = 3600 sec
3600 * 0.02 = ~72MB

but this depeds from many other things, this is just simple calculating, its hard to get real speed :)

u can always calculate like 1MB = 1024 KB, not 1000

but this still will be only theoretical
Thank you tomekk for doing the math for me :D

And yes, the script should provide a theoretical indication, not precise one.
However, this is not the thing I was looking for.

I believe(and I hope) that I'll manage the mathematics part on my own.
What I was hoping is that someone could offer or help me to create the script(and by script, i mean the code part).
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

Code: Select all

# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

bind pub - !m2t megs_to_time_proc
bind pub - !t2m time_to_kbs_proc

proc megs_to_time_proc { nick uhost hand chan arg } {
	set our_args [split $arg]
	set megs [lindex $our_args 0]
	set kilobytes_speed [lindex $our_args 1]

	if {([regexp {^([0-9]+)$} $megs]) && ([regexp {^([0-9]+)$} $kilobytes_speed])} {
		set megs_to_kilobytes [expr $megs * 1024]
		set need_time [expr $megs_to_kilobytes / $kilobytes_speed]

		set the_time [expr {round($need_time) / 60}]

		set r_hours [expr $the_time / 60]
		set r_minutes [expr $the_time - ($r_hours * 60)]

		if {(($r_hours >= 0) && ($r_minutes > 0)) || (($r_hours > 0) && ($r_minutes == 0))} { 
			putquick "PRIVMSG $chan :time ~~ $r_hours hour/s, $r_minutes minute/s"
		} else {
			putquick "PRIVMSG $chan :time ~~ less than one minute"
		}
	}
}

proc time_to_kbs_proc { nick uhost hand chan arg } {
	set our_args [split $arg]
	set minutes [lindex $our_args 0]
	set kilobytes_speed [lindex $our_args 1]

	if {([regexp {^([0-9]+)$} $minutes]) && ([regexp {^([0-9]+)$} $kilobytes_speed])} {
		set minutes_to_secs [expr $minutes * 60]
		set need_kilobytes [expr {double($minutes_to_secs * $kilobytes_speed)}]

		set the_megs [expr {double($need_kilobytes / 1000)}]

		putquick "PRIVMSG $chan :u can transfer ~~ $the_megs MB"
	}
}

putlog "transfers.tcl ver 0.1 by tomekk loaded"
manual:
!m2t <megs> <kilobytes>, !m2t 100 20 = ~ 1 hour, 25 minutes
!t2m <minutes> <kilobytes>, !t2m 100 20 = ~120.0 MB

try :>
a
andrii
Voice
Posts: 3
Joined: Mon Dec 08, 2008 6:30 am

File transfer speed calculator

Post by andrii »

Thank you tomekk!

This is perfect!

//A
Post Reply