orka_b455160b/examples/src/orka_5_scene_tree.adb

 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
--  SPDX-License-Identifier: Apache-2.0
--
--  Copyright (c) 2016 onox <denkpadje@gmail.com>
--
--  Licensed under the Apache License, Version 2.0 (the "License");
--  you may not use this file except in compliance with the License.
--  You may obtain a copy of the License at
--
--      http://www.apache.org/licenses/LICENSE-2.0
--
--  Unless required by applicable law or agreed to in writing, software
--  distributed under the License is distributed on an "AS IS" BASIS,
--  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--  See the License for the specific language governing permissions and
--  limitations under the License.

with Ada.Text_IO;
with Ada.Real_Time;

with Orka.Scenes.Singles.Trees;
--  with Orka.Scenes.Doubles.Trees;

procedure Orka_5_Scene_Tree is
   use type Ada.Real_Time.Time;

   package Trees renames Orka.Scenes.Singles.Trees;
--   package Trees renames Orka.Scenes.Doubles.Trees;

   T : Trees.Tree := Trees.Create_Tree ("root");
   A, B : Ada.Real_Time.Time;
begin
   A := Ada.Real_Time.Clock;
   for Index_One in 1 .. 25 loop
      declare
         Name_One : constant String :=
           "N1" & Integer'Image (Index_One);
      begin
         T.Add_Node (Name_One, "root");

         for Index_Two in 1 .. 4 loop
            declare
               Name_Two : constant String :=
                 Name_One & "N2" & Integer'Image (Index_Two);
            begin
               T.Add_Node (Name_Two, Name_One);

               for Index_Three in 1 .. 5 loop
                  declare
                     Name_Three : constant String :=
                       Name_Two & "N3" & Integer'Image (Index_Three);
                  begin
                     T.Add_Node (Name_Three, Name_Two);

                     for Index_Four in 1 .. 20 loop
                        declare
                           Name_Four : constant String :=
                             Name_Three & "N4" & Integer'Image (Index_Four);
                        begin
                           T.Add_Node (Name_Four, Name_Three);
                        end;
                     end loop;
                  end;
               end loop;
            end;
         end loop;
      end;
   end loop;
   B := Ada.Real_Time.Clock;
   Ada.Text_IO.Put_Line (Duration'Image (1e3 * Ada.Real_Time.To_Duration (B - A)));

   for I in 1 .. 4 loop
      A := Ada.Real_Time.Clock;
      T.Update_Tree;
      B := Ada.Real_Time.Clock;
      Ada.Text_IO.Put_Line (Duration'Image (1e3 * Ada.Real_Time.To_Duration (B - A)));
   end loop;

   Ada.Text_IO.Put_Line ("Depth: " & T.Depth'Image);
   for Level_Index in 1 .. T.Depth loop
      Ada.Text_IO.Put_Line ("Width: " & Natural'Image (T.Width (Level_Index)));
   end loop;
end Orka_5_Scene_Tree;