Forum Discussion
smp_86112
Cirrostratus
Feb 02, 2010Efficiency of String Comparison
Which statement is more efficent in terms of processing?
[HTTP::uri] equals "/"
or
[HTTP::uri] == "/"
According to my interpretation of the official TCL d...
hoolio
Cirrostratus
Mar 04, 2010Using time (Click here) in tclsh, it looks like eq is more efficient when the two operands aren't equal. Maybe == can do two checks: the first as numeric and the second as strings if the first check doesn't match. Just a guess...
eq versus == is the same when the operands are identical strings
% time {expr {"a" eq "a"}} 1000000
1 microseconds per iteration
% time {expr {"a" == "a"}} 1000000
1 microseconds per iteration
eq versus == is shows eq is more efficient when the operands are not the same
% time {expr {"a" eq "b"}} 1000000
1 microseconds per iteration
% time {expr {"a" == "b"}} 1000000
2 microseconds per iteration
I'll try testing this in an iRule at some point as well.
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects