@@ -58,8 +58,8 @@ def test_load_function_stats(function_ranker):
5858 # Verify funcA specific values
5959 assert func_a_stats ["function_name" ] == "funcA"
6060 assert func_a_stats ["call_count" ] == 1
61- assert func_a_stats ["own_time_ns" ] == 63000
62- assert func_a_stats ["cumulative_time_ns" ] == 5443000
61+ assert func_a_stats ["own_time_ns" ] == 153000
62+ assert func_a_stats ["cumulative_time_ns" ] == 1324000
6363
6464
6565def test_get_function_addressable_time (function_ranker , workload_functions ):
@@ -71,10 +71,10 @@ def test_get_function_addressable_time(function_ranker, workload_functions):
7171
7272 assert func_a is not None
7373 addressable_time = function_ranker .get_function_addressable_time (func_a )
74-
74+
7575 # Expected addressable time: own_time + (time_in_callees / call_count)
76- # = 63000 + ((5443000 - 63000 ) / 1) = 5443000
77- assert addressable_time == 5443000
76+ # = 153000 + ((1324000 - 153000 ) / 1) = 1324000
77+ assert addressable_time == 1324000
7878
7979
8080def test_rank_functions (function_ranker , workload_functions ):
@@ -107,9 +107,9 @@ def test_get_function_stats_summary(function_ranker, workload_functions):
107107
108108 assert stats is not None
109109 assert stats ["function_name" ] == "funcA"
110- assert stats ["own_time_ns" ] == 63000
111- assert stats ["cumulative_time_ns" ] == 5443000
112- assert stats ["addressable_time_ns" ] == 5443000
110+ assert stats ["own_time_ns" ] == 153000
111+ assert stats ["cumulative_time_ns" ] == 1324000
112+ assert stats ["addressable_time_ns" ] == 1324000
113113
114114
115115
@@ -128,40 +128,8 @@ def test_importance_calculation(function_ranker):
128128
129129 assert func_a_stats is not None
130130 importance = func_a_stats ["own_time_ns" ] / total_program_time
131-
132- # funcA importance should be approximately 0.57 % (63000/10968000 )
133- assert abs (importance - 0.0057 ) < 0.001
131+
132+ # funcA importance should be approximately 1.9 % (153000/7958000 )
133+ assert abs (importance - 0.019 ) < 0.01
134134
135135
136- def test_simple_model_predict_stats (function_ranker , workload_functions ):
137- # Find SimpleModel::predict function
138- predict_func = None
139- for func in workload_functions :
140- if func .function_name == "predict" :
141- predict_func = func
142- break
143-
144- assert predict_func is not None
145-
146- stats = function_ranker .get_function_stats_summary (predict_func )
147- assert stats is not None
148- assert stats ["function_name" ] == "predict"
149- assert stats ["call_count" ] == 1
150- assert stats ["own_time_ns" ] == 2289000
151- assert stats ["cumulative_time_ns" ] == 4017000
152- assert stats ["addressable_time_ns" ] == 4017000
153-
154- # Test addressable time calculation
155- addressable_time = function_ranker .get_function_addressable_time (predict_func )
156- # Expected addressable time: own_time + (time_in_callees / call_count)
157- # = 2289000 + ((4017000 - 2289000) / 1) = 4017000
158- assert addressable_time == 4017000
159-
160- # Test importance calculation for predict function
161- total_program_time = sum (
162- s ["own_time_ns" ] for s in function_ranker ._function_stats .values ()
163- if s .get ("own_time_ns" , 0 ) > 0
164- )
165- importance = stats ["own_time_ns" ] / total_program_time
166- # predict importance should be approximately 20.9% (2289000/10968000)
167- assert abs (importance - 0.209 ) < 0.01
0 commit comments