https://github.com/gocom/rah_runtime
Diagnose Textpattern CMS' execution times
https://github.com/gocom/rah_runtime
Last synced: about 1 year ago
JSON representation
Diagnose Textpattern CMS' execution times
- Host: GitHub
- URL: https://github.com/gocom/rah_runtime
- Owner: gocom
- License: gpl-2.0
- Created: 2012-02-01T02:23:39.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2013-09-25T08:18:46.000Z (over 12 years ago)
- Last Synced: 2025-01-26T11:08:25.500Z (over 1 year ago)
- Language: PHP
- Homepage: http://rahforum.biz/plugins/rah_runtime
- Size: 168 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
- License: LICENSE
Awesome Lists containing this project
README
h1. rah_runtime
"Homepage":http://rahforum.biz/plugins/rah_runtime | "Packagist":https://packagist.org/packages/rah/rah_runtime | "Twitter":https://twitter.com/gocom | "GitHub":https://github.com/gocom/rah_runtime | "Support forum":http://forum.textpattern.com/viewtopic.php?id=33914 | "Donate":http://rahforum.biz/donate/rah_runtime
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.
h2. Basics
bc.
...contained statements...
The plugin introduces a new Textpattern tag, @@. The tag calculates execution runtimes for Textpattern template markuThe runtimes can be printed to the page template and are added to a "tag trace":http://textpattern.net/wiki/index.php?title=Tag_trace.
The rah_runtime tag can be used both as a container and as a self-closing single tag. When the tag is used as a container, it calculates a runtime of the wrapped code. When used as a self-closing single tag, it calculates a runtime from the first tag instance to the second.
h2. Attributes
@@ tag's attributes are as follows.
*return*
If set to @1@, the tag outputs the runtime to the page template. If @0@ the runtime is only added and visible in the page's "tag trace":http://textpattern.net/wiki/index.php?title=Tag_trace when the site is in debugging mode. By default @return@ is @0@, and the runtimes are only added to the tag trace.
Example: @return="1"@ Default: @"0"@
*format*
Return formatted version of the time. When used, resulting value (float) is presented as a fixed decimal number. By default the option is used (@1@).
Example: @format="0"@ Default: @"1"@
*index*
With this attribute you can nest several tag pairs and count several independent runtimes. The @index@ attribute only applies when @@ is used as a self-closing single tag.
Example: @index="articles"@ Default: @"default"@
*persistent*
If set to @1@, the runtime is kept alive after returning. Normally the runtime pair is destroyed after using it, but with @persistent@ the initial runtime is kept and still usable. The attribute is useful if you want to calculate multiple runtimes from same single starting point. The @persistent@ attribute only applies when @@ is used as a self-closing single tag.
Example: @persistent="1"@ Default: @"0"@
h2. Examples
h3. Using as a container
As a container, @rah_runtime@ calculates a runtime for the wrapped content.
bc.
The above will return the contained statement's results, as it would normally without the rah_runtime, and the runtime of the contained statement is added to the page's "tag trace":http://textpattern.net/wiki/index.php?title=Tag_trace. The tag trace should display a line similar to this:
bc. [rah_runtime (default): 0.000010013580322]
h3. Using as a single tag
When the rah_runtime tag is used as a single, self-closing tag, the runtime is calculated from a @@ tag instance to the next. Essentially the runtime is for the markup and code between two @@ tags.
bc.
The above will return all the markup normally, like there weren't any traces of rah_runtime, and the runtime is added to the page's tag trace as a line similar to this:
bc. [rah_runtime (default): 0.000010013580322]
h3. Returning runtimes to the page
Normally the resulting runtimes are added to the "tag trace":http://textpattern.net/wiki/index.php?title=Tag_trace and are not visible in the normal page content. That is unless @return@ attribute is set to @1@.
bc.
Runtime:
The runtime is added to the tag trace and the above will return:
bc. Runtime: 0.00021401458032
h3. Using multiple nested tag pairs
The rah_runtime tag's @index@ attribute can be used to nest and mix multiple @@ tags and runtime pairs together. This will allow calculating simultaneous runtimes that overlap each others.
bc.
Time1:
Time2:
The above will return two runtimes:
bc. Time1: 0.000081
Time2: 0.000184
The _time2_ contains the runtime of _time1_ and more.
h3. Using persistent runtimes
Persistent runtimes are useful when several runtimes are to be calculated from a same starting point.
bc..
p. Note that every one of the rah_runtime tags (except for the last) has @persistent@ attribute set to @1@. If the tag doesn't have it, then the runtime pair is destroyed after returning it. To finally destroy the runtime, set persistent to @"0"@ (zero) or leave it undefined.
h2. Changelog
h3. Version 0.5.0 - upcoming
* Updated: Help file.
h3. Version 0.4 - 2012/07/12
* Added: @return@ attribute.
* Added: Now the runtimes are added to the tag trace.
* Added: Container tag mode support.
* Changed: By default runtimes are only visible in a tag trace. Set @return@ attribute to @1@ (@return="1"@) output runtimes to the page template.
* Changed: Default @index@ to @default@. This is to avoid potential type juggling side-effects.
h3. Version 0.3 - 2011/08/19
* Added: a new attribute @persistent@. Disables destroying of used runtime pairs.
* Changed: Now stores the runtimes in a static variable instead of a global.
h3. Version 0.2 - 2010/06/18
* Fixed: now returns as float (compatible with pre-PHP5). "Thank you for reporting, Andreas":http://forum.textpattern.com/viewtopic.php?pid=230410#p230410.
h3. Version 0.1 - 2010/06/15
* Initial release.