performance discrepency in binary scan

From: Aamer Akhter (aakhter_at_gmail.com)
Date: 02/23/05


Date: 23 Feb 2005 09:06:43 -0800

Folks,

I'm using the tcllib ip package, and added these to procs:

proc ::ip::ToInteger {ip} {
    binary scan [ip::Normalize4 $ip] I out
    return $out
}

proc ::ip::ToHex {ip} {
    binary scan [ip::Normalize4 $ip] H8 out
    return "0x$out"
}

I then timed the difference:

% time {ip::ToInt 0.0.0.1} 100000
97 microseconds per iteration

% time {ip::ToHex 0.0.0.1} 100000
12 microseconds per iteration

% info patchlevel
8.4.6

Thoughts?



Relevant Pages