Forum Discussion
smp_86112
Cirrostratus
Jun 24, 2010Optimizing If statement conditions
I see this examples like this all over the place:
when HTTP_REQUEST {
if { [HTTP::host] equals "www.myhost.com" and [HTTP::uri] equals "/myuri" } {
HTTP::redirect https://[HTTP::host][HTTP::...
smp_86112
Cirrostratus
Jun 28, 2010You are absolutely right hoolio. I did the test again, this time setting the strings to lowercase in both conditions. It seems the consolidated statement is still faster, and the difference is a bit wider in this case. I won't post the whole thing anymore, just the avg-cycles:
timing on
when HTTP_REQUEST {
if { [string tolower [HTTP::host][HTTP::uri]] equals "www.myhost.com/admin" } {
HTTP::uri "/new_uri"
}
}
avg-cycles 14762
avg-cycles 14892
avg-cycles 14804
timing on
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "www.myhost.com" and [string tolower [HTTP::uri]] equals "/admin" } {
HTTP::uri "/new_uri"
}
}
avg-cycles 16219
avg-cycles 16526
avg-cycles 16626Recent 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
