Closed ankitkumarsindhu closed 2 months ago
Could you provide me with a minimal working example (a jar for instance), I can test on my machine?
We had issues in some cases where the monitoring loop for JoularJX ends prematurely, and therefore no energy data are recorded. It's mostly in some application servers as JoularJX tries to destroy the VM on shutdown. The tentative fix (in issue #42) ended up with side effects on regular Java applications where the loop never ends. You could try to apply that change (commit 1dd0a64) and see if that fix your issue.
Hi! Below is the working example:
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.OutputTimeUnit;
import jdk.incubator.vector.IntVector; import jdk.incubator.vector.VectorSpecies;
/**
execution time. */ public class VectorOperations1 {
private static final VectorSpecies
@State(Scope.Benchmark) public static class ArraysState { int[] a; int[] b;
@Setup(Level.Trial)
public void setUp() {
// Initialize arrays with default values for demonstration
a = new int[] { 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765 };
b = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
}
}
@Benchmark @Warmup(iterations = 4) @Measurement(iterations = 6) @BenchmarkMode({ Mode.AverageTime, Mode.Throughput }) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Fork(jvmArgs = "--add-modules=jdk.incubator.vector", value = 2) public void testVectorAdd(ArraysState state, Blackhole blackhole) { long startTime = System.nanoTime(); // Record start time int[] result1 = add(state.a, state.b); long endTime = System.nanoTime(); // Record end time long elapsedTime = endTime - startTime; // Calculate elapsed time System.out.println("Time taken for execution vector1 addition: " + elapsedTime + " nanoseconds"); blackhole.consume(result1); }
@Benchmark @Warmup(iterations = 4) @Measurement(iterations = 6) @BenchmarkMode({ Mode.AverageTime }) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Fork(jvmArgs = "--add-modules=jdk.incubator.vector", value = 2) public void testVectorMultiply(ArraysState state, Blackhole blackhole) { long startTime = System.nanoTime(); // Record start time int[] result2 = multiply(state.a, state.b); long endTime = System.nanoTime(); // Record end time long elapsedTime = endTime - startTime; // Calculate elapsed time System.out.println("Time taken for execution vector1 multiplication: " + elapsedTime + " nanoseconds"); blackhole.consume(result2); }
/**
/**
Could you try the proposed fix in issue #66, in this comment.
I have been running some test on java code with JMH and getting the details of energy consumption with JoularJX but for a specifc example it does not record the energy consumption details for anything instead it creates the similar folder structure as it creates for any test running with Joular, and the total-method energy file is empty even though the number of forks are set to 5 and the measurement iterations are 15. The sample I am using:
Is it because of vector operations used in the sample code? or something else.
Sample: @Benchmark @Warmup(iterations = 4) @Measurement(iterations = 6) @BenchmarkMode({ Mode.AverageTime }) @OutputTimeUnit(TimeUnit.MICROSECONDS) @Fork(jvmArgs = "--add-modules=jdk.incubator.vector", value = 2) public void testVectorMultiply(ArraysState state, Blackhole blackhole) { int[] result2 = multiply(state.a, state.b); blackhole.consume(result2); }