1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
------------------------------------------------------------------------------
-- Templates Parser --
-- --
-- Copyright (C) 2005 --
-- AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or (at --
-- your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, but --
-- WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public License --
-- along with this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
------------------------------------------------------------------------------
with Ada.Calendar;
with Ada.Command_Line;
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with Templates_Parser;
procedure Testcache is
use Ada;
use Ada.Strings.Unbounded;
use type Calendar.Time;
package TP renames Templates_Parser;
use type TP.Vector_Tag;
Translations : TP.Translate_Table
:= (TP.Assoc ("VAR1", "a value"),
TP.Assoc ("VAR2",
+"a table" & "with" & "many" & "values" & "to" & "be"
& "displayed" & "one" & "by" & "one"),
TP.Assoc ("VAR3",
+"one" & "two" & "three"),
TP.Assoc ("VAR4", ""),
TP.Assoc ("COND1", False),
TP.Assoc ("COND2", True));
Start, Stop : Calendar.Time;
Elaps : Duration;
Right : Unbounded_String;
procedure Run (Filename : in String; Cached : in Boolean) is
Current : Unbounded_String;
begin
Text_IO.Put_Line ("Cached " & Boolean'Image (Cached));
for K in 1 .. 10 loop
Start := Calendar.Clock;
Current := To_Unbounded_String
(TP.Parse (Filename, Translations, Cached));
Stop := Calendar.Clock;
if Right = Current then
Text_IO.Put ("Ok ");
else
Text_IO.Put ("NOk ");
end if;
Current := Null_Unbounded_String;
Elaps := Stop - Start;
Text_IO.Put_Line ("Elaps : " & Duration'Image (Elaps));
end loop;
end Run;
begin
if Command_Line.Argument_Count = 0 then
Text_IO.Put_Line ("Syntax: testcache <filename>");
Text_IO.New_Line;
else
Right := To_Unbounded_String
(TP.Parse (Command_Line.Argument (1), Translations, False));
Run (Command_Line.Argument (1), False);
Text_IO.New_Line;
Run (Command_Line.Argument (1), True);
end if;
end Testcache;
|