I need to limit the CPU and bandwidth of my application for testing purposes during the development process and wrote a small bash script wrapper around the java command, but I'm not sure how I can integrate this approach with IDEA's run/debug configuration.
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Usage: javalimit [CPU Percentage] [download in kbps] [upload in kbps] [normal java args]"
echo "Required packages: trickle, cpulimit"
fi
CPU_PERCENTAGE=$1
DOWNLOAD_KBPS=$2
UPLOAD_KBPS=$3
shift 3
trickle -s -d $DOWNLOAD_KBPS -u $UPLOAD_KBPS java $@
TRICKLED_PID=$!
cpulimit --limit=$CPU_PERCENTAGE --pid=$TRICKLED_PID
My first failed approach for IDEA integration was
Statically set the cpu/down/up, removed shift
Copied my java folder to a new one, renamed java command, symbolic linked my script to bin/java
Told IDEA to use this JRE config - Cra开发者_如何学运维shed
Any insights on a better way to approach this problem would be appreciated!
I guess the best solution would be to use the Remote Debug as I've suggested in the similar question.
精彩评论