Skip to content

Commit e144936

Browse files
committed
Add optional heap and CPU profiling when running Flux.
- Specify `-Pprofile[=<filename>]` to enable profiling for `:metafix-runner:run`. - Specify `-Pprofile=true|false` to enable/disable profiling for `:metafix:integrationTest`. - Specify `METAFIX_INTEGRATION_TEST_PROFILE=true|false` to enable/disable profiling for `metafix/integrationTest.sh`. https://docs.oracle.com/javase/8/docs/technotes/samples/hprof.html
1 parent 62b2eb2 commit e144936

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ out/
66
node_modules/
77
xtext-server/
88
package-lock.json
9+
*.hprof.txt
910
*.vsix
1011
/metafix/src/test/resources/org/metafacture/metafix/integration/**/*.diff
1112
/metafix/src/test/resources/org/metafacture/metafix/integration/**/*.err

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ plugins {
66

77
editorconfig {
88
excludes = [
9+
'**/*.hprof.txt',
910
'**/*.out',
1011
'**/*.vsix',
1112
'**/.*',

metafix-runner/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ dependencies {
1111

1212
application {
1313
mainClass = 'org.metafacture.runner.Flux'
14+
15+
if (project.hasProperty('profile')) {
16+
def file = project.getProperty('profile') ?: project.name
17+
applicationDefaultJvmArgs = ["-agentlib:hprof=heap=sites,cpu=samples,file=${file}.hprof.txt"]
18+
}
1419
}

metafix/build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ test {
6464
task integrationTest(type: Exec, group: 'Verification') {
6565
executable './integrationTest.sh'
6666

67-
if (project.hasProperty('args')) args project.getProperty('args').split()
67+
if (project.hasProperty('args')) {
68+
args project.getProperty('args').split()
69+
}
70+
71+
if (project.hasProperty('profile')) {
72+
environment.METAFIX_INTEGRATION_TEST_PROFILE = project.getProperty('profile')
73+
}
74+
6875
environment.METAFIX_DISABLE_TO_DO = System.getProperty('org.metafacture.metafix.disableToDo')
6976
}
7077

metafix/integrationTest.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function parse_boolean() {
2525
}
2626

2727
parse_boolean "$METAFIX_DISABLE_TO_DO" && disable_todo=1 || disable_todo=
28+
parse_boolean "$METAFIX_INTEGRATION_TEST_PROFILE" && noprofile= || noprofile=no
2829

2930
[ -t 1 -a -x /usr/bin/colordiff ] && colordiff=colordiff || colordiff=cat
3031

@@ -66,7 +67,7 @@ function die() {
6667
}
6768

6869
function run_metafix() {
69-
$gradle_command -p "$root_directory" :metafix-runner:run --args="$1"
70+
$gradle_command -p "$root_directory" :metafix-runner:run --args="$1" -P${noprofile}profile="${1%.*}"
7071
}
7172

7273
function run_catmandu() {

0 commit comments

Comments
 (0)