@@ -69,33 +69,6 @@ def test_bm_weighted_no_custom_weights(self):
6969 expected_weights ,
7070 )
7171
72- def test_dctax_weighted (self ):
73- benchmark_map = {
74- "benchmark1" : bm .Benchmark ("fake_target" , "BM_TCMalloc_Test1" ),
75- "benchmark2" : bm .Benchmark ("fake_target" , "BM_Cord_Test2" ),
76- "benchmark3" : bm .Benchmark ("fake_target" , "BM_Protobuf_Test1" ),
77- }
78- expected_weights = {
79- "BM_TCMalloc_Test1" : 0.4 ,
80- "BM_Cord_Test2" : 0.1 ,
81- "BM_Protobuf_Test1" : 0.2 ,
82- }
83- with absltest .mock .patch .object (
84- weights ,
85- "GetDCTaxWeights" ,
86- return_value = {
87- "BM_TCMalloc_Test1" : 0.4 ,
88- "BM_Cord_Test2" : 0.1 ,
89- "BM_Protobuf_Test1" : 0.2 ,
90- },
91- ):
92- self .assertEqual (
93- weights .GetBenchmarkWeights (
94- benchmark_map , weights .SchedulingStrategy .DCTAX_WEIGHTED
95- ),
96- expected_weights ,
97- )
98-
9972 def test_bm_weighted_custom_weights (self ):
10073 benchmark_map = {
10174 "benchmark1" : bm .Benchmark ("fake_target" , "benchmark1" ),
@@ -115,7 +88,7 @@ def test_bm_weighted_custom_weights(self):
11588 expected_weights ,
11689 )
11790
118- def test_workload_weighted (self ):
91+ def test_workload_weighted_no_custom_weights (self ):
11992 benchmark_map = {
12093 "benchmark1" : bm .Benchmark ("fake_target" , "BM_Workload1_Test1" ),
12194 "benchmark2" : bm .Benchmark ("fake_target" , "BM_Workload1_Test2" ),
@@ -132,3 +105,61 @@ def test_workload_weighted(self):
132105 ),
133106 expected_weights ,
134107 )
108+
109+ def test_workload_weighted_custom_weights (self ):
110+ benchmark_map = {
111+ "benchmark1" : bm .Benchmark ("fake_target" , "BM_Workload1_Test1" ),
112+ "benchmark2" : bm .Benchmark ("fake_target" , "BM_Workload1_Test2" ),
113+ "benchmark3" : bm .Benchmark ("fake_target" , "BM_Workload2_Test1" ),
114+ }
115+ custom_weights = ["Test1:3" ]
116+ expected_weights = {
117+ "benchmark1" : 0.75 ,
118+ "benchmark2" : 0.25 ,
119+ "benchmark3" : 1.0 ,
120+ }
121+ self .assertEqual (
122+ weights .GetBenchmarkWeights (
123+ benchmark_map ,
124+ weights .SchedulingStrategy .WORKLOAD_WEIGHTED ,
125+ custom_weights ,
126+ ),
127+ expected_weights ,
128+ )
129+
130+ def test_dctax_weighted (self ):
131+ benchmark_map = {
132+ "benchmark1" : bm .Benchmark ("fake_target" , "BM_TCMalloc_Test1" ),
133+ "benchmark2" : bm .Benchmark ("fake_target" , "BM_Cord_Test2" ),
134+ "benchmark3" : bm .Benchmark ("fake_target" , "BM_Protobuf_Test1" ),
135+ }
136+ expected_weights = {
137+ "BM_TCMalloc_Test1" : 0.4 ,
138+ "BM_Cord_Test2" : 0.1 ,
139+ "BM_Protobuf_Test1" : 0.2 ,
140+ }
141+ custom_weights = ["Test1:3" ]
142+ with absltest .mock .patch .object (
143+ weights ,
144+ "GetDCTaxWeights" ,
145+ return_value = {
146+ "BM_TCMalloc_Test1" : 0.4 ,
147+ "BM_Cord_Test2" : 0.1 ,
148+ "BM_Protobuf_Test1" : 0.2 ,
149+ },
150+ ):
151+ self .assertEqual (
152+ weights .GetBenchmarkWeights (
153+ benchmark_map , weights .SchedulingStrategy .DCTAX_WEIGHTED
154+ ),
155+ expected_weights ,
156+ )
157+ # Custom weights are ignored for DCTAX_WEIGHTED scheduling strategy.
158+ self .assertEqual (
159+ weights .GetBenchmarkWeights (
160+ benchmark_map ,
161+ weights .SchedulingStrategy .DCTAX_WEIGHTED ,
162+ custom_weights ,
163+ ),
164+ expected_weights ,
165+ )
0 commit comments