winIDEA SDK
test_get_statistics_for_function.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_getStatisticsForFunction():
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, False)
19
20 print("Function 'targetInit' statistics (by area ID, in 'Neutral' context):")
21 area = prof_data.getArea(ic.CProfilerArea2.EFunctions, "targetInit")
22 stat = prof_data.getStatisticsForFunction(area.getAreaId(), "Neutral")
23 print(f"\tArea name: {stat.getAreaName()}")
24 print(f"\tCall count: {stat.getNumHits()}")
25
26 print("Function 'targetInit' statistics (directly by func name in 'Neutral' context):")
27 stat = prof_data.getStatisticsForFunction(ic.CProfilerArea2.EFunctions,
28 "targetInit",
29 "Neutral")
30 print(f"\tArea name: {stat.getAreaName()}")
31 print(f"\tCall count: {stat.getNumHits()}")
32
33
34if __name__ == "__main__":
35 test_getStatisticsForFunction()