xenoterracide
xenoterracide

Reputation: 16837

How do I profile maven tests on windows with JProfiler?

I tried this

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <excludedGroups>com.my.test.IntegrationTest</excludedGroups>
      <argLine>-agentpath:C:\Program Files\jprofiler10\bin\windows-x64\jprofilerti.dll=port=8849,nowait</argLine>
    </configuration>
  </plugin>

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <configuration>
      <groups>com.my.test.IntegrationTest</groups>
      <argLine>-agentpath:C:\Program/ Files\jprofiler10\bin\windows-x64\jprofilerti.dll=port=8849,nowait</argLine>
    </configuration>
    <executions>

which results in

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project my-util: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_162\jre\bin\java" -agentpath:C:\Program Files\jprofiler10\bin\windows-x64\jprofilerti.dll=port=8849,nowait -jar C:\Users\xeno\IdeaProjects\my-util\target\surefire\surefirebooter6221605500745834451.jar C:\Users\xeno\IdeaProjects\my-util\target\surefire\surefire4500791091163286071tmp C:\Users\xeno\IdeaProjects\my-util\target\surefire\surefire_07989865501871806496tmp"

bonus points if it auto starts recording in the UI when it become available

Upvotes: 2

Views: 1021

Answers (1)

Ingo Kegel
Ingo Kegel

Reputation: 47995

Passing

-agentpath:<path to jprofilerti.dll>=port=8849,nowait

will just load the profiling agent but not perform any recording. In your case, there is another problem because the JVM does not start up, most probably the space in C:\Program Files splits the argument into two arguments. I would recommend to install JProfiler into a path without spaces.

To record data and save a snapshot you have to configure offline profiling. The argument looks like this:

-agentpath:<path to jprofilerti.dll>=port=8849,offline,id=<session ID>

where the session ID is taken from the top-right corner of the "Application settings" tab in the session settings dialog. In that session, you configure a "JVM startup" trigger to start recording data and and a "JVM exit" trigger to save snapshot at the end.

Upvotes: 2

Related Questions