Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In PLINQ, what is the difference between .AsSequential() and .AsOrdered()?

Tags:

I can't seem to wrap my head around what the difference is between AsSequential and AsOrdered. I have looked up documentation on msdn for each of these as well as searching the internet for examples, but I am just a simple shoe cobbler and I was unable to definitively understand what is going on. If possible, could someone please explain when you would use AsSequential vs AsOrdered, and if necessary explain how the results would be different?

like image 997
user2565663 Avatar asked Aug 03 '13 01:08

user2565663


People also ask

Which extension method do you need to run a parallel query in PLINQ?

If you specify Default as a parameter to the WithExecutionMode extension method, PLINQ will execute the query in parallel if an improvement in performance is evident in executing the query in parallel. If not, PLINQ would execute the query just like a LINQ query.

What is AsParallel in Linq C#?

AsParallel(IEnumerable) Enables parallelization of a query. AsParallel<TSource>(Partitioner<TSource>) Enables parallelization of a query, as sourced by a custom partitioner that is responsible for splitting the input sequence into partitions.

Which of the following methods is used to run a LINQ query in parallel?

You can use the WithExecutionMode method and the System. Linq. ParallelExecutionMode enumeration to instruct PLINQ to select the parallel algorithm. This is useful when you know by testing and measurement that a particular query executes faster in parallel.


1 Answers

AsOrdered instructs the Parallel LINQ engine to preserve ordering, but still executes the query in parallel. This has the effect of hindering performance as the engine must carefully merge the results after parallel execution.

AsSequential instructs the Parallel LINQ engine to execute the query sequentially, that is, not in parallel.

like image 178
jason Avatar answered Sep 25 '22 11:09

jason