Thursday, October 31, 2013

QA Performance testing

Code tuning and optimization





Computer performance

is characterized by the amount of useful work accomplished by a computer system compared to the time and resources used. Important aspect in software quality and human-computer interactions.
Good performance:
  1. Short ersponse time for a given piece of work
  2. Procesing bigger input data
  3. Low utilization of resources
  4. High availability (less waiting)
  5. Fast/high compact data de/compression
  6. High bandwidth/short data transmition time

Actual vs. Percieved Performance
e.g.
'Vista's file copy performance is slower than XP'-FALSE
Vista uses better algorithm. The Explorer waits 12 sec before showing copy duration estimate.

Performance improvements can reduce readability and complexity -> CAN LEAD TO SYSTEM/APPLICATION MAINTENANCE ISSUES.


Performance Analys before and after the code is finished! NEVER in the middle.


How to improve performance:

  • Program requrements - Sowftware cost vs Performance
  • System design - performance-oriented arhitecture with resource goals for individual sub-systems, features and classes
  • Class and method design - data types and algorithms
  • External interactions - OS, devices (printer,network)
  • Code execution - compiler optimizations
  • Hardware - very often the cheapest way
  • Code tuning - bottleneck/hot spots. Modifying CORRECT code to make it run more efficiently.

Systematic tuning steps:
  1. 1. Access problem and establish nimeric values for acceptable behaviour
  2. 2. Mesure performance before modificaion
  3. 3. Identify bottleneck - critical part for improving the performance
  4. 4. Modify that part and remove the bottleneck - repeteable and precise measurement
  5. 5. Mesure performance after modificaion
  6. 6. If better adopt it, else reverse!

Performance analysis tools are called profilers. They mesure the frequnecy and duration of function calls / traces the call stack and memory usage. 

C# Optimization tips

  • Static fields and methods are faster than instance ones!
  • Faster to minimize agruments and use constants in call methods
  • If it is ok global static variables can be used
  • Some switch-case are faster than sequence of if-else
  • 2D arrays are slow
  • StringBulder is better when appending String
  • Simple array is faster than List
  • Use lazy evaluation (caching)
  • For loop is faster than foreach
  • Avoid using stuct - copied in their entity on each function call or returm value


Performance testing


Objectives

  • Performance has become the key indicator of product quality and acceptance
  • Customers are becoming extremely demanding

Performance testing is typically done to help identify bottlenecks in a system, establish a baseline for future testing, support a performance tuning effort, determine compliance with performance goals and requirements, and/or collect other performance-related data to help stakeholders make informed decisions related to the overall quality of the application being tested. In addition, the results from performance testing and analysis can help you to estimate the hardware configuration required to support the application(s) when you go live to production operation.
At the highest level, performance testing is almost always conducted to address one or more risks related to expense, opportunity costs, continuity, and/or corporate reputation.

Tuning Process Overview

  • Performance(speed, scalability,stability), Load(subjected to workloads), and Stress Testing(subjected beyond anticipated)
  • Baseline - is the process of running a set of tests to capture performance metric data for the purpose of evaluating the effectiveness of subsequent performance-improving changes to the system or application.
  • Benchmarking - is the process of comparing your systems performance against a baseline that you have created internally or against an industry standard endorsed by some other organization.
  • Throughput - is the amount of transactions produced over time during a test. I's also expressed as the amount of capacity that a website or application can handle. Also before starting a performance test it is common to have a throughput goal that the application needs to be able to handle a specific number of request per hr.
  • Concurrency - two or more events in the same interval of time.

No comments:

Post a Comment