Skip to content
This repository was archived by the owner on Jul 14, 2026. It is now read-only.
Logo

Hardware Stress API for .NET

A .NET class library written in VB.NET, that provides a mechanism for exerting pressure on hardware resources, such as CPU, RAM, or disk drives.

Warning

This repository is archived in a read-only state and is no longer maintained.

This project is no longer updated or supported, but remains available for reference and educational use.


Forks  Contributors  Followers  Watchers Sponsors  Stars

AppVeyor CI SonarCloud Quality Gate Latest Release Language Platform License
Repo size Total Downloads Last commit Pull Requests Open IssuesClosed Issues Maintenance

Made in Spain


👋 Introduction

This project is a modest, lightweight .NET class library written in VB.NET. Its sole purpose is to provide developers with an easy-to-use API to programmatically apply workload pressure on core hardware components, specifically the CPU, RAM, and Disk I/O operations. It wraps low-level resource simulation inside a clean and predictable IDisposable pattern.

💡 Motivation

When developing applications that must run in constrained environments or handle heavy workloads, testing how your software behaves under intense hardware limitation is crucial. Instead of relying on complex, external, and bulky benchmarking software, I wanted a simple, native programmatic solution that could be easily integrated directly into .NET unit tests, integration tests, or local debugging tools.

⚡ The Real Question
How does your application react when the system runs out of resources? Does it handle timeouts gracefully, or does it crash unexpectedly? This library is designed to help you find those answers in your own test environment.

📝 Requirements

  • Visual Studio.

🚀 Getting Started

  1. Navigate to the Releases page.
  2. Download the latest .zip archive and extract its contents to your preferred directory.

🛠️ Usage

Usage is very simple, there are 3 classes: CpuStress, DiskStress and MemoryStress, which provides an Allocate() method to start stressing resources, and a Deallocate() method to stop it.

CPU Stress

Using cpuStress As New CpuStress()
    Dim percentage As Single = 20.5F 20.50%

    Console.WriteLine("Allocating CPU usage percentage...")
    cpuStress.Allocate(percentage)
    Thread.Sleep(TimeSpan.FromSeconds(5))
    Console.WriteLine("Instance CPU average usage percentage: {0:F2}%", cpuStress.InstanceCpuPercentage)
    Console.WriteLine("Process  CPU average usage percentage: {0:F2}%", cpuStress.ProcessCpuPercentage)
    Console.WriteLine()

    Console.WriteLine("Deallocating CPU usage percentage...")
    cpuStress.Deallocate()
    Thread.Sleep(TimeSpan.FromSeconds(5))
    Console.WriteLine("Instance CPU average usage percentage: {0:F2}%", cpuStress.InstanceCpuPercentage)
    Console.WriteLine("Process  CPU average usage percentage: {0:F2}%", cpuStress.ProcessCpuPercentage)
End Using

Memory Stress

Using memStress As New MemoryStress()
    Dim memorySize As Long = 1073741824 1 GB

    Console.WriteLine("Allocating physical memory size...")
    memStress.Allocate(memorySize)
    Console.WriteLine("Instance Physical Memory Size (in bytes): {0} ({1:F2} GB)", memStress.InstancePhysicalMemorySize, (memStress.InstancePhysicalMemorySize / 1024.0F ^ 3))
    Console.WriteLine("Process  Physical Memory Size (in bytes): {0} ({1:F2} GB)", memStress.ProcessPhysicalMemorySize, (memStress.ProcessPhysicalMemorySize / 1024.0F ^ 3))
    Console.WriteLine()
    Console.WriteLine("Deallocating physical memory size...")
    memStress.Deallocate()
    Console.WriteLine("Instance Physical Memory Size (in bytes): {0}", memStress.InstancePhysicalMemorySize)
    Console.WriteLine("Process  Physical Memory Size (in bytes): {0} ({1:F2} MB)", memStress.ProcessPhysicalMemorySize, (memStress.ProcessPhysicalMemorySize / 1024.0F ^ 2))
End Using

Disk Stress

Using diskStress As New DiskStress()
    Console.WriteLine("Allocating disk I/O read and write operations...")
    diskStress.Allocate(fileSize:=1048576) 1 MB

    Thread.Sleep(TimeSpan.FromSeconds(10))

    Console.WriteLine("Stopping disk I/O read and write operations...")
    diskStress.Deallocate()

    Console.WriteLine()
    Console.WriteLine("Instance disk I/O read operations count: {0} (total of files read)", diskStress.InstanceReadCount)
    Console.WriteLine("Process  disk I/O read operations count: {0}", diskStress.ProcessReadCount)
    Console.WriteLine()
    Console.WriteLine("Instance disk I/O read data (in bytes): {0} ({1:F2} GB)", diskStress.InstanceReadBytes, (diskStress.InstanceReadBytes / 1024.0F ^ 3))
    Console.WriteLine("Process  disk I/O read data (in bytes): {0} ({1:F2} GB)", diskStress.ProcessReadBytes, (diskStress.ProcessReadBytes / 1024.0F ^ 3))
    Console.WriteLine()
    Console.WriteLine("Instance disk I/O write operations count: {0} (total of files written)", diskStress.InstanceWriteCount)
    Console.WriteLine("Process  disk I/O write operations count: {0}", diskStress.ProcessWriteCount)
    Console.WriteLine()
    Console.WriteLine("Instance disk I/O written data (in bytes): {0} ({1:F2} GB)", diskStress.InstanceWriteBytes, (diskStress.InstanceWriteBytes / 1024.0F ^ 3))
    Console.WriteLine("Process  disk I/O written data (in bytes): {0} ({1:F2} GB)", diskStress.ProcessWriteBytes, (diskStress.ProcessWriteBytes / 1024.0F ^ 3))
End Using

💪 Contributing

Your contribution is highly appreciated!. If you have any ideas, suggestions, or encounter issues, feel free to open an issue by clicking here.

Your input helps make this Work better for everyone. Thank you for your support! 🚀

💰 Beyond Contribution

This work is distributed for educational purposes and without any profit motive. However, if you find value in my efforts and wish to support and motivate my ongoing work, you may consider contributing financially through the following options:

Platform How to Support
Become my sponsor on GitHub
Contribute any amount you prefer and unlock rewards!
Support me on Ko-fi
Buy me a coffee!
Become a Patron on Patreon
Support my open-source work regularly!
Make a PayPal Donation
Donate any amount you like via PayPal!
Purchase my software at Envato's CodeCanyon
Discover my desktop tools and DevCase Class Library for .NET, an extensive API suite.

Your support means the world to me! Thank you for considering it! 🤗💗

⚠️ Disclaimer

This software and its associated repository are provided strictly on an "as is" basis, without warranties of any kind, whether express or implied. This includes, but is not limited to, any implied warranties of merchantability, reliability, or fitness for a particular purpose.

The authors and copyright holders assume no liability for any direct, indirect, incidental, or consequential damages—including data loss or system errors—arising from the use, misuse, or inability to use this software. You are solely responsible for determining the appropriateness of using this tool and assume all associated risks.

Furthermore, this project operates entirely independently. The utilization of any third-party libraries or components within this software does not imply any affiliation with, or endorsement or approval by, their respective original authors.

By using this software, you agree to indemnify and hold harmless the authors from any claims, damages, or liabilities arising from your use or misuse of it.

This project is licensed under the Apache License, Version 2.0. See the License file for details.

About

A .NET class library written in VB.NET, that provides a mechanism for exerting pressure on hardware resources, such as CPU, RAM, or disk drives.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages