Best way to test Proc speed

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Best way to test Proc speed

Post by ComputerTech »

So is this a good/best way to test the proc speed?

Code: Select all

bind PUB - "!test" speed:test

proc speed:test {nick host hand chan text} {
set start [clock clicks]
putquick "MODE $chan +o $nick"
set end [clock clicks]
puthelp "PRIVMSG $chan : Timespan: [expr ($end-$start)/1000.0]ms"
}
(Found this code from http://forum.egghelp.org/viewtopic.php?t=20784 | thanks to caesar)
ComputerTech
w
willyw
Revered One
Posts: 1200
Joined: Thu Jan 15, 2009 12:55 am

Re: Best way to test Proc speed

Post by willyw »

Check out:

http://www.tcl.tk/man/tcl8.6/TclCmd/time.htm

You'll find it interesting.

After that, you might like to visit:

https://www.tcl.tk/man/tcl8.5/tutorial/Tcl39.html

too.

I hope this helps.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

thanks willyw, appreciate it :wink:
ComputerTech
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Just thought i'd post my finished working proc speed test code :lol:

Code: Select all

bind PUB - "!speed" do:test

proc proc:name {nick host hand chan text} {
putserv "PRIVMSG $chan :foo"
}

proc do:test {nick host hand chan text} {
set foo [ time {proc:name $nick $host $hand $chan $text} 1]
set aoo [lindex [split $foo] 0]
set qoo "[expr {$aoo / 1000.00}]ms"
puthelp "PRIVMSG $chan :Proc Name : $tproc"
puthelp "PRIVMSG $chan :Proc Speed: $qoo"
}
ComputerTech
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The clock clicks should yield the same results.
Once the game is over, the king and the pawn go back in the same box.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Just curious why the "time" command yields different milliseconds each time

Code: Select all

125 microseconds per iteration
% time {puts "hello"} 1
hello
121 microseconds per iteration
% time {puts "hello"} 1
hello
126 microseconds per iteration
% time {puts "hello"} 1
hello
126 microseconds per iteration
% time {puts "hello"} 1
hello
126 microseconds per iteration
% time {puts "hello"} 1
hello
123 microseconds per iteration
% time {puts "hello"} 1
hello
92 microseconds per iteration
%
^^ on tclsh :P
ComputerTech
User avatar
CrazyCat
Revered One
Posts: 1247
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Just because the cpu could be used for other / different things and not 100% of the cpu (nor the same percentage) is dedicated to tclsh.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Okay, so what would be an alternative way to test proc speed and not rely on CPU ? would need exact 0.00seconds to compare different procs :P

thanks in advanced
ComputerTech
User avatar
CrazyCat
Revered One
Posts: 1247
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

You can't.
"Proc speed" means nothing, it can only be compared to another one.

But you can use time with a greater number of iteration (I usually use 1000), it will give you an average speed which is more relevant

Edit: you can find short infos on https://wiki.tcl-lang.org/page/How+to+M ... erformance
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Thanks CrazyCat :wink:
ComputerTech
Post Reply