/[eiffelstudio]/branches/eth/eve/Src/library/memory_analyzer/ma_memory_state.e
ViewVC logotype

Contents of /branches/eth/eve/Src/library/memory_analyzer/ma_memory_state.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 83441 - (show annotations)
Sat Jun 5 13:52:53 2010 UTC (9 years, 7 months ago) by jasonw
File size: 4760 byte(s)
Renamed branch eve3 to eve. The eve branch serves as the new branch for the EVE project.
1 note
2 description: "Represent a memory state, it contain the informations of all type names and the count of them."
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 date: "$Date$"
6 revision: "$Revision$"
7
8 class
9 MA_MEMORY_STATE
10
11 create
12 make_with_memory_map
13
14 feature {NONE} -- Initialization
15
16 make_with_memory_map (a_memory_map: HASH_TABLE [INTEGER, INTEGER])
17 -- Initialize `Current'.
18 --| a_memory_map: type_id -> number of instances of type_id present in system
19 require
20 a_memory_map_not_void: a_memory_map /= Void
21 local
22 l_inter: INTERNAL
23 l_mem: MEMORY
24 do
25 from
26 create l_inter
27 create l_mem
28 create objects_states.make (100)
29 a_memory_map.start
30 until
31 a_memory_map.after
32 loop
33 objects_states.extend ([l_inter.type_name_of_type (a_memory_map.key_for_iteration), a_memory_map.item_for_iteration])
34 a_memory_map.forth
35 end
36 objects_count_number := objects_count (a_memory_map)
37 memory_eiffel_used := l_mem.memory_statistics ({MEM_CONST}.eiffel_memory).used
38 memory_c_used := l_mem.memory_statistics ({MEM_CONST}.c_memory).used
39 ensure
40 objects_state_set: objects_states /= Void
41 objects_count_number_set: True
42 memory_eiffel_used_set: True
43 memory_c_used_set: True
44 end
45
46 feature -- Measurrment
47
48 item_found_count: INTEGER
49 -- after routine found_type, return the count of founded item
50 require
51 founded_type_not_void: founded_type /= Void
52 local
53 l_item_founded: like item_founded
54 do
55 l_item_founded := item_founded
56 check l_item_founded /= Void end -- Implied by precondition
57 Result := l_item_founded.count_in_system
58 end
59
60 memory_used_eiffel: INTEGER
61 -- used eiffel memory of this state
62 do
63 Result := memory_eiffel_used
64 end
65
66 memory_used_c: INTEGER
67 -- used c memory of this state
68 do
69 Result := memory_c_used
70 end
71
72
73 feature -- Status report
74
75 found_type (a_type_name: STRING): BOOLEAN
76 -- if the state have the type of type_name
77 do
78 from
79 objects_states.start
80 until
81 objects_states.after or Result = True
82 loop
83 if objects_states.item.type_name.is_equal (a_type_name) then
84 Result := True
85 item_founded := objects_states.item
86 end
87 objects_states.forth
88 end
89 end
90
91 founded_type: like item_founded
92 -- the founded type by routine found_type
93 do
94 Result := item_founded
95 ensure
96 Result = item_founded
97 end
98
99 objects_total_count: INTEGER
100 -- the total number of objects
101 do
102 Result := objects_count_number
103 end
104
105 feature -- Compare
106
107 compare (a_state: like Current): ARRAYED_LIST [like state]
108 -- compare Current with a_state
109 -- result indicate type name and changed amount
110 require
111 a_state_not_void: a_state /= Void
112 local
113 l_count_change: INTEGER
114 do
115 from
116 create Result.make (10)
117 objects_states.start
118 until
119 objects_states.after
120 loop
121 if a_state.found_type (objects_states.item.type_name) then
122 l_count_change := a_state.item_found_count - objects_states.item.count_in_system
123 if l_count_change /= 0 then
124 Result.extend ([objects_states.item.type_name, l_count_change])
125 end
126 else
127 Result.extend ([objects_states.item.type_name, - objects_states.item.count_in_system])
128 end
129 objects_states.forth
130 end
131 ensure
132 result_not_void: Result /= Void
133 end
134
135 feature {NONE} -- Implementation
136
137 objects_count (a_table: HASH_TABLE [INTEGER, INTEGER]): INTEGER
138 -- count the total objects
139 require
140 a_table_not_void: a_table /= Void
141 do
142 from
143 a_table.start
144 until
145 a_table.after
146 loop
147 Result := Result + a_table.item_for_iteration
148 a_table.forth
149 end
150 end
151
152 objects_count_number: INTEGER
153 -- the total number of objects in current state
154
155 memory_eiffel_used: INTEGER
156 -- eiffel memory used of this state
157
158 memory_c_used: INTEGER
159 -- c memory used of this state
160
161 item_founded: detachable like state
162 -- the founded item by routine found_type
163
164 state: TUPLE [type_name: STRING; count_in_system: INTEGER]
165 -- [type_name_of_type, number of instances of type_name_of_type present in system]
166 local
167 l_result: detachable like state
168 do
169 check False end -- Anchor type only
170 check l_result /= void end -- Satisfy void-safe compiler
171 Result := l_result
172 end
173
174 objects_states: ARRAYED_LIST [like state];
175 -- the count the objects, first argument is type name, second argument is the object instances count
176
177 note
178 copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
179 license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
180 source: "[
181 Eiffel Software
182 356 Storke Road, Goleta, CA 93117 USA
183 Telephone 805-685-1006, Fax 805-685-6869
184 Website http://www.eiffel.com
185 Customer support http://support.eiffel.com
186 ]"
187
188
189
190
191 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23