timing

Description

The timing command can be used to enable iRule timing statistics. This will then collect timing information as specified each time the rule is evaluated. Statistics may be viewed with “b rule show all” or in the Statistics tab of the iRules Editor.
Note: In 11.5.0, timing was enabled by default for all iRules in BZ375905. The performance impact is negligible. As a result, you no longer need to use this command to view timing statistics.

You’ll likely only want to look at the average and min numbers as max is often way, way out there due to the optimizations being performed on the first run of the rule. By “optimizations” we mean that TMM is doing its normal data inspection/collection routine which is performed for each new connection. This process allows you to use the streamlined, cached values later in your iRules, such as HTTP::host and IP::local_addr. This process is more resource intensive than a normal pass through the iRule and as such will offset the “max” statistics, hence the need to throw out this number when scoping your iRule usage.
Enabling timing does have negligible overhead so you shouldn’t need to worry about leaving it enabled.

Syntax

timing <on |off>
when EVENT_NAME { <iRule code> }

when EVENT_NAME timing <on | off>{ <iRule code> }

timing <on |off>

  • When the timing command is issued before a “when EVENT_NAME” declaration in an iRule, timing is enabled or disabled for the remainder of the iRule.

when EVENT_NAME timing <on |off> { <iRule code> }

  • Use the timing command after the “when EVENT_NAME” and before its braces to enable or disable timing only for that specified event.

Examples

To enable timing for the entire rule:
timing on
when RULE_INIT {
  log local0. "Rule initialized with timing enabled."
}
when HTTP_REQUEST {
  pool my_pool
}

To enable timing for just one event:
when RULE_INIT {
  log local0. "Rule initialized -- timing not enabled."
}
when HTTP_REQUEST timing on {
  log local0. "This event only is being timed"
  pool my_pool
}

To enable, selectively disable, then disable timing:
rule foo {
  timing on
  when HTTP_REQUEST {
    ...
  }
  when CLIENT_ACCEPTED timing off {
    ...
  }
  timing off
  when SERVER_CONNECTED {
    ...
  }
}