Module 9.
Code Testing, Performance Monitoring &
Optimisation
source: Freepik
In the complex landscape of software development, testing and performance
monitoring are fundamental. Ensuring that the code runs smoothly, efficiently, and as
intended requires strategic planning and continuous optimisation. This module
focuses on designing tests for codes, monitoring performance, and enhancing
software efficiency through careful analysis and targeted improvements.
In this module, you will explore:
● Learn how to design and implement various test cases to validate the
functionality of applications, focusing on real-world examples such as the
"Add Student" application.
● Dive into the techniques and tools used to monitor application
performance, including RAM and CPU usage, and how to capture baseline
analysis for comparisons.
● Discover the methodologies to improve code performance through specific
changes, how to compare before-and-after metrics, and propose further
optimisations.
To enhance your understanding, we have tailored specific learning activities:
● Designing and Implementing Test Cases for the "Add Student" Application
to Ensure Functionality.
● Monitoring Application Performance Including RAM and CPU Usage, and
Capturing Baseline Analysis.
● Implementing Code Changes to Improve Performance, Comparing
Before-and-After Metrics, and Suggesting Further Optimisations.
Assessment notes
Assessment 2 is due this week so make sure you upload all required
documents to Canvas.
Subject Learning Outcomes
The material in this module relates to the following subject learning outcomes:
SLO 6: Develop skills in designing effective test cases, monitor software
performance metrics, and understand how to make code optimisations
based on performance data.
Student Expectations
During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.
Accordingly, it is suggested that you allow:
4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), responding to facilitator feedback.
8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.
Topic 1. Performance Monitoring and Analysis
Key takeaways from this topic...
1. Performance monitoring focuses on tracking key system resources like RAM
and CPU to ensure the software runs efficiently.
2. Capturing baseline metrics is critical for making meaningful comparisons and
for understanding how changes will impact performance.
3. Monitoring tools can help identify performance bottlenecks, aiding in targeted
optimisation efforts.
Learner Guide
The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.
Expand All
Panels
Collapse All
Panels
Section 1: Importance of Designing Tests and Approaches
In the domain of software development, testing stands as a pivotal phase that
vouches for the reliability and robustness of the code. It encompasses the
scrutinising of code functionalities to ensure adherence to outlined requirements and
flawless operation without glitches. This portion delves deeply into the vital
procedures and methodologies entailed in crafting tests for codes, supplemented by
a practical case study to vividly illustrate the concept.
Designing Tests
The crafting of tests for codes is more than just an auxiliary step, embodying a
central element in the software development lifecycle. It facilitates the early detection
of bugs, consequently conserving time and resources as the project progresses.
Moreover, it serves to validate that alterations instated in the code do not negatively
impact pre-existing functionalities, thereby upholding a superior standard of quality
and dependability.
Further Reading
Overview of Test Design Techniques in Software Development
Links to an external site.
Explore the various types of test design techniques, including specification-based
(black-box) techniques and learn to select the right technique based on factors such
as system type, regulatory standards, customer requirements, risk levels, and
tester's skills.
Reference: 2018, 'Overview of Test Design Techniques in Software Development', Test Automation
Resources, accessed 31 January 2024,
<https://testautomationresources.com/software-testing-basics/software-test-design-techniques/>
Approaches to Code Testing
When tasked with code testing, one may opt for a range of approaches,
encompassing:
● Unit Testing
This procedure targets the minutest units of code, typically singular
functions or methods, validating their correct operation in isolation.
● Integration Testing
This form of testing focuses on assessing the interplay between diverse
units of code, verifying their seamless operation upon integration.
● System Testing
At this juncture, the entire system undergoes scrutiny to affirm its
compliance with delineated requirements and overall functional
proficiency.
● Acceptance Testing
This approach entails evaluating the system from the vantage point of the
user, ensuring it satisfies their necessities and anticipations.
Further Reading
Unit and Functional Tests in a Nutshell
Links to an external site.
Explore the difference between unit and functional tests and how to perform them
with the use of a testing framework - the Google Test Framework in particular.
Reference: 2017, 'Unit and Functional Tests in a Nutshell', Coderwall, accessed 31 January 2024,
<https://coderwall.com/p/zj8kjg/unit-and-functional-tests-in-a-nutshell>
Section 2: Practical Steps in Designing Tests
For the crafting of efficacious tests for codes, heed the following steps:
● Requirement Analysis
Commence with a lucid comprehension of the requirements and
functionalities that the code is anticipated to deliver.
● Test Case Design
Forge detailed test cases that enumerate the input conditions, execution
protocols, and anticipated outcomes.
● Test Data Preparation
Fabricate pertinent data requisite for testing, aimed at assessing the
functionality of the code.
● Test Execution
Implement the devised tests, either manually or utilising automated testing
instruments, and record the outcomes.
● Result Analysis
Engage in a detailed analysis of the results to pinpoint discrepancies and
areas where the code potentially falls short of expectations.
● Feedback and Iteration
Grounded on the test outcomes, confer feedback and implement
necessary adjustments to bolster the code’s performance and reliability.
Section 3: Case Study - Enhancing Code Quality at TechNest
Background
TechNest Solutions, a burgeoning software development entity, aspired to amplify
the calibre of its codebase to cater to the escalating demands of their clientele and
maintain a competitive edge in the industry.
Problem Statement
The incumbent testing protocols at the firm lacked sufficient rigour, engendering a
heightened frequency of bugs and errors permeating the production sphere, which
marred the user experience and tarnished the brand’s standing.
Implementation
To rectify this, TechNest Solutions overhauled its testing mechanisms by instituting a
comprehensive code testing strategy, featuring:
● Developing a Testing Protocol
A delineated testing protocol was formulated, encompassing diverse
testing tiers such as unit, integration, and system testing, to warrant a
meticulous appraisal of the code.
● Training and Skill Enhancement
The development cadre underwent training in the paramount practices for
code testing, augmenting their proficiency and capabilities in devising
potent tests.
● Automated Testing
The integration of automated testing tools was initiated to expedite and
streamline test executions, fostering regular and consistent testing
patterns.
● Feedback Loop
A feedback conduit was established, whereby test results were scrutinised
and the gleaned insights utilised to foster continual enhancements to the
code.
Outcome
The refurbished testing strategy precipitated a notable elevation in the quality of the
code generated at TechNest Solutions. Bugs and errors were pinpointed early in the
development trajectory, conserving both time and resources.
The streamlined testing protocols further facilitated quicker releases, aiding the firm
in adhering to project deadlines more adeptly. This endeavour highlighted the
quintessential role of devising tests for codes in augmenting software quality and
dependability.
Topic 2. Performance Monitoring and Analysis
Key takeaways from this topic...
1. Performance monitoring focuses on tracking key system resources like RAM
and CPU to ensure the software runs efficiently.
2. Capturing baseline metrics is critical for making meaningful comparisons and
for understanding how changes will impact performance.
3. Monitoring tools can help identify performance bottlenecks, aiding in targeted
optimisation efforts.
Learner Guide
The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.
Expand All
Panels
Collapse All
Panels
Section 1: Performance Monitoring
Performance monitoring and analysis stand as vital undertakings in the software
development cycle. This comprises a collection of procedures dedicated to verifying
the accurate and proficient operation of software applications.
This topic aims to give learners an insight into the effective monitoring and analysis
of software system performance, supplemented by a practical case study to help you
understand it in a real world context.
Understanding Performance Monitoring
Central to software development is the commitment to ensure that applications not
only function properly but also perform with the optimum efficiency. Performance
monitoring is tasked with the ongoing evaluation of the operational aspects of the
software, pinpointing sectors that might benefit from enhancements or modifications.
The primary facets assessed during this phase are:
● Response Time: The duration necessitated for a system to reply to a
user's enquiry.
● Resource Utilisation: Observing the consumption of system resources
such as memory, CPU, and network bandwidth.
● Throughput: The quantum of transactions the system processes within a
specified time span.
● Error Rate: The recurrence rate of errors during the system's functioning.
Section 2: Performance Analysis and Steps in Monitoring and Analysis
Implementing Performance Analysis
Following the monitoring stage, performance analysis emerges as the subsequent
step involving the scrutiny of data procured during monitoring, to pinpoint potential
improvement zones. This procedure may encompass:
● Analysing Bottlenecks
Identifying segments in the code or system configuration that might be
inducing delays or inefficiencies.
● Capacity Planning
Anticipating forthcoming system demands and strategising accordingly to
circumvent performance hitches.
● Optimisation
Instituting alterations to boost the system's efficiency based on the results
of the analysis.
● Reporting and Documentation
Crafting detailed reports to record the discoveries and enhancements
applied.
Steps in Performance Monitoring and Analysis
To enact performance monitoring and analysis, adopt the following procedures:
● Setting Benchmarks
Formulate baseline performance indicators to which the system's
performance can be juxtaposed.
● Continuous Monitoring
Employing tools and technologies for ceaseless system performance
monitoring, accruing essential operational data.
● Data Analysis
Examining the amassed data to discern patterns, trends, and potential
areas of concern.
● Implementing Improvements
Implementing necessary alterations to the system to elevate its efficiency,
based on the analytical findings.
● Feedback and Iteration
Upholding a loop of continual refinement by persistently observing and
analysing the system's performance, effectuating adjustments as required.
Section 3: Case Study - Performance Optimisation
Background
Skyward Industries, a well-entrenched e-commerce enterprise, was grappling with
escalating user traffic, which was exerting pressure on their existing system
infrastructure.
Problem Statement
Owing to a surge in user numbers, the system started manifesting stress signs,
including delayed response times and recurring downtimes, adversely impacting the
user experience and potentially diminishing sales.
Implementation
To counteract this, Skyward Industries embarked on a comprehensive performance
monitoring and analysis endeavour. The project encapsulated:
● Implementing Monitoring Tools
The initiative commenced with the integration of sophisticated monitoring
instruments to incessantly evaluate the system's performance.
● Gathering and Analysing Data
The team accumulated data over a duration and analysed it to identify the
prevailing bottlenecks and sectors needing improvement.
● Optimisation Initiatives
In light of the analysis, a series of optimisation moves were instigated,
encompassing server augmentations and code refinements to improve
system performance.
● Routine Performance Reviews
Skyward Industries instituted periodic performance assessments to
continually oversee the system's functionality and implement necessary
adaptations.
Outcome
The venture resulted in a notable amelioration in system performance, denoted by
swifter response times and diminished downtimes. The initiative also promoted more
adept capacity planning, aiding the company in gearing up for further expansion
effectively.
This scenario underlines the critical role of performance monitoring and analysis in
guaranteeing system scalability and delivering a superior user experience.
Topic 3. Performance Improvement and
Optimisation
Key takeaways from this topic...
1. Initially, focus on "low-hanging fruits" for performance gains—small changes
that yield significant improvements.
2. Using metrics to compare performance before and after code changes
quantifies the impact of your optimisation efforts.
3. Performance optimisation is an ongoing process that should adapt as
codebase evolves and new performance data becomes available.
Learner Guide
The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.
Expand All
Panels
Collapse All
Panels
Section 1: Performance Improvement and Optimisation
Performance improvement and optimisation stand as vital closing phases in the
software development cycle. These activities concern the fine-tuning of the system to
ensure peak functioning efficiency, thereby promising users a smooth and satisfying
experience.
This topic will familiarise you with the fundamental concepts and techniques behind
advancing and optimising system performance, supplemented with a relevant case
study to grant a deeper comprehension.
Understanding Performance Improvement
Within software development, performance improvement is a perpetual activity
concentrated on upgrading various aspects of a system to meet or surpass the
established performance standards. This may involve a broad spectrum of activities,
including but not limited to:
● Code Optimisation
Revamping the code to eliminate redundant components and streamline
operations, thus accelerating execution times.
● Database Tuning
Modifying the database settings and configurations to enable quicker data
access and storage.
● Hardware Upgrades
Enhancing the physical infrastructure, such as augmenting memory or
upgrading servers, to accommodate higher performance levels.
● Network Improvements
Upgrading the network setup to decrease latency and enhance data
transfer rates.
Further Reading
C++ Performance Optimization Best Practices
Links to an external site.
Explore various techniques and best practices for optimizing C++ code.
Reference: Ivan Chiklikchi, 2023, 'C++ Performance Optimization Best Practices', Hackernoon,
accessed 31 January 2024, <https://hackernoon.com/c-performance-optimization-best-practices>
Section 2: Implementation of Performance Optimisation
Implementing Performance Optimisation
Performance optimisation is a detailed process encompassing the analysis and
fine-tuning of various system components to secure optimal operation. The
procedure generally incorporates:
● Identifying Performance Goals
Designating clear and quantifiable performance goals that the system
aims to achieve.
● Benchmarking
Instituting benchmarks to juxtapose the present performance standards
against the set objectives.
● Performance Testing
Conducting examinations to pinpoint areas where the system's
performance can be augmented.
● Optimisation Implementation
Enacting optimisation strategies to reach the intended performance levels.
● Monitoring and Adjustment
Persistently overseeing the system's performance and initiating necessary
modifications to preserve optimal functioning.
Further Reading
Performance Testing Tutorial
Links to an external site.
Explore the different types of performance testing in software development and
common performance issues. Learn to assess the speed, response time, stability,
reliability, scalability, and resource usage of a software application under specific
workloads.
Reference: Thomas Hamilton, 2024, 'Performance Testing Tutorial – Types (Example)', GURU99,
accessed 31 January 2024, <https://www.guru99.com/performance-testing.html>
Section 3: Case Study - Enhancing Operations at Horizon E-Solutions
Background
Horizon E-Solutions, a rapidly expanding e-service provider, was endeavoring to
consolidate its market stance by providing users with a peerless service experience.
Problem Statement
Nevertheless, their progress was obstructed by regular system lags and latency
challenges, which negatively influenced user contentment and obstructed their
growth pathway.
Implementation
To mitigate these obstacles, Horizon E-Solutions launched a thorough performance
improvement and optimisation project, which entailed:
● Analysis of Current Performance Levels
The first stage comprised an extensive review of the existing system
performance to pinpoint the prevailing gaps.
● Development of a Strategic Plan
Post-analysis, a strategic roadmap was formulated to address the
recognised performance bottlenecks.
● Optimisation Measures
A range of optimisation strategies were instituted, including code
improvements, database tuning, and network enhancements, to boost
system performance.
● Continuous Monitoring and Adjustments
A mechanism for ongoing supervision and modifications was established
to guarantee consistent optimal performance.
Outcome
The venture manifested in significant advancements, with the system now
demonstrating reduced latency and amplified transaction speeds, heightening user
satisfaction and fostering business expansion. This case demonstrates the
transformative potential of performance improvement and optimisation efforts,
illustrating their capacity to propel a business forward by delivering a superior service
experience to users.
Further Resources
The resources in this section are for further exploration, providing additional
information for deeper insights.
Expand All
Panels
Collapse All
Panels
Video: Software Testing Explained
This video provides a brief overview of software testing and its significance in the
dynamic and complex world of software development. It emphasizes the challenges
developers face in understanding every layer of abstraction and the evolving
requirements.
Software Testing Explained
Links to an external site.
Reference: Fireship, 2021, 'Software Testing Explained', YouTube, accessed 31 January 2024,
<https://youtu.be/u6QfIXgjwGQ>
Video: Do you Even Test?
A tutorial video that discusses in detail what testing is and demonstrates how to
integrate one of the most used testing frameworks (Google Test) into a CMake
project.
Do you Even Test?
Links to an external site.
Reference: Code for yourself, 2022, 'Do you Even Test?', YouTube, accessed 31 January 2024,
<https://youtu.be/pxJoVRfpRPE>
Reading: Test Case Design Techniques in Software Testing
Test case design techniques are the key to planning, designing, and implementing
tests for software applications. These techniques involve various steps that aim to
ensure the effectiveness of test cases in uncovering bugs or other defects in
software programs. This blog post will review all these techniques, including their
pros and cons and when to use them.
Test Case Design Techniques in Software Testing
Links to an external site.
Reference: Kiruthika Devaraj, 2023, 'Test Case Design Techniques in Software Testing', Testsigma,
accessed 31 January 2024, <https://testsigma.com/blog/test-case-design-techniques/>
Reading: Introduction to Unit Testing with Google Test
In modern software development, unit testing plays a vital role in ensuring the
reliability, stability, and maintainability of code. By testing individual components of a
program in isolation, developers can catch bugs early, verify expected behaviors,
and refactor code with confidence. Google Test, also known as GTest, is a popular
framework for unit testing C++ code. This article explores the fundamentals of GTest
and how it can improve the quality of your C++ projects.
Introduction to Unit Testing with Google Test
Links to an external site.
Reference: Chittaranjan Sethi, 2023, 'Introduction to Unit Testing with Google Test (GTest)', Medium,
accessed 31 January 2024,
<https://medium.com/@chittaranjansethi/introduction-to-unit-testing-with-google-test-gtest-in-c-344a8
9b8eb4>
Reading: C++ Unit Testing - A Complete Guide
Unit testing is a crucial aspect of modern software development, ensuring the
reliability and correctness of your C++ codebase. This article covers just about
everything you need to know about C++ unit testing, from the basics to advanced
practices, along with real-world examples.
C++ Unit Testing: A Complete Guide with Examples and Best Practices
Links to an external site.
Reference: Rahnuma Tasnim, 2023, 'C++ Unit Testing: A Complete Guide with Examples and Best
Practices', Software Testing Stuff, accessed 31 January 2024,
<https://www.softwaretestingstuff.com/c-unit-testing>
Reading: C++ Testing - Its Importance and Implementation
This comprehensive guide to C++ testing covers numerous aspects of testing,
including unit, integration, and functional tests, highlighting the importance of code
coverage and reliability. It provides insights into setting up the testing environment,
choosing the right testing framework, and writing test cases, covering topics such as
test-driven development, advanced testing techniques, debugging failed tests, and
automating tests. Best practices in C++ testing are highlighted.
C++ Testing: What is its Importance and Implementation
Links to an external site.
Reference: Severin Ilya, 2023, 'C++ Testing: What Is Its Importance And Implementation', Market
Splash, accessed 31 January 2024, <https://marketsplash.com/tutorials/cpp/cplusplus-tester/>
Reading: Write Unit Tests for C/C++ in Visual Studio
This article provides a comprehensive guide on writing unit tests for C and C++ code
in Visual Studio. The article covers the basic test workflow, including using the Test
Explorer window, and highlights that Visual Studio supports various C++ test
frameworks such as Microsoft Unit Testing Framework, Google Test, and Boost.Test.
It explains the steps to create and run unit tests in Visual Studio 2017 and later
versions.
Write Unit Tests for C/C++ in Visual Studio
Links to an external site.
Reference: Microsoft staff, 2023, 'Write Unit Tests for C/C++ in Visual Studio', Microsoft Learn,
accessed 31 January 2024,
<https://learn.microsoft.com/en-us/visualstudio/test/writing-unit-tests-for-c-cpp>
Reading: Tips for Improving Time-Critical Code
Writing fast code requires understanding all aspects of your application and how it
interacts with the system. This article suggests alternatives to some of the more
obvious coding techniques to help you ensure that the time-critical portions of your
code perform satisfactorily.
Links to an external site.
Tips for Improving Time-Critical Code
Links to an external site.
Reference: Microsoft staff, 2023, 'Tips for Improving Time-Critical Code', Microsoft Learn, accessed
31 January 2024, <https://learn.microsoft.com/en-us/cpp/build/tips-for-improving-time-critical-code>
Reading: Visual Studio 2022 Profiling Tools
A profiler can help you make informed decisions quickly by providing a visual
depiction of execution times and CPU usage for your application. This article
provides a quick look at the most common profiling tools.
Visual Studio 2022: First look at profiling tools
Links to an external site.
Reference: Microsoft staff, 2023, 'Visual Studio 2022: First look at profiling tools', Microsoft Learn,
accessed 31 January 2024,
<https://learn.microsoft.com/en-us/visualstudio/profiling/profiling-feature-tour>