IntelliJ IDEA 调试配置:bash 脚本限制 cpu/带宽
我需要在开发过程中限制应用程序的 CPU 和带宽以进行测试,并围绕 java 命令编写了一个小型 bash 脚本包装器,但我不确定如何将此方法与 IDEA 的运行/调试配置集成。
#!/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
我的 IDEA 集成的第一个失败方法是
静态设置 cpu/down/up,删除 shift
将我的 java 文件夹复制到一个新文件夹,重命名 java 命令,将我的脚本符号链接到 bin/java
告诉 IDEA 使用此 JRE 配置 -
任何 崩溃如果有更好的方法来解决这个问题,我们将不胜感激!
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 - Crashed
Any insights on a better way to approach this problem would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想最好的解决方案是使用远程调试,因为我在类似问题中建议。
I guess the best solution would be to use the Remote Debug as I've suggested in the similar question.