MCPcopy Create free account
hub / github.com/catboost/catboost / TestMutable

Function TestMutable

catboost/libs/helpers/ut/array_subset_ut.cpp:157–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155
156 template <class F>
157 void TestMutable(
158 const TVector<int>& array,
159 const NCB::TArraySubsetIndexing<size_t> arraySubsetIndexing,
160 const TVector<int>& expectedModifiedSubset,
161 F&& f
162 ) {
163 UNIT_ASSERT_EQUAL(arraySubsetIndexing.Size(), expectedModifiedSubset.size());
164
165 for (auto iterationType : {
166 EIterationType::ForEach,
167 EIterationType::ParallelForEach,
168 EIterationType::External
169 })
170 {
171 TVector<int> arrayCopy = array;
172 NCB::TArraySubset<TVector<int>> arraySubset{&arrayCopy, &arraySubsetIndexing};
173
174 switch (iterationType) {
175 case EIterationType::ForEach:
176 arraySubset.ForEach(f);
177 break;
178 case EIterationType::ParallelForEach: {
179 NPar::TLocalExecutor localExecutor;
180 localExecutor.RunAdditionalThreads(3);
181
182 arraySubset.ParallelForEach(f, &localExecutor, 3);
183 }
184 break;
185 case EIterationType::External: {
186 const auto* subsetIndexing = arraySubset.GetSubsetIndexing();
187
188 const NCB::TSimpleIndexRangesGenerator<size_t> parallelUnitRanges =
189 subsetIndexing->GetParallelUnitRanges(3);
190
191 for (size_t unitRangeIdx : xrange(parallelUnitRanges.RangesCount())) {
192 auto unitRange = parallelUnitRanges.GetRange(unitRangeIdx);
193 subsetIndexing->ForEachInSubRange(
194 unitRange,
195 [&](size_t index, size_t srcIndex) {
196 f(index, arrayCopy[srcIndex]);
197 }
198 );
199 }
200 }
201 }
202 }
203 }
204
205 void TestGetSubset(
206 const TVector<int>& v,

Callers 1

Y_UNIT_TESTFunction · 0.85

Calls 12

xrangeFunction · 0.85
RunAdditionalThreadsMethod · 0.80
GetParallelUnitRangesMethod · 0.80
ForEachInSubRangeMethod · 0.80
fFunction · 0.50
SizeMethod · 0.45
sizeMethod · 0.45
ForEachMethod · 0.45
ParallelForEachMethod · 0.45
GetSubsetIndexingMethod · 0.45
RangesCountMethod · 0.45
GetRangeMethod · 0.45

Tested by

no test coverage detected