﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
1082	Petición de creación de una función de medida de tiempo de instrucciones tol	lmperez@…	Víctor de Buen Remiro	"Hola tol, ¿podríais incluir la siguiente función en la stdlib?
Mide el tiempo medio que tarda una instrucción tol en ejecutarse, independientemente de la gramática.
Creo que puede ser muy útil a la hora de optimizar el tiempo de las tareas de los proyectos.
Gracias de antemano.
{{{
//////////////////////////////////////////////////////////////////////////////
Real TolCode.Performance(Text code, Text grammar, Real n)
//////////////////////////////////////////////////////////////////////////////
{
  Real n2       = Floor(n);
  Set  codeW    = [[ """" ]];
  Set  grammarW = [[
    ""Anything"", ""Code"", ""Complex"", ""CDate"", ""CTimeSet"", ""Date"", ""Matrix"",
    ""NameBlock"", ""Polyn"", ""Ratio"", ""Real"", ""Serie"", ""Set"", ""Special"",
    ""Struct"", ""Text"", ""TimeSet"", ""VMatrix"", ""Class"", ""\#Embed"", ""\#Require"",
    ""Static""
  ]];

  Real c.ok = If(code<:codeW,False,True);
  Real g.ok = If(grammar<:grammarW,True,False);
  Real n.ok = If(GE(n2,1),True,False);

  Real Case(And(c.ok,g.ok,n.ok),
  {
    Text txt.code =
    ""Real time = Time; ""+NL+
    ""Set For(1,""+IntText(n2)+"",Real (Real j) ""+NL+
    ""{ ""+NL+
    ""  ""+grammar+"" ""+code+""; ""+NL+
    ""  Real True ""+NL+
    ""}); ""+NL+
    ""Real Time-time"";
  
    Real time.routine    = Eval (txt.code);
    Real time.subroutine = time.routine/n;
    Real time.subroutine
  },
  Not(g.ok),
  {
    WriteLn(""[TolCode.Performance] Not valid tol grammar."",""W"");
    Real False
  },
  Not(c.ok),
  {
    WriteLn(""[TolCode.Performance] Not valid tol code function."",""W"");
    Real False
  },
  Not(n.ok),
  {
    WriteLn(""[TolCode.Performance] Not valid number of simulations."",""W"");
    Real False
  },
  True,True)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(""It measures the average time that a tol instruction takes to 
execute. It needs the instruction to execute as a text variable, the grammar
of the instruction and a number of simulations."",
TolCode.Performance);
//////////////////////////////////////////////////////////////////////////////
}}}
"	defect	new	lowest		ASCII data files	2.0.1	trivial		Performance	Jorge Pedro Gea
