MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / ShouldContinueRepeatedPasses

Method ShouldContinueRepeatedPasses

source/fuzz/fuzzer.cpp:364–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362}
363
364bool Fuzzer::ShouldContinueRepeatedPasses(
365 bool continue_fuzzing_probabilistically) {
366 if (continue_fuzzing_probabilistically) {
367 // If we have applied T transformations so far, and the limit on the number
368 // of transformations to apply is L (where T < L), the chance that we will
369 // continue fuzzing is:
370 //
371 // 1 - T/(2*L)
372 //
373 // That is, the chance of continuing decreases as more transformations are
374 // applied. Using 2*L instead of L increases the number of transformations
375 // that are applied on average.
376 auto transformations_applied_so_far = static_cast<uint32_t>(
377 transformation_sequence_out_.transformation_size());
378 auto chance_of_continuing = static_cast<uint32_t>(
379 100.0 *
380 (1.0 - (static_cast<double>(transformations_applied_so_far) /
381 (2.0 * static_cast<double>(
382 fuzzer_context_->GetTransformationLimit())))));
383 if (!fuzzer_context_->ChoosePercentage(chance_of_continuing)) {
384 // We have probabilistically decided to stop.
385 return false;
386 }
387 }
388 // Continue fuzzing!
389 num_repeated_passes_applied_++;
390 return true;
391}
392
393} // namespace fuzz
394} // namespace spvtools

Callers

nothing calls this directly

Calls 2

ChoosePercentageMethod · 0.80

Tested by

no test coverage detected