Date: Thu, 14 Jan 2016 00:57:58 +1100 (EST) From: Ian Smith <smithi@nimnet.asn.au> To: "darwinsurvivor@gmail.com" <darwinsurvivor@gmail.com> Cc: kpneal@pobox.com, "William A. Mahaffey III" <wam@hiwaay.net>, freebsd-questions@freebsd.org Subject: Re: Task to busy one CPU 100% for a period of time? Message-ID: <20160114000637.U93547@sola.nimnet.asn.au> In-Reply-To: <CAMuYtRDoKfGC0awAon1%2BBmUKsj6ugau-umgzCiR8MpbA37QTgQ@mail.gmail.com> References: <20160111002439.Q93547@sola.nimnet.asn.au> <56928802.2040802@hiwaay.net> <20160111154616.G93547@sola.nimnet.asn.au> <20160111203832.GC88498@neutralgood.org> <20160113052558.R93547@sola.nimnet.asn.au> <CAMuYtRDoKfGC0awAon1%2BBmUKsj6ugau-umgzCiR8MpbA37QTgQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 12 Jan 2016 13:02:26 -0800, darwinsurvivor@gmail.com wrote: > Have you looked at the sysutils/stress utility? It may do what you need. > > > ~Doug I have now, thanks :) It works well, given I've only tested the -c CPU load option so far. If I'd found it sooner, I might not have bothered compiling Kevin's little program and writing the below script to do about the same thing with it .. but I'm grateful for the exercise! > On Tue, Jan 12, 2016 at 10:36 AM, Ian Smith <smithi@nimnet.asn.au> wrote: > > On Mon, 11 Jan 2016 15:38:32 -0500, kpneal@pobox.com wrote: [..] > > > cc -c main.c > > > cc -c dummy.c > > > cc -o load1 main.o dummy.o > > > > > > One invocation of this program should consume an entire CPU and therefore > > > raise the load average by 1.00. Run as many as you like. > > > > > > (The reason for the two compilations is to avoid having any compiler > > > optimize away the for loop. Just to be safe.) > > > > Thankyou Kevin. Works a treat, so far tested 8 at once, loadavg = 8.00 > > > > I'll follow up hopefully tomorrow with results of a sh script to run a > > given number of instances for a given time, needing a bit more testing. So here; both this and stress give equivalent results with 2 to 8 tasks; over 4 I'm running into overheating (~90C), acpi_thermal kicking in, CPU slowing apparently - but it is summer, and still ~28C|82F at midnight! #!/bin/sh # 12/1/16 add2load.sh thanks Kevin Neal <kpneal@pobox.com> for load1 C code me=`basename $0` [ ! "$1" ] && echo "usage: $me tasks(1-12) [seconds (dflt 930)]" && exit 1 tasks=0; [ $1 -ge 1 -a $1 -le 12 ] && tasks=$1 [ $tasks -eq 0 ] && echo "$me tasks ($1) must be 1..12" && exit 1 [ "$2" ] && secs=$2 || secs=930 # default 15.5m ok=''; [ $secs -ge 20 -a $secs -le 1800 ] && ok=y [ ! "$ok" ] && echo "$me seconds ($secs) must be 20..1800" && exit 1 echo "`date` $me running $tasks load1 tasks for ${secs}s" bgpids='' done=0; trap "done=1; sleep=0" int quit term while [ $done -eq 0 ]; do while [ $tasks -gt 0 ]; do ~/bin/load1 & bgpids="$bgpids $!" tasks=$((tasks-1)) done sleep $secs done=1 done kill $bgpids || echo "$me: error killing pids $bgpids" echo "`date` $me done" trap - int quit term exit 0 cheers, Ian
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160114000637.U93547>