Skip to content

Performance Tweaks (PLINQ/TPL) to Genetic Algorithm #55

@codingdna2

Description

@codingdna2

FEATURE REQUEST (Optimization)
I've completed a bunch of performance tests on a scheduling algorithm implemented with GeneticSharp. Following are my findings.

I've used PLINQ/TPL to try to improve performance here and there.
Following are my results:

  • ParallelTaskExecutor.Start, changed loop to Parallel.For, removing the Task.Run RESULT: +2%
  • GeneticAlgorithm.Cross, GeneticAlgorithm.Mutate, changed loop to Parallel.ForEach (see PR) and used ConcurrentBag RESULT: +80% +110%

Additional context
I didn't like too much the actual implementation of ParallelTaskExecutor due to the need of sizing the min and max threads manually. If I understand well, Parallel class use a default (automatic) partitioner which can be customized if required (maybe even through the external interface?).

Let me know what you think.
Kind Regards,

References
MSDN Parallel Class
MSDN Custom Partitioners for PLINQ and TPL

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions