这篇文章主要讲解了“怎么使用Linux平台下的压力测试工具stress-ng”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么使用Linux平台下的压力测试工具stress-ng”吧!

安装很简单,在CentOS下,通过yum -y install stress-ng即可安装此工具.
安装成功后,执行man stress-ng可查看该工具的帮助信息.

NAMEstress-ng-atooltoloadandstressacomputersystemstress-ng是计算机系统进行压力测试的工具.SYNOPSISstress-ng[OPTION[ARG]]...使用方法:stress-ng[OPTION[ARG]]...DESCRIPTIONstress-ngwillstresstestacomputersysteminvariousselectableways.Itwasdesignedtoexercisevariousphysicalsubsystemsofacomputeraswellasthevar‐iousoperatingsystemkernelinterfaces.stress-ngalsohasawiderangeofCPUspecificstressteststhatexercisefloatingpoint,integer,bitmanipulationandcontrolflow.stress-ngwasoriginallyintendedtomakeamachineworkhardandtriphardwareissuessuchasthermaloverrunsaswellasoperatingsystembugsthatonlyoccurwhenasystemisbeingthrashedhard.Usestress-ngwithcautionassomeofthetestscanmakeasystemrunhotonpoorlydesignedhardwareandalsocancauseexcessivesystemthrashingwhichmaybedifficulttostop.stress-ngcanalsomeasuretestthroughputrates;thiscanbeusefultoobserveperformancechangesacrossdifferentoperatingsystemreleasesortypesofhard‐ware.However,ithasneverbeenintendedtobeusedasaprecisebenchmarktestsuite,sodoNOTuseitinthismanner.Runningstress-ngwithrootprivilegeswilladjustoutofmemorysettingsonLinuxsystemstomakethestressorsunkillableinlowmemorysituations,sousethisjudiciously.Withtheappropriateprivilege,stress-ngcanallowtheioniceclassandionicelevelstobeadjusted,again,thisshouldbeusedwithcare.Onecanspecifythenumberofprocessestoinvokepertypeofstresstest;speci‐fyinganegativeorzerovaluewillselectthenumberofprocessorsavailableasdefinedbysysconf(_SC_NPROCESSORS_CONF).stress-ng提供了N中途径对系统进行测试.该工具可运行计算机的各种物理子系统(如CPU/内存/网络等)以及各种OS内核接口.stress-ng有大量的CPU压力测试方法,包括测试浮点数/整数/位运算和控制流程等.stress-ng的最初目的是给机器加压,通过使系统过载来发现OS的bug.要注意的是,stress-ng在设计不良的系统中运行可能会系统宕机.OPTIONSGeneralstress-ngcontroloptions:...详细可参考stress-ng手册.EXAMPLES使用样例stress-ng--vm8--vm-bytes80%-t1hrun8virtualmemorystressorsthatcombineduse80%oftheavailablemem‐oryfor1hour.Thuseachstressoruses10%oftheavailablememory.执行8个虚拟的内存压测器,合计使用80%的可用内存,持续时间1小时,每个压测器约10%的可用内存.stress-ng--cpu4--io2--vm1--vm-bytes1G--timeout60srunsfor60secondswith4cpustressors,2iostressorsand1vmstressorusing1GBofvirtualmemory.stress-ng--iomix2--iomix-bytes10%-t10mruns2instancesofthemixedI/Ostressorsusingatotalof10%oftheavailablefilesystemspacefor10minutes.Eachstressorwilluse5%oftheavailablefilesystemspace.stress-ng--cpu8--cpu-ops800000runs8cpustressorsandstopsafter800000bogooperations.stress-ng--sequential2--timeout2m--metricsrun2simultaneousinstancesofallthestressorssequentiallyonebyone,eachfor2minutesandsummarisewithperformancemetricsattheend.stress-ng--cpu4--cpu-methodfft--cpu-ops10000--metrics-briefrun4FFTcpustressors,stopafter10000bogooperationsandproduceasummaryjustfortheFFTresults.stress-ng--cpu0--cpu-methodall-t1hruncpustressorsonallonlineCPUsworkingthroughalltheavailableCPUstressorsfor1hour.stress-ng--all4--timeout5mrun4instancesofallthestressorsfor5minutes.stress-ng--random64run64stressorsthatarerandomlychosenfromalltheavailablestressors.stress-ng--cpu64--cpu-methodall--verify-t10m--metrics-briefrun64instancesofallthedifferentcpustressorsandverifythatthecomputationsarecorrectfor10minuteswithabogooperationssummaryattheend.stress-ng--sequential0-t10mrunallthestressorsonebyonefor10minutes,withthenumberofinstancesofeachstressormatchingthenumberofonlineCPUs.stress-ng--sequential8--classio-t5m--timesrunallthestressorsintheioclassonebyonefor5minuteseach,with8instancesofeachstressorrunningconcurrentlyandshowoveralltimeutil‐isationstatisticsattheendoftherun.stress-ng--all0--maximize--aggressiverunallthestressors(1instanceofeachperCPU)simultaneously,maximizethesettings(memorysizes,fileallocations,etc.)andselectthemostdemanding/aggressiveoptions.stress-ng--random32-xnuma,hdd,keyrun32randomlyselectedstressorsandexcludethenuma,hddandkeystres‐sorsstress-ng--sequential4--classvm--excludebigheap,brk,stackrun4instancesoftheVMstressorsoneaftereachother,excludingthebigheap,brkandstackstressorsstress-ng--taskset0,2-3--cpu3run3instancesoftheCPUstressorandpinthemtoCPUs0,2and3.

感谢各位的阅读,以上就是“怎么使用Linux平台下的压力测试工具stress-ng”的内容了,经过本文的学习后,相信大家对怎么使用Linux平台下的压力测试工具stress-ng这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!