Forum .LRN Q&A: Computing script execution time

Hi!

We are trying to compute how much time a dotLRN script takes to execute. After we compute the execution time, we want to store it in a dotlrn table along with the userID, the URL and some other stuff.

We want to collect those statistics in order to derive capacity planning models.

Let me first show you what we did.

In file:

#var/lib/aolserver/dotlrn/www/blank-master.tcl

We included this code:

set reloj [clock clicks -milliseconds]
set insertar "insert into tiempo(tiempo_inicio) values($reloj)"
db_dml do_insert $insertar

In file:

# var/lib/aolserver/dotlrn/packages/dotlrn/lib/toolbar.tcl

We included the following code:

set user_id [ad_conn user_id]
set url [ad_conn url]

db_multirow -unclobber -extend {tiempo1} tiempo select_tiempo "select t.tiempo_inicio as tiempo from tiempo t" {
set tiempo1 $tiempo
set tiempo2 [clock clicks -milliseconds]
if {$tiempo2 < 0} {
set postiempo [expr abs($tiempo1)]
set tiempo3 [expr abs($tiempo2)]
set residuo [expr $postiempo-$tiempo3]
set tiempo_comienza [expr abs($tiempo2)]
} else {
set residuo [expr $tiempo2-$tiempo1]
set tiempo_comienza [expr abs($tiempo1)]
}

set insertar "insert into clinica(usuario,pagina,tinicio,tacceso) values($user_id,\'$url',$tiempo_comienza, $residuo)"
db_dml do_insert $insertar
}
db_dml _delete "delete from tiempo"

1. Notice that in order for this code to be correct the file blank-master.tcl should be about the first file to be executed and the file toolbar.tcl should be the last. Is this true?

2. Is the code in the second file correct? We have but primitive dotLRN API skills. This simple code was developed by students, but it looks to me rather complicated. Shouldn’t it look more like a simple subtraction of initial time with end time?

3. Notice also that in the first file, the initial time is stored in a separate table, which will slow down the global execution time. Is there a way to communicate the initial time between both files without storing it in a table?

Finally, we introduced in file
#/var/lib/aolserver/dotlrn/www/blank-master.adp

The following code:

At the beginning of label "head":

SCRIPT LANGUAGE="JAVASCRIPT"
var d= new Date();
var segundos=d.getSeconds();
var tiempo1=d.getMilliseconds();

/script

And near the end:

SCRIPT LANGUAGE="JAVASCRIPT"

var d2= new Date();
var tiempo2=d2.getMilliseconds();
var segundos2 =d2.getSeconds();

if (segundos==segundos2)
{
var resultado=tiempo2-tiempo1;
}
else
{
tiempo2=((segundos2-segundos)*1000)+tiempo2;
var resultado=tiempo2-tiempo1;
}
document.write(" El tiempo de descarga es: "+ resultado+ " ms");
/script

This is not the same time as computed in the previous code. Is there no way to, again, simply communicate the variable between files? Sort of like:

document.write(" El tiempo de descarga es: "+ $residuo+ " ms");

Thanks for your kind help.

Raul R.

Collapse
Posted by Nima Mazloumi on
no sure whether you need that. Try the request monitor first http://media.wu-wien.ac.at/download/
Collapse
Posted by Raúl V. Ramírez-Velarde on
Hi!

Thanks, we'll install it. But does it calculate execution times? Sort of like php-Nuke does. It is actually not that difficult.