Skip to content

Commit

Permalink
🔖 Release v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBakerEffendi committed Mar 16, 2022
1 parent f79c114 commit 167b73e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.bin
*.gzip
graph.xml
gsql_client.jar

# Ignore Gradle GUI config
gradle-app.setting
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.1.1] - 2022-03-16

### Added

- Two new metrics that are tracked: `CHANGED_CLASSES` and `CHANGED_METHODS`.

## [1.1.0] - 2022-03-15

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name := "Plume"
inThisBuild(
List(
organization := "com.github.plume-oss",
version := "1.1.0",
version := "1.1.1",
scalaVersion := "2.13.7",
crossScalaVersions := Seq("2.13.7", "3.1.1"),
resolvers ++= Seq(
Expand Down
20 changes: 17 additions & 3 deletions src/main/scala/com/github/plume/oss/Jimple2Cpg.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class Jimple2Cpg {
* @param driver The driver used to interact with the backend database.
* @param sootOnlyBuild (Experimental) Used to determine how many resources are used when only loading files
* into Soot.
* @throws Exception if any fatal error occurred during the CPG creation.
* @return The constructed CPG.
*/
def createCpg(
Expand Down Expand Up @@ -127,9 +128,24 @@ class Jimple2Cpg {

if (codeToProcess.isEmpty) {
logger.info("No files have changed since last update. Exiting...")
PlumeStatistics.setMetric(PlumeStatistics.CHANGED_CLASSES, 0L)
PlumeStatistics.setMetric(PlumeStatistics.CHANGED_METHODS, 0L)
return cpg
} else {
logger.info(s"Processing ${codeToProcess.size} new or changed program files")
val numChangedMethods = codeToProcess
.map(getQualifiedClassPath)
.map(Scene.v().getSootClass)
.map(_.getMethodCount)
.sum
logger.info(
s"Processing ${codeToProcess.size} new or changed program files " +
s"($numChangedMethods new or changed methods)"
)
PlumeStatistics.setMetric(PlumeStatistics.CHANGED_CLASSES, codeToProcess.size)
PlumeStatistics.setMetric(
PlumeStatistics.CHANGED_METHODS,
numChangedMethods
)
}

// After the diff pass any changed types are removed. Remaining types should be black listed to avoid duplicates
Expand Down Expand Up @@ -172,8 +188,6 @@ class Jimple2Cpg {

driver.buildInterproceduralEdges()
cpg
} catch {
case e: Exception => e.printStackTrace(); throw e;
} finally {
clean()
}
Expand Down
24 changes: 16 additions & 8 deletions src/main/scala/com/github/plume/oss/PlumeStatistics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,43 @@ object PlumeStatistics extends Enumeration {
*/
type PlumeStatistic = Value

val TIME_OPEN_DRIVER, TIME_CLOSE_DRIVER, TIME_EXTRACTION, TIME_REACHABLE_BY_QUERYING = Value
val TIME_OPEN_DRIVER, TIME_CLOSE_DRIVER, TIME_EXTRACTION, TIME_REACHABLE_BY_QUERYING,
CHANGED_CLASSES, CHANGED_METHODS = Value

private val time: mutable.Map[PlumeStatistic, Long] =
private val statistics: mutable.Map[PlumeStatistic, Long] =
PlumeStatistics.values.map((_, 0L)).to(collection.mutable.Map)

/** Measures the time for a given code block and saves it under the [[PlumeStatistic]] heading.
* @param stat the statistic to save the elapsed time under.
* @param statistic the statistic to save the elapsed time under.
* @param block the code block to measure.
* @tparam R the return value of the code block.
* @return the result of the code block.
*/
def time[R](stat: PlumeStatistic, block: => R): R = {
def time[R](statistic: PlumeStatistic, block: => R): R = {
val t0 = System.nanoTime()
val result = block
val t1 = System.nanoTime()
time.put(stat, t1 - t0)
statistics.put(statistic, t1 - t0)
result
}

/** Sets the value of a statistic.
* @param statistic The statistic to set.
* @param newValue The new value to associate with the statistic.
*/
def setMetric(statistic: PlumeStatistic, newValue: Long): Unit =
statistics.put(statistic, newValue)

/** The results of the measured time per process.
* @return a map of each [[PlumeStatistic]] and the time per process in nanoseconds.
*/
def results(): Map[PlumeStatistic, Long] = time.toMap
def results(): Map[PlumeStatistic, Long] = statistics.toMap

/** Sets all the clocks back to 0.
*/
def reset(): Unit = {
time.clear()
PlumeStatistics.values.map((_, 0L)).foreach { case (v, t) => time.put(v, t) }
statistics.clear()
PlumeStatistics.values.map((_, 0L)).foreach { case (v, t) => statistics.put(v, t) }
}

}

0 comments on commit 167b73e

Please sign in to comment.