Kevin Bacon Code Contest Performance Optimization Techniques
Explore strategies for improving performance in the Kevin Bacon Code Contest of 11/16/2015 by delving into the app's functionality, addressing issues with single-threaded HTTP processes, and optimizing performance through Visual Studio profiling tools. Discover insights on selecting the right collection types for efficient storage and access operations.
- Kevin Bacon
- Performance Optimization
- Visual Studio Profiling
- Collection Efficiency
- HTTP Optimization
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
E N D
Presentation Transcript
Kevin Bacon Code Contest Performance Optimization 11/16/2015
How the app works Gets the Seed Page Look up the link using HTTP Loads HTML into HTML Agility Pack Get all the href (links) For each link Check if we ve already looked up that link (AllUrlsTraversed [ArrayList]) Check if it s the final link If not, then look up that link You re Done!
Big issues Single-Threaded HTTP is asynchronous and takes time Need to change to multi-threading Perf Profiler
Performance Profiling in Visual Studio https://msdn.microsoft.com/en-us/library/ms182372.aspx
Choose the right collection Collection Ordering Contiguous Storage? Yes Direct Access? Lookup Efficiency Manipulate Efficiency O(1) Notes Dictionary Unordered Via Key Key: O(1) Key: O(log n) Key: O(log n) Best for high performance lookups. SortedDictionary Sorted No Via Key O(log n) Compromise of Dictionary speed and ordering, uses binarysearch tree. Very similar toSortedDictionary, except tree is implemented in an array, so has faster lookup on preloaded data, but slower loads. Best for smaller lists where direct access required and no sorting. SortedList Sorted Yes Via Key O(n) User has precise control over element ordering User has precise control over element ordering Unordered List Yes Via Index Index: O(1) Value: O(n) O(n) LinkedList No No Value: O(n) O(1) Best for lists where inserting/deleting in middle is commonand no direct access required. Unique unordered collection, like a Dictionary except key and value are same object. Unique sorted collection, like SortedDictionary except key and value are same object. Essentially same as List<T> except only process as LIFO Essentiallysame as List<T> except only process as FIFO Via Key HashSet Yes Key: O(1) O(1) SortedSet Sorted No Via Key Key: O(log n) O(log n) Stack LIFO Yes Only Top Top: O(1) O(1)* Queue FIFO Yes Only Front Front: O(1) O(1) http://geekswithblogs.net/BlackRabbitCoder/archive/2011/06/16/c.net-fundamentals-choosing-the-right-collection-class.aspx
26 seconds 13 minutes
Whats next Loading the doc into the HTML Agility Pack is taking 60% of processing time. Perhaps I could just read the string directly and do a simpler parse function