1

I am trying to create a very simple batch script to make high usage of CPU and disk with low memory(RAM) footprint.

The purpose is to make the system very slow to test and fix some timeout exceptions issues.

For high CPU usage, I am able to achieve it with this simple batch script and running 4-5 instances of it.

@echo off
:loop
goto loop

I modified the script to do some read-write operations as well to get high disk usage, but despite I am running multiple instances I am still getting almost 0% disk usage with my SSD disk. Below is my modified script -

@echo off
:loop
set file=D:\text%random%.txt
FOR /L %%A IN (1,1,20) DO (ECHO This is garbage text. >> %file%)
del %file%
goto loop

Any suggestions how to increase the disk usage.

Note:

  1. My task would be done if I can make CPU and disk usage high, but I would be curious to know how to increase memory usage as well.
  2. I understand that complex solution like lots of zip/unzip using Powershell and 7Zip, etc may work. But I want to achieve this as simple as possible without using any 3rd party tools (Burn tests).
  3. I can use PowerShell as well, provided without any 3rd party tools.
Koder101
  • 844
  • 15
  • 28
  • Powershell is not a third party tool. If you don't want to use it, why did you use the Powershell tag? – Squashman Dec 22 '17 at 21:05
  • @Squashman: I know PS is not 3rd party, I can use it. I just wanted to emphasize only on 3rd party tools like 7zip. If it is confusing then I would re-phrase my statement. – Koder101 Dec 22 '17 at 21:08
  • 1
    Microsoft has an old utility you can get from them so it wouldn't be third party per se. [SQLIO](https://www.microsoft.com/en-in/download/details.aspx?id=20163). It has been superseded by [DISKSPD](https://gallery.technet.microsoft.com/DiskSpd-a-robust-storage-6cd2f223). – Squashman Dec 22 '17 at 21:16
  • test timeout of what? – Kory Gill Dec 22 '17 at 21:18
  • @KoryGill : **"test timeout of what?"**, this would be a long and irrelevant story, but still I'll try - *we are getting timeout exception when creating new site collections on SharePoint server from our CSOM utility. The test server runs slow, but our dev server runs normal and the issue is not replicale. hence want to slow down our dev server.* :) – Koder101 Dec 22 '17 at 21:22
  • Copy large files. – ACatInLove Dec 22 '17 at 21:23

4 Answers4

1

Using Powershell:

"while (1) { echo (date) | out-file 'temp.file'; sleep 0.1; rm 'temp.file' } " 
> loadme.ps1
~\Desktop $
.\loadme.ps1

And it gets loaded upto 25% with IO read/write.enter image description here

Artyom
  • 3,507
  • 2
  • 34
  • 67
1

As suggested by @Squashman, I found Diskspd Utility fulfilling my requirement.

Running the single instance of this simple command made my disk usage to 100% and CPU usage to 50%.

Diskspd.exe -b8K -d60 -h -L -o2 -t4 -r -w30 -c50M c:\io.dat

My System Config:

CPU : Intel Core i7-6600U 2.81Ghz

Ram : 16 Gigs

Community
  • 1
  • 1
Koder101
  • 844
  • 15
  • 28
0

Use Diskspd Utility as @squashman recommends for controlled I/O loads.

Here's low foot print, high CPU usage script. No .NET memory foot print to deal with. Remove the pause if you just want to go for it, otherwise, each cmd window that you visit and hit a key in, will jump your CPU usage for you (~10% on my box). On a server class machine you might have to increase the number of consoles that get created.

@setlocal
@set prompt=$G
@if not defined _procCount set _procCount=0
@echo _procCount==%_procCount%
@set /a _procCount+=1
@set _thisScript=%~f0
@if %_procCount% lss 32 call start "Burn CPU %_procCount%" cmd.exe /k %_thisScript%
@pause

@set _accumulator=0
@set _counter=2
@set _result=0

:top
@set /a _counter+=1
@set /a _result=%_counter%/2
@if %_result% == 65535 @goto :ResetCounter
@goto :top

:ResetCounter
@set /a _accumulator+=1
@set _counter=2
@echo %_accumulator%
goto :top
jwdonahue
  • 6,199
  • 2
  • 21
  • 43
0
dd if=/dev/urandom | gzip -9 >> /dev/null &
welkinwalker
  • 2,062
  • 3
  • 18
  • 21