winIDEA SDK
test_get_timeline_iterator.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import isystem.connect as ic
6import export_profiler_data # see docs section Examples for link to source
7
8
9winidea_id = ''
10
11
12def test_getTimelineIterator():
13 conn_mgr = ic.ConnectionMgr()
14 conn_mgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
15
16 # To see exportProfilerData(), click Examples tab in iSYSTEM online docs.
17 xml_file_path = export_profiler_data.export_data(conn_mgr)
18 prof_data = ic.CProfilerData2.createInstance(xml_file_path, True)
19
20 print("First 10 'write' events in timeline:")
21 titr = prof_data.getTimelineIterator(ic.CProfilerTimeEvent.EEvWrite)
22 for index in range(10):
23 assert titr.hasNext() is True, f"There are no more 'write' events available, last: {index}"
24 event_data = titr.next()
25 event_data: ic.CProfilerTimeEvent
26 print(
27 f"\tIndex {index}: value {event_data.getValue()} @ {event_data.getTime()}")
28
29 print("First 10 'write' events in timeline of 'mainLoopCounter' variable:")
30 area = prof_data.getArea('Data/mainLoopCounter')
31 titr = prof_data.getTimelineIterator(ic.CProfilerTimeEvent.EEvWrite,
32 area.getHandle())
33 for index in range(10):
34 assert titr.hasNext(
35 ) is True, f"There is no more 'write' events available, last: {index}"
36 event_data = titr.next()
37 event_data: ic.CProfilerTimeEvent
38 print(
39 f"\tIndex {index}: value {event_data.getValue()} @ {event_data.getTime()}")
40
41
42if __name__ == "__main__":
43 test_getTimelineIterator()