Convert non-deterministic computing engine to C # and reconstruct it

Source: Internet
Author: User

This is the original VB. NET version I wrote earlier:

Http://www.cnblogs.com/RChen/archive/2010/05/17/1737587.html

After being converted to the C # version, some refactoring is also performed. This includes modifying to a strong type and using Parallel. ForEach, but failed to receive the expected results. Performance improvement is relatively small.

After research, we found that the key to the problem is to pruning the possibility of traversal in some way, so as to reduce the number of traversal times and improve performance. Besides, because the results are implemented through yield return and IEnumerable, IList or Array is not implemented. therefore, it does not support Parallel split by index range in essence. the ForEach method is used, and the actual estimation is several inefficient chunk round-reading methods, so there is thread synchronization overhead between each chunk, as mentioned above. This performance optimization will have to be available for further research.

The following is the implementation code of the current situation:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections;   namespace NonDeterministicEngineCS {      class Program      {          static void Main( string [] args)          {              Benchmarking( new Action(Test1), "Test1 () execution is completed, which takes {0} milliseconds. " );              Console.WriteLine( "====================================================" );              Benchmarking( new Action(Test2), "Test2 () execution is completed, which takes {0} milliseconds. " );              Console.WriteLine( "====================================================" );              Benchmarking( new Action(Test3), "Test3 () execution is completed, which takes {0} milliseconds. " );              Console.ReadLine();          }            // A simple test example          public static void Test1()          {              NonDeterministicEngine engine = new NonD

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.