[英]Using jRAPL in JUnit unit test
There are some way of using jRAPL or similar tool for measure energy consumption inside of unit tests? 有什么方法可以使用jRAPL或类似的工具来测量单元测试中的能耗?
Something like: 就像是:
public class FooTest{
@Before
public void startUp(){
double beginning = EnergyCheck.statCheck();
}
@After
public void tearDown(){
double end = EnergyCheck.statCheck();
System.out.println(end - beginning);
}
@Test
public void FooTest(){
//TODO
}
}
What configuration I should do to be able to use jRAPL this way, using Eclipse IDE? 为了能够通过Eclipse IDE以这种方式使用jRAPL,我应该怎么做?
Best regards. 最好的祝福。
Having looked a the code, the following might work for a given method, so long as the query took long enough. 看完代码后,只要查询花费了足够长的时间,以下内容可能就可以使用给定的方法。
@Test
public void FooTest(){
double beginning = EnergyCheck.statCheck();
//TODO
double end = EnergyCheck.statCheck();
System.out.println(end - beginning);enter code here
}
There are some issues with using RAPL when the duration of execution is very small. 当执行时间非常短时,使用RAPL存在一些问题。 See: http://os.inf.tu-dresden.de/papers_ps/greenmetrics2012-rapl.pdf
参见: http : //os.inf.tu-dresden.de/papers_ps/greenmetrics2012-rapl.pdf
The configuration you would need is to run in on Linux, the instructions indicate that you should use the command: 您需要的配置是在Linux上运行,说明指示您应该使用以下命令:
sudo modprobe msr
which enables the kernel module for monitoring RAPL based instructions. 这使内核模块可以监视基于RAPL的指令。
An alternative tool is: https://github.com/TANGO-Project/code-optimiser-plugin which is currently under development. 另一种工具是: https : //github.com/TANGO-Project/code-optimiser-plugin ,目前正在开发中。 It can give power values, but has yet to offer a direct way to calibrate the model that it uses to calculate power consumption.
它可以给出功率值,但尚未提供校准其用于计算功耗的模型的直接方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.