Skip to content
Merged

V2 #7

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Keep all files to LF file endings
* text=auto eol=lf

*.jar binary
15 changes: 8 additions & 7 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,32 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
java: ['21', '25']
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7

- name: Set up JDK 21
uses: actions/setup-java@v5
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v6
with:
java-version: '21'
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: maven

- name: Build and test with Maven
run: mvn -B verify --file pom.xml
run: mvn -B -ntp verify --file pom.xml

- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: test-results-${{ matrix.os }}
name: test-results-${{ matrix.os }}-${{ matrix.java }}
path: target/surefire-reports/
if-no-files-found: ignore

- name: Upload JAR artifact
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'ubuntu-latest' && matrix.java == '21'
uses: actions/upload-artifact@v7
with:
name: joularcode-java
Expand Down
9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@ release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://maven.apache.org/wrapper/#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar

# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
.
.DS_Store
.idea/
.zed/
.vscode/
joular-code-java-results/
joularcodejava.properties
*.class
/joularcodejava.properties
*.class
174 changes: 100 additions & 74 deletions README.md

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions joularcodejava.properties.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (c) 2026, Adel Noureddine.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the
# GNU Lesser General Public License v3.0 (LGPL-3.0-only)
# which accompanies this distribution, and is available at
# https://www.gnu.org/licenses/lgpl-3.0.en.html
#
# Author : Adel Noureddine

# Joular Code for Java: Configuration
#
# CPU power source
# Options:
# auto (RAPL on Linux, the PowerJoular ring buffer everywhere else, including Linux machines without RAPL such as the Raspberry Pi)
# rapl (read Linux RAPL directly, from /sys/class/powercap)
# ringbuffer (read the shared memory ring buffer PowerJoular writes with -r)
# vm (inside a virtual machine, read the file the host writes the power of this virtual machine to, see vm-power-file)
# Default if left empty: auto
power-source-type=

# Path to the ring buffer (used by ringbuffer, and by auto on a machine without RAPL)
# Default if left empty (OS-dependent):
# Linux: /dev/shm/powerjoular
# macOS: /tmp/powerjoular
# Windows: %PROGRAMDATA%\powerjoular
powerjoular-ringbuffer-path=

# The path to the file where the host writes the power consumption of the guest virtual machine (if power-source-type is vm), as seen from the virtual machine
# On the host, powerjoular -p <pid of the virtual machine's process> -o <file> writes it to <file>-<pid>.csv
# Example: /mnt/shared/vm-power.csv-4242.csv
vm-power-file=

# The format of the virtual machine file (if power-source-type is vm)
# Options:
# powerjoular (the row PowerJoular rewrites every second with -o for a process: timestamp,cpu_usage,cpu_power)
# watts (the power alone, in watts, used as it is)
# Default if left empty: powerjoular
vm-power-format=

# The sample rate (milliseconds) for the agent to monitor methods usage by calling the JVM stack
# Higher count means less accurate energy data
# Lower count means higher overhead of the agent
# From 1 to 1000
# Default if left empty: 10 (good balance between accuracy and efficiency)
stack-monitoring-sample-rate=

# Output folder for results
# Default if left empty: joular-code-java-results
results-path=

# Only frames whose package.class.method starts with one of these prefixes are filtered and calculated and written to methods-power-app.csv
# methods-power-all.csv always have every branch (including those of the JDK)
# Several prefixes are separated by a comma, e.g. com.example,org.myapp; any match counts
# Default if left empty: no filter (all branches go to both files)
methods-filtering-prefix=
272 changes: 95 additions & 177 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,177 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (c) 2026, Adel Noureddine.
~ All rights reserved. This program and the accompanying materials
~ are made available under the terms of the
~ GNU Lesser General Public License v3.0 (LGPL-3.0-only)
~ which accompanies this distribution, and is available at
~ https://www.gnu.org/licenses/lgpl-3.0.en.html
~
~ Author : Adel Noureddine
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.noureddine.joular</groupId>
<artifactId>joularcodejava</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
<description>Joular Code Java is a lightweight and efficient Java agent for monitoring the energy consumption of methods and executions branches</description>
<inceptionYear>2026</inceptionYear>
<url>https://github.com/joular/joularcode-java</url>

<licenses>
<license>
<name>The GNU Lesser General Public License v3.0 (LGPL-3.0-only)</name>
<url>https://www.gnu.org/licenses/lgpl-3.0.en.html</url>
</license>
</licenses>

<developers>
<developer>
<name>Adel Noureddine</name>
<email>adel.noureddine@outlook.com</email>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/joular/joularcode-java.git</connection>
<developerConnection>scm:git:ssh://github.com:joular/joularcode-java.git</developerConnection>
<url>https://github.com/joular/joularcode-java</url>
</scm>

<properties>
<maven.compiler.release>21</maven.compiler.release>
<encoding>UTF-8</encoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mockito.version>5.23.0</mockito.version>
</properties>

<dependencies>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.18.1</version>
</dependency>
<dependency>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>6.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.6.2</version>
<executions>
<execution>
<id>enforce-java-version</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[21,)</version>
<message>Joular Code - Java requires Java 21 or later.</message>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.15.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.5</version>
<configuration>
<argLine>-Xshare:off -javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar -Dnet.bytebuddy.experimental=true --enable-native-access=ALL-UNNAMED</argLine>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<forceCreation>true</forceCreation>
<archive>
<manifestEntries>
<Agent-Class>org.noureddine.joular.joularcodejava.agent.Agent</Agent-Class>
<Premain-Class>org.noureddine.joular.joularcodejava.agent.Agent</Premain-Class>
<Can-Redefine-Classes>true</Can-Redefine-Classes>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>false</shadedArtifactAttached>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/LICENSE</exclude>
<exclude>module-info.class</exclude>
<exclude>META-INF/versions/**/module-info.class</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Agent-Class>org.noureddine.joular.joularcodejava.agent.Agent</Agent-Class>
<Premain-Class>org.noureddine.joular.joularcodejava.agent.Agent</Premain-Class>
<Can-Redefine-Classes>true</Can-Redefine-Classes>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (c) 2026, Adel Noureddine.
~ All rights reserved. This program and the accompanying materials
~ are made available under the terms of the
~ GNU Lesser General Public License v3.0 (LGPL-3.0-only)
~ which accompanies this distribution, and is available at
~ https://www.gnu.org/licenses/lgpl-3.0.en.html
~
~ Author : Adel Noureddine
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.noureddine.joular</groupId>
<artifactId>joularcodejava</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
<description>Joular Code for Java is a lightweight and efficient Java agent for monitoring the energy consumption of methods and execution branches</description>
<inceptionYear>2026</inceptionYear>
<url>https://github.com/joular/joularcode-java</url>

<licenses>
<license>
<name>The GNU Lesser General Public License v3.0 (LGPL-3.0-only)</name>
<url>https://www.gnu.org/licenses/lgpl-3.0.en.html</url>
</license>
</licenses>

<developers>
<developer>
<name>Adel Noureddine</name>
<email>adel.noureddine@outlook.com</email>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/joular/joularcode-java.git</connection>
<developerConnection>scm:git:ssh://github.com:joular/joularcode-java.git</developerConnection>
<url>https://github.com/joular/joularcode-java</url>
</scm>

<properties>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>6.1.3</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.16.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<forceCreation>true</forceCreation>
<archive>
<manifestEntries>
<Agent-Class>org.noureddine.joular.joularcodejava.agent.Agent</Agent-Class>
<Premain-Class>org.noureddine.joular.joularcodejava.agent.Agent</Premain-Class>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading
Loading