Library tutorials & articles

Iteration Methods

Conclusions

To test the different methods, I allocated 1,000,000 doubles into an array and indexed over all of them. I repeated this 1,000 times to minimize randomness. Here are the results...

Results

Enumeration is always slow. That’s not surprising as I’m using a general data structure to hold the doubles. Each access performs a cast. The three operator/property methods differed very slightly. These are probably all optimized similarly. Using pointer math to traverse over the raw data was significantly faster. This is probably due to the fact that there’s no bounds checking. In summary, if you have large amounts of data and performance is critical, consider using managed C++.

Acknowledgements

Thanks to Mark Vulfson of ProWorks for tips on using Flipper Graph Control. Also, to my colleagues Ken Baldwin and Steve Sneller at CenterSpace Software.

Comments

  1. 06 Aug 2003 at 14:17


    Thanks for the feedback!  I tried putting in the extra step.  The results are virtually unchanged from previous changes.  Please try it out yourself.


    Cheers,
    Trevor



    Trevor Misfeldt
    CEO, CenterSpace Software

  2. 13 May 2003 at 15:47

    You are merely accessing the reference to where the data is kept for the array, but are never actually accessing the data, which you do elsewhere (for example Method #2). If you were to actually access the data, then I think your method would perform similar to Method #2. I don't think that the actual data is read until you access the variable. So perhaps to complete the test, I would perform a d += 1 in each loop to make sure that the data is accessed by each method your base class in which the object exists.

  3. 01 Jan 1999 at 00:00

    This thread is for discussions of Iteration Methods.

Leave a comment

Sign in or Join us (it's free).

AddThis

Related discussion

Related podcasts

  • Looking into the C# Crystal Ball with Charlie Calvert and Bill Wagner

    One of the most exciting announcements from PDC was the news about C# 4.0 and Visual Studio 2010. With all the excitement and discussion throughout the event about these new developer tools, we reached out to two experts in the fields. Charlie Calvert and Bill Wagner sat down with Keith and Woody...

Events coming up

  • Dec 6

    Developing AJAX Web Applications with Castle Monorail

    London, United Kingdom

    Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!