ds_profile (public)

 ds_profile command [ tag ]

Defined in packages/acs-developer-support/tcl/acs-developer-support-procs.tcl

Helper proc for performance profiling of templates. This will record the total time spent within an invocation of a template (computed as time between the 'ds_profile start' and 'ds_profile stop' invocations inserted by the template engine).

Parameters:
command - Must be "start" or "stop".
tag (optional) - In practice, the path to the template being profiled.
  • start marks the beginning of a block.
  • stop marks the end of a block. Start and stops must match.

Partial Call Graph (max 5 caller/called nodes):
%3 test_ds_add_test ds_add_test (test acs-developer-support) ds_profile ds_profile test_ds_add_test->ds_profile ds_add ds_add (public) ds_profile->ds_add ds_enabled_p ds_enabled_p (public) ds_profile->ds_enabled_p

Testcases:
ds_add_test
Source code:
    if {![ds_enabled_p]} {
        error "DS not enabled"
    }
    switch $command {
        start {
            if { $tag eq "" } {
                error "Tag parameter is required"
            }
            set ::ds_profile__start_clock($tag) [clock clicks -microseconds]
        }
        stop {
            if { [info exists ::ds_profile__start_clock($tag)]
                 && $::ds_profile__start_clock($tag) ne "" } {
                ds_add prof $tag  [expr {[clock clicks -microseconds] - $::ds_profile__start_clock($tag)}]
                unset ::ds_profile__start_clock($tag)
            } else {
                ns_log Warning "ds_profile stop called without a corresponding call to ds_profile start, with tag $tag"
            }
        }
        default {
            error "Invalid command. Valid commands are 'start', 'stop', and 'log'."
        }
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: