rah_runtime

Published under current TXP projects

Rah_runtime returns runtimes from point A to B in microseconds. The plugin can be used to diagnose runtimes of specific blocks of Textpattern’s markup code.

Download rah_runtime v0.3

Image: rah_runtime

Image: rah_runtime

Requirements

Installation and usage

The general behavior stands:

  1. Go to your Textpattern installation’s admin panel.
  2. Navigate to Admin / Plugins.
  3. Download and open the plugin code.
  4. Copy the plugin code to the install plugin box.
  5. Click install and go thru the automated installation process.
  6. After installation find the plugin from the plugin list and click Activate.
  7. Now the plugin is installed and ready to be used.

Attributes

The tag is <txp:rah_runtime /> and attributes for it follow.

index
With this attribute you can nest several tag pairs and count several independent runtimes.
Example: index="1" Default: "0"

format
Return formated version of the time. Will make the time respect power of ten, and SI units smaller than microsends won’t be returned, just microsends with decimals. By default, used (1).
Example: format="0" Default: "1"

persistent
If set to 1, the runtime is kept alive after outputting the time. Normally the runtime pair is destroyed after using it, but with persistent the initial runtime is still usable. The attribute is useful, if you want to calculate multiple runtimes from same single starting point.
Example: persistent="1" Default: "0"

Examples

Simple usage:

<txp:rah_runtime />
	<!--
		Some code here, for example:
		<txp:article />
	-->
Runtime: <txp:rah_runtime />

Returns: [...] Runtime: 0.000011

Using multiple nested tag pairs:

<txp:rah_runtime index="2" />
<txp:rah_runtime index="1" />
Time1: <txp:rah_runtime index="1" />
Time2: <txp:rah_runtime index="2" />

Returns: Time1: 0.000081 Time2: 0.000184

Using persistent runtimes:

<!--
	Start the runtime timer
-->
<txp:rah_runtime persistent="1" />
	<!--
		Some code here, for example:
		<txp:article />
	-->
<!--
	Output runtime
-->
<txp:rah_runtime persistent="1" />
	<!--
		Some more code here, for example:
		<txp:article />
	-->
<!--
	Output runtime, calculated
	from the same original starting point
-->
<txp:rah_runtime persistent="1" />
	<!--
		Even some more code.
	-->
<!--
	Destroy and output the final runtime,
	calculated from the same original starting point
-->
<txp:rah_runtime />

Note that every one of the tags has persistent attribute. If the tag doesn’t have it, then the runtime pair is destroyed after outputting it. To finally destroy the runtime, set persistent to "0" (zero) or remove the attribute.

Changelog

Version 0.3

Version 0.2

Version 0.1