These are chat archives for Spirals-Team/powerapi

17th
Jan 2019
Muyassarov Feruz
@mFeruz_gitlab
Jan 17 09:33
Hi. I am doing a project to measure energy consumption of application running on bare metal. Thus, according to comments I chose to use powerapi over bitWatts. However, I can't really download CLI from the following link https://github.com/Spirals-Team/powerapi/wiki/Getting-started-CLI, because it prompts 404 error. Second, if I clone it from the git repo, what should I do afterwards to get values of power consumption? I have Java, Maven installed, but I am confused with the steps? Can someone please share the installation steps and how to run experiments? I know that there are wiki pages related to powerapi but not installation guide. Thank you very much in advance.
Thibault Béziers la Fosse
@orichalque
Jan 17 13:20

Hi @mFeruz_gitlab , there's a maven dependency specified here: https://github.com/Spirals-Team/powerapi/wiki/Getting-started-API
You'll be able to use powerapi through this dependency. I'll paste you a sample of the code I use to measure the power of a process.

  def run(pid: Int): Unit = {
    val module = new CpuSimpleModule(new LinuxHelper, tdp, tdpFactor)
    val cpu = PowerMeter.loadModule(module)
    monitoring = cpu.monitor(Process(pid))
                    .every(frequency)
                    .to(console)
  }

  def stop(): Unit = {
    monitoring.cancel()
  }

tdp and tdp factor depend on your CPU. You might want to check the characteristics. The console I use is the JFreeChartDisplay. It'll show the power consumption in a nice chart. But I'm sure there's plenty of other options, especially if you want to save the data. Of course, if you're not running with Linux, don't use the LinuxHelper ;-)
I hope it helps.

Muyassarov Feruz
@mFeruz_gitlab
Jan 17 16:12
Hi @orichalque , First of all thank you very much. Now, it is more clear. So, what I did is:
  1. clone the powerapi rep (git clone git://github.com/Spirals-Team/powerapi)
  2. Compile it ($ sudo sbt publishLocal)
  3. Include repository location in build.sbt file as mentioned in https://github.com/Spirals-Team/powerapi/wiki/Getting-started-API
             (resolvers ++= Seq("OSS Sonatype snapshot repository" at 
              "https://oss.sonatype.org/content/repositories/snapshots")
  4. Create a scala file with the following code (I added my processeor's TDP):
       def run(pid: Int): Unit = {
    val module = new CpuSimpleModule(new LinuxHelper, 15, 0.7)
    val cpu = PowerMeter.loadModule(ProcFSCpuSimpleModule())
    monitoring = cpu.monitor(Process(8052))
                 .every(100)
                 .to(JFreeChartDisplay)
    }
    def stop(): Unit = {
    monitoring.cancel()
    }
  5. Compile this scala file
  6. and expect for nice chart:)), which is not there yet((. Could you please confirm that I am not missing anything here. Thank you for your time and attention.
Thibault Béziers la Fosse
@orichalque
Jan 17 19:05
Hi, this seems ok, except that you declare a val module with your tpd but use a different one (i.e. ProcFSCpuSimpleModule()) in your PowerMeter :)
Muyassarov Feruz
@mFeruz_gitlab
Jan 17 22:13
@orichalque Thanks a lot, got it