Find White Papers
Home
About Us
List Your Papers
    
> Red Gate Software > How To Make Your .NET Application Perform

How To Make Your .NET Application Perform

White Paper Published By: Red Gate Software

This short white paper discusses the common pitfalls and performance problems .NET developers come across when creating applications. The paper also presents several ways of getting around these issues, so that developers can make their .NET applications perform the way they should.



Tags : 
scalability, performance, performance problem, performance problems, .net, .net application, optimize code, .net profiling

Red Gate Software
Published:  Oct 19, 2007
Type:  White Paper
Length:  7 pages

How to make your .NET applications 
perform 
Technical paper Written by James Moore, Red Gate® Software Ltd 
ingeniously simple tools for .NETHow to make your .NET applications perform 
Introduction Because of today's high processor speeds, and the large amount of available memory, many programmers seem to ignore the limitations on these resources in applications. 
This can often lead to scalability and performance problems that can often be solved with very little difficulty. This paper discusses common pitfalls and problems when creating applications in .NET. We will cover some nomenclature first, then present several common issues that we have come across in a wide variety of applications. We will then describe some common ways of solving these problems. 
Beware of optimizing needlessly. You are better off writing readable code, then focusing your efforts on optimizing only those parts that need it? this is just as true with Just In Time (JIT) compiled platforms, such as .NET as with native code. 
If we over­optimize our code, we risk limiting the ability of the compiler to perform compiler 1 optimizations, such as loop interchange, thereby leading to a decrease in performance, as 2 the compiler may select different optimizations depending on platform . 
In my experience, it is best to ensure you have a scalable architecture, and leave optimization for a subsequent stage in which you can identify, measure, and fix those performance hotspots. 
A big Oh 3 You may have come across big­O notation before. It is used to describe how an algorithm employs resources (time and memory) depending on the size of its input. If a function has a 2 time complexity of O(n ), then we imply that after n is sufficiently large, the amount of time spent in the function grows in proportion to the square of the size of the input? but when n is small, this is not necessarily the case. 
Let's have a look at the following function: 
1:  static void SomeFunction(int[] array) 2:        { 3:  Thread.Sleep(100000)? 4: 5:  for (int i = 0? i < array.Length? i++) 6:          { 7:  for (int j = 0? j < array.Length? j++) 8:              { 9:  Thread.Sleep(10)? 10:              } 11:          } 12:      } 
1 See http://en.wikipedia.org/wiki/Compiler_optimization for information about the wonderful things your compiler can do for you. 2 For a great overview of different architectures and their behaviors, get a copy of Computer Architecture, A Quantitative Approach by John L. Hennessy and David A. Patterson. 3 Also known as Big­Oh, Landau notation or asymptotic notation.
1 How to make your .NET applications perform 
2 This function has a time complexity of O(n ).  If we pass in an array of 1 element, then the function will spend longest in the sleep on line 3 of our function and this is still true if we pass a 100 element array. However, if we pass in a 1,000 element array, the same amount of time is spent in line 9 as line 3. 
As the number of elements in the array grows beyond 1,000, the sleep on line 9 becomes more and more dominant and the sleep on line 3 loses its influence on the run time of the function. 
The table below outlines several common function complexities, illustrating how they grow with the size of the input. 
2 3 O(1) O(lg N) O(n) O(n lg n) O(n ) O(n ) 1 1 1 1 1 1 1 10 1 3 10 33 100 1000 50 1 6 50 282 2500 125000 100 1 7 100 664 10000 1000000 1000 1 10 1000 9966 1000000 1000000000 12 10000 1 13 10000 132877 100000000 10 12 18 1000000 1 20 1000000 19931569 10 10 
I was going to draw a graph of this table, but you would only have been able to see the lines 3 2 of O(n ) or O(n ), as they grow so much more rapidly than the others. 
So far, we have been talking about time complexities, but it is important to remember that the same can also be true of memory usage. 
You will often find that, to decrease a function's time­complexity, you need to increase its memory complexity. Can you come up with a function with an O(1) time complexity (i.e. the function's execution time does not vary with the size of the input), and a function with an O(1) memory complexity, to tell if a number under 10,000 is prime or not? What are the respective memory and time complexities? 
Get real So all this complexity malarkey sounds good? but how do I use it in practice? My function is 5,000 lines of code, calls other ... [download for more]

Browse Technology Topics

Data Center

Virtualization, Cloud Computing, Infrastructure, Design and Facilities, Power and Cooling, Green Computing  
    

Data Management

Application Integration, Analytical Applications, Business Intelligence, Configuration Management, Database Development, Data Integration, Data Mining, Data Protection, Data Quality, Data Replication, Database Security, EDI, SOAP, Service Oriented Architecture, Web Service Management, Data Warehousing  
    

Enterprise Applications

Application Integration, Application Performance Management, Best Practices, Business Activity Monitoring, Business Analytics, Business Integration, Business Intelligence, Business Management, Business Metrics, Business Process Automation, Business Process Management, Call Center Management, Call Center Software, Change Management, Corporate Governance, Customer Interaction Service, Customer Relationship Management, Customer Satisfaction, Customer Service, EBusiness, Enterprise Resource Planning, Enterprise Software, EProcurement, Extranets, Groupware Workflow, HIPAA Compliance, IP Faxing, IT Spending, Marketing Automation, Performance Testing, Product Lifecycle Management, Project Management, Return On Investment, Risk Management, Sales & Marketing Software, Sales Automation, Server Virtualization, Simulation Software, Supply Chain Management, System Management Software, Total Cost of Ownership, Video Conferencing, Voice Recognition, Voice Over IP, Workforce Management, Incentive Compensation, Spend Management, Manufacturing Execution Systems, International Computing  

Human Resource Technology

Human Resources Services, Payroll Software, Time and Attendance Software, Workforce Management Software, Financial Management, Employee Monitoring Software, Employee Training Software, Recruiting Software/Services, Employee Performance Management, ELearning, Benefits Management, Expense Management  
    

IT Career Advancement

Cisco Certification, Microsoft Certification, Linux Certification, Network Security Certification, Software Development Certification  

IT Management

Employee Performance, ITIL, Productivity, Project Management, Software Compliance, Sarbanes Oxley Compliance, Service Management, Desktop Management  
    

Knowledge Management

Collaboration, Collaborative Commerce, Contact Management, Content Delivery, Content Integration, Content Management System, Corporate Portals, Customer Experience Management, Document Management, Information Management, Intranets, Messaging, Records Management, Search And Retrieval, Search Engines, Secure Content Management, SLA  

Networking

Active Directory, Bandwidth Management, Convergence, Distributed Computing, Ethernet Networking, Fibre Channel, Gigabit Networking, Governance, Grid Computing, Infrastructure, Internetworking Hardware, Interoperability, IP Networks, IP Telephony, Local Area Networking, Load Balancing, Migration, Monitoring, Network Architecture, Network Management, Network Performance, Network Performance Management, Network Provisioning, Network Security, OLAP, Optical Networking, Quality Of Service, Remote Access, Remote Network Management, Server Hardware, Servers, Small Business Networks, TCP/IP Protocol, Test And Measurement, Traffic Management, Tunneling, Utility Computing, VPN, Wide Area Networks, Green Computing, Cloud Computing, Power and Cooling, Data Center Design and Management, Colocation and Web Hosting  
    

Platforms

AS/400, Domino, Linux, Microsoft Exchange, Oracle, PeopleSoft, SAP, Siebel, Solaris, Tivoli, Unix, Web Sphere, Windows, Windows Server  

Security

Access Control, Anti Spam, Anti Spyware, Anti Virus, Application Security, Auditing, Authentication, Biometrics, Business Continuity, Compliance, DDoS, Disaster Recovery, Email Security, Encryption, Firewalls, Hacker Detection, High Availability, Identity Management, Internet Security, Intrusion Detection, Intrusion Prevention, IPSec, Network Security Appliance, Password Management, Patch Management, Phishing, PKI, Policy Based Management, Security Management, Security Policies, Single Sign On, SSL, Secure Instant Messaging, Web Service Security, PCI Compliance, Vulnerability Management  
    

Software Development

.NET, C++, Database Development, Java, Middleware, Open Source, Software Outsourcing, Quality Assurance, Scripting, SOAP, Software Testing, Visual Basic, Web Development, Web Services, Web Service Security, XML  

Storage

Backup And Recovery, Blade Servers, Clustering, IP Storage, ISCSI, Network Attached Storage, RAID, Storage Area Networks, Storage Management, Storage Virtualization, Email Archiving, Data Deduplication  
    

Wireless

802.11, Bluetooth, CDMA, GPS, Mobile Computing, Mobile Data Systems, Mobile Workers, PDA, RFID, Smart Phones, WiFi, Wireless Application Software, Wireless Communications, Wireless Hardware, Wireless Infrastructure, Wireless Messaging, Wireless Phones, Wireless Security, Wireless Service Providers, WLAN  
Search