RTCTest.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 #
4 ## RTCTest.py
5 
12 
13 from rtc_handle import *
14 from BasicDataType_idl import *
15 import time
16 import commands
17 
18 env = RtmEnv(sys.argv, ["localhost:9898"])
19 list0 = env.name_space["localhost:9898"].list_obj()
20 env.name_space['localhost:9898'].rtc_handles.keys()
21 
22 time.sleep(2)
23 
24 ns = env.name_space['localhost:9898']
25 
26 compo1 = ns.rtc_handles["ConsoleIn0.rtc"]
27 compo0 = ns.rtc_handles["ConsoleOut0.rtc"]
28 
29 def mem_rss():
30  (stat, output) = commands.getstatusoutput("ps alxww | grep \"[r]\"tcd")
31  return output.split()[7]
32 
33 ## file and console out
34 def print_file_and_cons(out_data, out_flag=0):
35  ## out_flag:1 is file out only
36  if out_flag == 1:
37  fout.write(out_data + '\n')
38  fout.flush()
39  ## out_flag:2 is console out only
40  elif out_flag == 2:
41  print out_data
42  ## out_flag:0 is console and file out (default)
43  else:
44  print out_data
45  fout.write(out_data + '\n')
46  fout.flush()
47  return
48 
49 ## memory leak check
50 def leak_check(rss_start, rss_end):
51  if rss_start != rss_end:
52  fodat = " result: memory leak was found !!!"
53  else:
54  fodat = " result: memory leak was not found."
55  print_file_and_cons(fodat)
56  return
57 
58 ## file out setting
59 test_case = "RTCTest"
60 fout = open(test_case + ".log", 'w')
61 
62 fodat = "=== " + test_case + " start ==="
64 
65 ec = compo0.rtc_ref.get_owned_contexts()
66 ec_id = compo0.rtc_ref.get_context_handle(ec[0])
67 ec[0].activate_component(compo0.rtc_ref)
68 
69 loop_cnt = 1000
70 ## -----------------------------------------------------------------------------
71 fodat = "on_finalize()"
73 
74 for i in range(loop_cnt):
75  # ComponentAction::on_finalize()
76  compo0.rtc_ref.on_finalize()
77 
78  if i == 0:
79  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
80  fodat = " %05d: %s KB start" % (1, rss0)
81  print_file_and_cons(fodat,1)
82  rss1 = mem_rss() ; j1 = i
83  if rss0 != rss1:
84  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
85  print_file_and_cons(fodat,1)
86  rss0 = rss1 ; j0 = j1
87 
88 rssEnd = mem_rss()
89 fodat = " %05d: %s KB end" % (i+1, rssEnd)
90 print_file_and_cons(fodat,1)
91 leak_check(rssStart, rssEnd)
92 ## -----------------------------------------------------------------------------
93 fodat = "on_startup()"
95 
96 for i in range(loop_cnt):
97  # ComponentAction::on_startup(in ExecutionContextHandle_t exec_handle)
98  compo0.rtc_ref.on_startup(ec_id)
99 
100  if i == 0:
101  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
102  fodat = " %05d: %s KB start" % (1, rss0)
103  print_file_and_cons(fodat,1)
104  rss1 = mem_rss() ; j1 = i
105  if rss0 != rss1:
106  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
107  print_file_and_cons(fodat,1)
108  rss0 = rss1 ; j0 = j1
109 
110 rssEnd = mem_rss()
111 fodat = " %05d: %s KB end" % (i+1, rssEnd)
112 print_file_and_cons(fodat,1)
113 leak_check(rssStart, rssEnd)
114 ## -----------------------------------------------------------------------------
115 fodat = "on_shutdown()"
116 print_file_and_cons(fodat)
117 
118 for i in range(loop_cnt):
119  # ComponentAction::on_shutdown(in ExecutionContextHandle_t exec_handle)
120  compo0.rtc_ref.on_shutdown(ec_id)
121 
122  if i == 0:
123  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
124  fodat = " %05d: %s KB start" % (1, rss0)
125  print_file_and_cons(fodat,1)
126  rss1 = mem_rss() ; j1 = i
127  if rss0 != rss1:
128  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
129  print_file_and_cons(fodat,1)
130  rss0 = rss1 ; j0 = j1
131 
132 rssEnd = mem_rss()
133 fodat = " %05d: %s KB end" % (i+1, rssEnd)
134 print_file_and_cons(fodat,1)
135 leak_check(rssStart, rssEnd)
136 ## -----------------------------------------------------------------------------
137 fodat = "on_activated()"
138 print_file_and_cons(fodat)
139 
140 for i in range(loop_cnt):
141  # ComponentAction::on_activated(in ExecutionContextHandle_t exec_handle)
142  compo0.rtc_ref.on_activated(ec_id)
143 
144  if i == 0:
145  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
146  fodat = " %05d: %s KB start" % (1, rss0)
147  print_file_and_cons(fodat,1)
148  rss1 = mem_rss() ; j1 = i
149  if rss0 != rss1:
150  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
151  print_file_and_cons(fodat,1)
152  rss0 = rss1 ; j0 = j1
153 
154 rssEnd = mem_rss()
155 fodat = " %05d: %s KB end" % (i+1, rssEnd)
156 print_file_and_cons(fodat,1)
157 leak_check(rssStart, rssEnd)
158 ## -----------------------------------------------------------------------------
159 fodat = "on_deactivated()"
160 print_file_and_cons(fodat)
161 
162 for i in range(loop_cnt):
163  # ComponentAction::on_deactivated(in ExecutionContextHandle_t exec_handle)
164  compo0.rtc_ref.on_deactivated(ec_id)
165 
166  if i == 0:
167  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
168  fodat = " %05d: %s KB start" % (1, rss0)
169  print_file_and_cons(fodat,1)
170  rss1 = mem_rss() ; j1 = i
171  if rss0 != rss1:
172  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
173  print_file_and_cons(fodat,1)
174  rss0 = rss1 ; j0 = j1
175 
176 rssEnd = mem_rss()
177 fodat = " %05d: %s KB end" % (i+1, rssEnd)
178 print_file_and_cons(fodat,1)
179 leak_check(rssStart, rssEnd)
180 ## -----------------------------------------------------------------------------
181 fodat = "on_aborting()"
182 print_file_and_cons(fodat)
183 
184 for i in range(loop_cnt):
185  # ComponentAction::on_aborting(in ExecutionContextHandle_t exec_handle)
186  compo0.rtc_ref.on_aborting(ec_id)
187 
188  if i == 0:
189  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
190  fodat = " %05d: %s KB start" % (1, rss0)
191  print_file_and_cons(fodat,1)
192  rss1 = mem_rss() ; j1 = i
193  if rss0 != rss1:
194  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
195  print_file_and_cons(fodat,1)
196  rss0 = rss1 ; j0 = j1
197 
198 rssEnd = mem_rss()
199 fodat = " %05d: %s KB end" % (i+1, rssEnd)
200 print_file_and_cons(fodat,1)
201 leak_check(rssStart, rssEnd)
202 ## -----------------------------------------------------------------------------
203 fodat = "on_error()"
204 print_file_and_cons(fodat)
205 
206 for i in range(loop_cnt):
207  # ComponentAction::on_error(in ExecutionContextHandle_t exec_handle)
208  compo0.rtc_ref.on_error(ec_id)
209 
210  if i == 0:
211  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
212  fodat = " %05d: %s KB start" % (1, rss0)
213  print_file_and_cons(fodat,1)
214  rss1 = mem_rss() ; j1 = i
215  if rss0 != rss1:
216  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
217  print_file_and_cons(fodat,1)
218  rss0 = rss1 ; j0 = j1
219 
220 rssEnd = mem_rss()
221 fodat = " %05d: %s KB end" % (i+1, rssEnd)
222 print_file_and_cons(fodat,1)
223 leak_check(rssStart, rssEnd)
224 ## -----------------------------------------------------------------------------
225 fodat = "on_reset()"
226 print_file_and_cons(fodat)
227 
228 for i in range(loop_cnt):
229  # ComponentAction::on_reset(in ExecutionContextHandle_t exec_handle)
230  compo0.rtc_ref.on_reset(ec_id)
231 
232  if i == 0:
233  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
234  fodat = " %05d: %s KB start" % (1, rss0)
235  print_file_and_cons(fodat,1)
236  rss1 = mem_rss() ; j1 = i
237  if rss0 != rss1:
238  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
239  print_file_and_cons(fodat,1)
240  rss0 = rss1 ; j0 = j1
241 
242 rssEnd = mem_rss()
243 fodat = " %05d: %s KB end" % (i+1, rssEnd)
244 print_file_and_cons(fodat,1)
245 leak_check(rssStart, rssEnd)
246 ## -----------------------------------------------------------------------------
247 fodat = "is_alive()"
248 print_file_and_cons(fodat)
249 
250 for i in range(loop_cnt):
251  # LightweightRTObject::is_alive(in ExecutionContext exec_context)
252  compo0.rtc_ref.is_alive(ec[0])
253 
254  if i == 0:
255  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
256  fodat = " %05d: %s KB start" % (1, rss0)
257  print_file_and_cons(fodat,1)
258  rss1 = mem_rss() ; j1 = i
259  if rss0 != rss1:
260  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
261  print_file_and_cons(fodat,1)
262  rss0 = rss1 ; j0 = j1
263 
264 rssEnd = mem_rss()
265 fodat = " %05d: %s KB end" % (i+1, rssEnd)
266 print_file_and_cons(fodat,1)
267 leak_check(rssStart, rssEnd)
268 ## -----------------------------------------------------------------------------
269 fodat = "get_context()"
270 print_file_and_cons(fodat)
271 
272 for i in range(loop_cnt):
273  # LightweightRTObject::get_context(in ExecutionContextHandle_t exec_handle)
274  compo0.rtc_ref.get_context(ec_id)
275 
276  if i == 0:
277  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
278  fodat = " %05d: %s KB start" % (1, rss0)
279  print_file_and_cons(fodat,1)
280  rss1 = mem_rss() ; j1 = i
281  if rss0 != rss1:
282  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
283  print_file_and_cons(fodat,1)
284  rss0 = rss1 ; j0 = j1
285 
286 rssEnd = mem_rss()
287 fodat = " %05d: %s KB end" % (i+1, rssEnd)
288 print_file_and_cons(fodat,1)
289 leak_check(rssStart, rssEnd)
290 ## -----------------------------------------------------------------------------
291 fodat = "get_owned_contexts()"
292 print_file_and_cons(fodat)
293 
294 for i in range(loop_cnt):
295  # LightweightRTObject::get_owned_contexts()
296  compo0.rtc_ref.get_owned_contexts()
297 
298  if i == 0:
299  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
300  fodat = " %05d: %s KB start" % (1, rss0)
301  print_file_and_cons(fodat,1)
302  rss1 = mem_rss() ; j1 = i
303  if rss0 != rss1:
304  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
305  print_file_and_cons(fodat,1)
306  rss0 = rss1 ; j0 = j1
307 
308 rssEnd = mem_rss()
309 fodat = " %05d: %s KB end" % (i+1, rssEnd)
310 print_file_and_cons(fodat,1)
311 leak_check(rssStart, rssEnd)
312 ## -----------------------------------------------------------------------------
313 fodat = "get_participating_contexts()"
314 print_file_and_cons(fodat)
315 
316 for i in range(loop_cnt):
317  # LightweightRTObject::get_participating_contexts()
318  compo0.rtc_ref.get_participating_contexts()
319 
320  if i == 0:
321  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
322  fodat = " %05d: %s KB start" % (1, rss0)
323  print_file_and_cons(fodat,1)
324  rss1 = mem_rss() ; j1 = i
325  if rss0 != rss1:
326  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
327  print_file_and_cons(fodat,1)
328  rss0 = rss1 ; j0 = j1
329 
330 rssEnd = mem_rss()
331 fodat = " %05d: %s KB end" % (i+1, rssEnd)
332 print_file_and_cons(fodat,1)
333 leak_check(rssStart, rssEnd)
334 ## -----------------------------------------------------------------------------
335 fodat = "get_context_handle()"
336 print_file_and_cons(fodat)
337 
338 for i in range(loop_cnt):
339  # LightweightRTObject::get_context_handle(in ExecutionContext cxt)
340  compo0.rtc_ref.get_context_handle(ec[0])
341 
342  if i == 0:
343  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
344  fodat = " %05d: %s KB start" % (1, rss0)
345  print_file_and_cons(fodat,1)
346  rss1 = mem_rss() ; j1 = i
347  if rss0 != rss1:
348  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
349  print_file_and_cons(fodat,1)
350  rss0 = rss1 ; j0 = j1
351 
352 rssEnd = mem_rss()
353 fodat = " %05d: %s KB end" % (i+1, rssEnd)
354 print_file_and_cons(fodat,1)
355 leak_check(rssStart, rssEnd)
356 ## -----------------------------------------------------------------------------
357 fodat = "is_running()"
358 print_file_and_cons(fodat)
359 
360 for i in range(loop_cnt):
361  # ExecutionContext::is_running()
362  ec[0].is_running()
363 
364  if i == 0:
365  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
366  fodat = " %05d: %s KB start" % (1, rss0)
367  print_file_and_cons(fodat,1)
368  rss1 = mem_rss() ; j1 = i
369  if rss0 != rss1:
370  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
371  print_file_and_cons(fodat,1)
372  rss0 = rss1 ; j0 = j1
373 
374 rssEnd = mem_rss()
375 fodat = " %05d: %s KB end" % (i+1, rssEnd)
376 print_file_and_cons(fodat,1)
377 leak_check(rssStart, rssEnd)
378 ## -----------------------------------------------------------------------------
379 fodat = "start()"
380 print_file_and_cons(fodat)
381 
382 for i in range(loop_cnt):
383  # ExecutionContext::start()
384  ec[0].start()
385 
386  if i == 0:
387  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
388  fodat = " %05d: %s KB start" % (1, rss0)
389  print_file_and_cons(fodat,1)
390  rss1 = mem_rss() ; j1 = i
391  if rss0 != rss1:
392  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
393  print_file_and_cons(fodat,1)
394  rss0 = rss1 ; j0 = j1
395 
396 rssEnd = mem_rss()
397 fodat = " %05d: %s KB end" % (i+1, rssEnd)
398 print_file_and_cons(fodat,1)
399 leak_check(rssStart, rssEnd)
400 ## -----------------------------------------------------------------------------
401 fodat = "stop()"
402 print_file_and_cons(fodat)
403 
404 for i in range(loop_cnt):
405  # ExecutionContext::stop()
406  ec[0].stop()
407 
408  if i == 0:
409  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
410  fodat = " %05d: %s KB start" % (1, rss0)
411  print_file_and_cons(fodat,1)
412  rss1 = mem_rss() ; j1 = i
413  if rss0 != rss1:
414  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
415  print_file_and_cons(fodat,1)
416  rss0 = rss1 ; j0 = j1
417 
418 rssEnd = mem_rss()
419 fodat = " %05d: %s KB end" % (i+1, rssEnd)
420 print_file_and_cons(fodat,1)
421 leak_check(rssStart, rssEnd)
422 ## -----------------------------------------------------------------------------
423 fodat = "get_rate()"
424 print_file_and_cons(fodat)
425 
426 for i in range(loop_cnt):
427  # ExecutionContext::get_rate()
428  ec[0].get_rate()
429 
430  if i == 0:
431  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
432  fodat = " %05d: %s KB start" % (1, rss0)
433  print_file_and_cons(fodat,1)
434  rss1 = mem_rss() ; j1 = i
435  if rss0 != rss1:
436  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
437  print_file_and_cons(fodat,1)
438  rss0 = rss1 ; j0 = j1
439 
440 rssEnd = mem_rss()
441 fodat = " %05d: %s KB end" % (i+1, rssEnd)
442 print_file_and_cons(fodat,1)
443 leak_check(rssStart, rssEnd)
444 ## -----------------------------------------------------------------------------
445 fodat = "set_rate()"
446 print_file_and_cons(fodat)
447 
448 for i in range(loop_cnt):
449  # ExecutionContext::set_rate(in double rate)
450  ec[0].set_rate(1.23456)
451 
452  if i == 0:
453  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
454  fodat = " %05d: %s KB start" % (1, rss0)
455  print_file_and_cons(fodat,1)
456  rss1 = mem_rss() ; j1 = i
457  if rss0 != rss1:
458  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
459  print_file_and_cons(fodat,1)
460  rss0 = rss1 ; j0 = j1
461 
462 rssEnd = mem_rss()
463 fodat = " %05d: %s KB end" % (i+1, rssEnd)
464 print_file_and_cons(fodat,1)
465 leak_check(rssStart, rssEnd)
466 ## -----------------------------------------------------------------------------
467 fodat = "activate_component()"
468 print_file_and_cons(fodat)
469 
470 for i in range(loop_cnt):
471  # ExecutionContext::activate_component(in LightweightRTObject comp)
472  ec[0].activate_component(compo0.rtc_ref)
473 
474  if i == 0:
475  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
476  fodat = " %05d: %s KB start" % (1, rss0)
477  print_file_and_cons(fodat,1)
478  rss1 = mem_rss() ; j1 = i
479  if rss0 != rss1:
480  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
481  print_file_and_cons(fodat,1)
482  rss0 = rss1 ; j0 = j1
483 
484 rssEnd = mem_rss()
485 fodat = " %05d: %s KB end" % (i+1, rssEnd)
486 print_file_and_cons(fodat,1)
487 leak_check(rssStart, rssEnd)
488 ## -----------------------------------------------------------------------------
489 fodat = "deactivate_component()"
490 print_file_and_cons(fodat)
491 
492 for i in range(loop_cnt):
493  # ExecutionContext::deactivate_component(in LightweightRTObject comp)
494  ec[0].deactivate_component(compo0.rtc_ref)
495 
496  if i == 0:
497  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
498  fodat = " %05d: %s KB start" % (1, rss0)
499  print_file_and_cons(fodat,1)
500  rss1 = mem_rss() ; j1 = i
501  if rss0 != rss1:
502  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
503  print_file_and_cons(fodat,1)
504  rss0 = rss1 ; j0 = j1
505 
506 rssEnd = mem_rss()
507 fodat = " %05d: %s KB end" % (i+1, rssEnd)
508 print_file_and_cons(fodat,1)
509 leak_check(rssStart, rssEnd)
510 ## -----------------------------------------------------------------------------
511 fodat = "reset_component()"
512 print_file_and_cons(fodat)
513 
514 for i in range(loop_cnt):
515  # ExecutionContext::reset_component(in LightweightRTObject comp)
516  ec[0].reset_component(compo0.rtc_ref)
517 
518  if i == 0:
519  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
520  fodat = " %05d: %s KB start" % (1, rss0)
521  print_file_and_cons(fodat,1)
522  rss1 = mem_rss() ; j1 = i
523  if rss0 != rss1:
524  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
525  print_file_and_cons(fodat,1)
526  rss0 = rss1 ; j0 = j1
527 
528 rssEnd = mem_rss()
529 fodat = " %05d: %s KB end" % (i+1, rssEnd)
530 print_file_and_cons(fodat,1)
531 leak_check(rssStart, rssEnd)
532 ## -----------------------------------------------------------------------------
533 ec[0].activate_component(compo0.rtc_ref)
534 
535 fodat = "get_component_state()"
536 print_file_and_cons(fodat)
537 
538 for i in range(loop_cnt):
539  # ExecutionContext::get_component_state(in LightweightRTObject comp)
540  ec[0].get_component_state(compo0.rtc_ref)
541 
542  if i == 0:
543  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
544  fodat = " %05d: %s KB start" % (1, rss0)
545  print_file_and_cons(fodat,1)
546  rss1 = mem_rss() ; j1 = i
547  if rss0 != rss1:
548  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
549  print_file_and_cons(fodat,1)
550  rss0 = rss1 ; j0 = j1
551 
552 rssEnd = mem_rss()
553 fodat = " %05d: %s KB end" % (i+1, rssEnd)
554 print_file_and_cons(fodat,1)
555 leak_check(rssStart, rssEnd)
556 ## -----------------------------------------------------------------------------
557 fodat = "get_kind()"
558 print_file_and_cons(fodat)
559 
560 for i in range(loop_cnt):
561  # ExecutionContext::get_kind()
562  ec[0].get_kind()
563 
564  if i == 0:
565  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
566  fodat = " %05d: %s KB start" % (1, rss0)
567  print_file_and_cons(fodat,1)
568  rss1 = mem_rss() ; j1 = i
569  if rss0 != rss1:
570  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
571  print_file_and_cons(fodat,1)
572  rss0 = rss1 ; j0 = j1
573 
574 rssEnd = mem_rss()
575 fodat = " %05d: %s KB end" % (i+1, rssEnd)
576 print_file_and_cons(fodat,1)
577 leak_check(rssStart, rssEnd)
578 ## -----------------------------------------------------------------------------
579 fodat = "on_execute()"
580 print_file_and_cons(fodat)
581 
582 for i in range(loop_cnt):
583  # DataFlowComponentAction::on_execute(in ExecutionContextHandle_t exec_handle)
584  compo0.rtc_ref.on_execute(ec_id)
585 
586  if i == 0:
587  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
588  fodat = " %05d: %s KB start" % (1, rss0)
589  print_file_and_cons(fodat,1)
590  rss1 = mem_rss() ; j1 = i
591  if rss0 != rss1:
592  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
593  print_file_and_cons(fodat,1)
594  rss0 = rss1 ; j0 = j1
595 
596 rssEnd = mem_rss()
597 fodat = " %05d: %s KB end" % (i+1, rssEnd)
598 print_file_and_cons(fodat,1)
599 leak_check(rssStart, rssEnd)
600 ## -----------------------------------------------------------------------------
601 fodat = "on_state_update()"
602 print_file_and_cons(fodat)
603 
604 for i in range(loop_cnt):
605  # DataFlowComponentAction::on_state_update(in ExecutionContextHandle_t exec_handle)
606  compo0.rtc_ref.on_state_update(ec_id)
607 
608  if i == 0:
609  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
610  fodat = " %05d: %s KB start" % (1, rss0)
611  print_file_and_cons(fodat,1)
612  rss1 = mem_rss() ; j1 = i
613  if rss0 != rss1:
614  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
615  print_file_and_cons(fodat,1)
616  rss0 = rss1 ; j0 = j1
617 
618 rssEnd = mem_rss()
619 fodat = " %05d: %s KB end" % (i+1, rssEnd)
620 print_file_and_cons(fodat,1)
621 leak_check(rssStart, rssEnd)
622 ## -----------------------------------------------------------------------------
623 fodat = "on_rate_changed()"
624 print_file_and_cons(fodat)
625 
626 for i in range(loop_cnt):
627  # DataFlowComponentAction::on_rate_changed(in ExecutionContextHandle_t exec_handle)
628  compo0.rtc_ref.on_rate_changed(ec_id)
629 
630  if i == 0:
631  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
632  fodat = " %05d: %s KB start" % (1, rss0)
633  print_file_and_cons(fodat,1)
634  rss1 = mem_rss() ; j1 = i
635  if rss0 != rss1:
636  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
637  print_file_and_cons(fodat,1)
638  rss0 = rss1 ; j0 = j1
639 
640 rssEnd = mem_rss()
641 fodat = " %05d: %s KB end" % (i+1, rssEnd)
642 print_file_and_cons(fodat,1)
643 leak_check(rssStart, rssEnd)
644 ## -----------------------------------------------------------------------------
645 fodat = "get_profile()"
646 print_file_and_cons(fodat)
647 
648 for i in range(loop_cnt):
649  # ExecutionContextService::get_profile()
650  ec[0].get_profile()
651 
652  if i == 0:
653  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
654  fodat = " %05d: %s KB start" % (1, rss0)
655  print_file_and_cons(fodat,1)
656  rss1 = mem_rss() ; j1 = i
657  if rss0 != rss1:
658  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
659  print_file_and_cons(fodat,1)
660  rss0 = rss1 ; j0 = j1
661 
662 rssEnd = mem_rss()
663 fodat = " %05d: %s KB end" % (i+1, rssEnd)
664 print_file_and_cons(fodat,1)
665 leak_check(rssStart, rssEnd)
666 ## -----------------------------------------------------------------------------
667 fodat = "get_component_profile()"
668 print_file_and_cons(fodat)
669 
670 for i in range(loop_cnt):
671  # RTObject::get_component_profile()
672  compo0.rtc_ref.get_component_profile()
673 
674  if i == 0:
675  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
676  fodat = " %05d: %s KB start" % (1, rss0)
677  print_file_and_cons(fodat,1)
678  rss1 = mem_rss() ; j1 = i
679  if rss0 != rss1:
680  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
681  print_file_and_cons(fodat,1)
682  rss0 = rss1 ; j0 = j1
683 
684 rssEnd = mem_rss()
685 fodat = " %05d: %s KB end" % (i+1, rssEnd)
686 print_file_and_cons(fodat,1)
687 leak_check(rssStart, rssEnd)
688 ## -----------------------------------------------------------------------------
689 ec[0].deactivate_component(compo0.rtc_ref)
690 
691 fodat = "=== " + test_case + " end ==="
692 print_file_and_cons(fodat)
693 fout.close()
def mem_rss()
Definition: RTCTest.py:29
def print_file_and_cons(out_data, out_flag=0)
file and console out
Definition: RTCTest.py:34
def leak_check(rss_start, rss_end)
memory leak check
Definition: RTCTest.py:50


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:55