This repository has been archived by the owner on Mar 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from Spirals-Team/develop
Merge branch "develop" into "master" (Milestone 3.2)
- Loading branch information
Showing
264 changed files
with
8,063 additions
and
17,478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
language: scala | ||
scala: | ||
- 2.11.4 | ||
- 2.11.6 | ||
script: | ||
- sbt clean coverage test | ||
before_install: | ||
- openssl aes-256-cbc -K $encrypted_48ebb0d1c0b9_key -iv $encrypted_48ebb0d1c0b9_iv | ||
-in secrets.tar.enc -out secrets.tar -d | ||
- tar xvf secrets.tar | ||
- sbt clean "project powerapi-core" coverage test | ||
after_success: | ||
- sbt coverageReport | ||
- sbt coverageAggregate | ||
- sbt codacyCoverage | ||
- sbt "project powerapi-core" coverageReport | ||
- sbt "project powerapi-core" codacyCoverage | ||
- sbt "project powerapi-core" coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,14 +23,13 @@ | |
package org.powerapi.app | ||
|
||
import java.lang.management.ManagementFactory | ||
|
||
import org.powerapi.core.target.{Application, All, Process, Target} | ||
import org.powerapi.module.rapl.RAPLModule | ||
import org.powerapi.reporter.{FileDisplay, JFreeChartDisplay, ConsoleDisplay} | ||
import org.powerapi.{PowerMonitoring, PowerMeter, PowerModule} | ||
import org.powerapi.{PowerMonitoring, PowerMeter} | ||
import org.powerapi.core.power._ | ||
import org.powerapi.module.cpu.dvfs.CpuDvfsModule | ||
import org.powerapi.module.cpu.simple.CpuSimpleModule | ||
import org.powerapi.module.cpu.simple.{SigarCpuSimpleModule, ProcFSCpuSimpleModule} | ||
import org.powerapi.module.libpfm.{LibpfmHelper, LibpfmCoreProcessModule, LibpfmCoreModule} | ||
import org.powerapi.module.powerspy.PowerSpyModule | ||
import scala.concurrent.duration.DurationInt | ||
|
@@ -44,7 +43,7 @@ import scala.sys.process.stringSeqToProcess | |
* @author <a href="mailto:[email protected]">Loïc Huertas</a> | ||
*/ | ||
object PowerAPI extends App { | ||
val modulesR = """(cpu-simple|cpu-dvfs|libpfm-core|libpfm-core-process|powerspy|rapl)(,(cpu-simple|cpu-dvfs|libpfm-core|libpfm-core-process|powerspy|rapl))*""".r | ||
val modulesR = """(procfs-cpu-simple|sigar-cpu-simple|cpu-dvfs|libpfm-core|libpfm-core-process|powerspy|rapl)(,(procfs-cpu-simple|sigar-cpu-simple|cpu-dvfs|libpfm-core|libpfm-core-process|powerspy|rapl))*""".r | ||
val aggR = """max|min|geomean|logsum|mean|median|stdev|sum|variance""".r | ||
val durationR = """\d+""".r | ||
val pidR = """(\d+)""".r | ||
|
@@ -65,19 +64,6 @@ object PowerAPI extends App { | |
case _ => false | ||
} | ||
|
||
implicit def modulesStrToPowerModules(str: String): Seq[PowerModule] = { | ||
(for(module <- str.split(",")) yield { | ||
module match { | ||
case "cpu-simple" => CpuSimpleModule() | ||
case "cpu-dvfs" => CpuDvfsModule() | ||
case "libpfm-core" => LibpfmCoreModule() | ||
case "libpfm-core-process" => LibpfmCoreProcessModule() | ||
case "powerspy" => PowerSpyModule() | ||
case "rapl" => RAPLModule() | ||
} | ||
}).toSeq | ||
} | ||
|
||
def validateAgg(str: String): Boolean = str match { | ||
case aggR(_*) => true | ||
case _ => false | ||
|
@@ -121,16 +107,18 @@ object PowerAPI extends App { | |
def printHelp(): Unit = { | ||
val str = | ||
""" | ||
|PowerAPI, Spirals Team" | ||
|PowerAPI, Spirals Team | ||
| | ||
|Build a software-defined power meter. Do not forget to configure correctly the modules (see the documentation). | ||
|Build a software-defined power meter. Do not forget to configure correctly the modules. | ||
|You can use different settings per software-defined power meter for some modules by using the optional prefix option. | ||
|Please, refer to the documentation inside the GitHub wiki for further details. | ||
| | ||
|usage: ./powerapi modules [cpu-simple|cpu-dvfs|libpfm-core|libpfm-core-proces|powerspy|rapl,...] \ | ||
| monitor --frequency [ms] --targets [pid, ..., app, ...)|all] --agg [max|min|geomean|logsum|mean|median|stdev|sum|variance] --[console,file [filepath],chart] \ | ||
|usage: ./powerapi modules [procfs-cpu-simple|sigar-cpu-simple|cpu-dvfs|libpfm-core|libpfm-core-proces|powerspy|rapl,...] *--prefix [name]* \ | ||
| monitor --frequency [ms] --targets [pid, ..., app, ...|all] --agg [max|min|geomean|logsum|mean|median|stdev|sum|variance] --[console,file [filepath],chart] \ | ||
| duration [s] | ||
| | ||
|example: ./powerapi modules cpu-simple monitor --frequency 1000 --targets firefox --agg max --console monitor --targets chrome --agg max --console \ | ||
| modules powerspy monitor --frequency 1000 --targets all --agg max --console \ | ||
|example: ./powerapi modules procfs-cpu-simple monitor --frequency 1000 --targets firefox,chrome --agg max --console \ | ||
| modules powerspy --prefix powermeter2 monitor --frequency 1000 --targets all --agg max --console \ | ||
| duration 30 | ||
""".stripMargin | ||
|
||
|
@@ -139,16 +127,21 @@ object PowerAPI extends App { | |
|
||
def cli(options: List[Map[Symbol, Any]], duration: String, args: List[String]): (List[Map[Symbol, Any]], String) = args match { | ||
case Nil => (options, duration) | ||
case "modules" :: value :: "--prefix" :: prefix :: "monitor" :: tail if validateModules(value) => { | ||
val (remainingArgs, monitors) = cliMonitorsSubcommand(List(), Map(), tail.map(_.toString)) | ||
cli(options :+ Map('modules -> value, 'prefix -> Some(prefix), 'monitors -> monitors), duration, remainingArgs) | ||
} | ||
case "modules" :: value :: "monitor" :: tail if validateModules(value) => { | ||
val (remainingArgs, monitors) = cliMonitorsSubcommand(List(), Map(), tail.map(_.toString)) | ||
cli(options :+ Map('modules -> value, 'monitors -> monitors), duration, remainingArgs) | ||
cli(options :+ Map('modules -> value, 'prefix -> None, 'monitors -> monitors), duration, remainingArgs) | ||
} | ||
case "duration" :: value :: tail if validateDuration(value) => cli(options, value, tail) | ||
case option :: tail => println(s"unknown cli option $option"); sys.exit(1) | ||
} | ||
|
||
def cliMonitorsSubcommand(options: List[Map[Symbol, Any]], currentMonitor: Map[Symbol, Any], args: List[String]): (List[String], List[Map[Symbol, Any]]) = args match { | ||
case Nil => (List(), options :+ currentMonitor) | ||
case "modules" :: value :: "--prefix" :: prefix :: "monitor" :: tail if validateModules(value) => (List("modules", value, "--prefix", prefix, "monitor") ++ tail, options :+ currentMonitor) | ||
case "modules" :: value :: "monitor" :: tail if validateModules(value) => (List("modules", value, "monitor") ++ tail, options :+ currentMonitor) | ||
case "duration" :: value :: tail if validateDuration(value) => (List("duration", value) ++ tail, options :+ currentMonitor) | ||
case "monitor" :: tail => cliMonitorsSubcommand(options :+ currentMonitor, Map(), tail) | ||
|
@@ -167,12 +160,28 @@ object PowerAPI extends App { | |
} | ||
|
||
else { | ||
Seq("bash", "scripts/system.bash").! | ||
if(System.getProperty("os.name").toLowerCase.indexOf("nix") >= 0 || System.getProperty("os.name").toLowerCase.indexOf("nux") >= 0) Seq("bash", "scripts/system.bash").! | ||
val (configuration, duration) = cli(List(), "3600", args.toList) | ||
|
||
var libpfmHelper: Option[LibpfmHelper] = None | ||
|
||
if(configuration.count(powerMeterConf => powerMeterConf('modules).toString.contains("libpfm")) != 0) { | ||
libpfmHelper = Some(new LibpfmHelper) | ||
libpfmHelper.get.init() | ||
} | ||
|
||
for(powerMeterConf <- configuration) { | ||
val modules = powerMeterConf('modules).toString | ||
if(modules.contains("libpfm-core") || modules.contains("libpfm-core-process")) LibpfmHelper.init() | ||
val modules = (for(module <- powerMeterConf('modules).toString.split(",")) yield { | ||
module match { | ||
case "procfs-cpu-simple" => ProcFSCpuSimpleModule() | ||
case "sigar-cpu-simple" => SigarCpuSimpleModule() | ||
case "cpu-dvfs" => CpuDvfsModule() | ||
case "libpfm-core" => LibpfmCoreModule(powerMeterConf('prefix).asInstanceOf[Option[String]], libpfmHelper.get) | ||
case "libpfm-core-process" => LibpfmCoreProcessModule(powerMeterConf('prefix).asInstanceOf[Option[String]], libpfmHelper.get) | ||
case "powerspy" => PowerSpyModule() | ||
case "rapl" => RAPLModule() | ||
} | ||
}).toSeq | ||
|
||
val powerMeter = PowerMeter.loadModule(modules: _*) | ||
powerMeters :+= powerMeter | ||
|
@@ -207,8 +216,10 @@ object PowerAPI extends App { | |
|
||
Thread.sleep(duration.toInt.seconds.toMillis) | ||
|
||
val isLibpfmInit = configuration.count(powerMeterConf => powerMeterConf('modules).toString.contains("libpfm-core") || powerMeterConf('modules).toString.contains("libpfm-core-process")) != 0 | ||
if(isLibpfmInit) LibpfmHelper.deinit() | ||
libpfmHelper match { | ||
case Some(helper) => helper.deinit() | ||
case _ => {} | ||
} | ||
} | ||
|
||
shutdownHookThread.start() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.