Skip to content

Commit b22e2ce

Browse files
aremankares
authored andcommittedFeb 18, 2018
make the profiling service configurable via java properties (#5027)
Currently the profiling service can only configured as program argument. With this pull request it will be possible to configure it as java property, too. This feature is importent to start the profiling if you don't run the jruby executable. e.g. you use jruby in a war archive or as script engine in a standard java application.
1 parent 0101188 commit b22e2ce

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed
 

‎core/src/main/java/org/jruby/RubyInstanceConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ public static ClassLoader defaultClassLoader() {
15291529

15301530
private ProfilingMode profilingMode = Options.CLI_PROFILING_MODE.load();
15311531
private ProfileOutput profileOutput = new ProfileOutput(System.err);
1532-
private String profilingService;
1532+
private String profilingService = Options.CLI_PROFILING_SERVICE.load();;
15331533

15341534
private ClassLoader loader = defaultClassLoader();
15351535

‎core/src/main/java/org/jruby/runtime/profile/builtin/ProfiledMethods.java

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.jruby.internal.runtime.methods.DynamicMethod;
3333
import org.jruby.util.collections.NonBlockingHashMapLong;
3434

35-
import java.util.concurrent.ConcurrentHashMap;
3635
import java.util.concurrent.ConcurrentMap;
3736

3837
/**

‎core/src/main/java/org/jruby/util/cli/Options.java

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ public class Options {
224224
public static final Option<String> CLI_RECORD_SEPARATOR = string(CLI, "cli.record.separator", "\n", "Default record separator.");
225225
public static final Option<String> CLI_BACKUP_EXTENSION = string(CLI, "cli.backup.extension", "Backup extension for in-place ARGV files. Same as -i.");
226226
public static final Option<ProfilingMode> CLI_PROFILING_MODE = enumeration(CLI, "cli.profiling.mode", ProfilingMode.class, ProfilingMode.OFF, "Enable instrumented profiling modes.");
227+
public static final Option<String> CLI_PROFILING_SERVICE = string(CLI, "cli.profiling.service", "Profiling service class to use.");
227228
public static final Option<Boolean> CLI_RUBYGEMS_ENABLE = bool(CLI, "cli.rubygems.enable", true, "Enable/disable RubyGems.");
228229
public static final Option<Boolean> CLI_DID_YOU_MEAN_ENABLE = bool(CLI, "cli.did_you_mean.enable", true, "Enable/disable did_you_mean.");
229230
public static final Option<Boolean> CLI_RUBYOPT_ENABLE = bool(CLI, "cli.rubyopt.enable", true, "Enable/disable RUBYOPT processing at start.");

‎core/src/test/java/org/jruby/runtime/profile/ProfilingTest.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public void testNoProfilingServerAvailableIfProfilingIsDisabled() {
2929
Ruby ruby = Ruby.newInstance( configOne );
3030

3131
assertNull(ruby.getProfilingService());
32+
3233
}
3334
/**
3435
* Tests the {@link org.jruby.runtime.profile.ProfilingServiceLookup} too
@@ -47,7 +48,17 @@ public void testProfilingServiceLookupWorks() {
4748
assertTrue(ruby.getProfilingService() instanceof TestProfilingService);
4849
} catch( RaiseException e ) {
4950
//e.printStackTrace();
50-
// TODO hwo to mock org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- jruby/profiler/shutdown_hook
51+
// TODO how to mock org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- jruby/profiler/shutdown_hook
5152
}
5253
}
54+
55+
/**
56+
* Tests if the profiling service can be configured as java property
57+
*/
58+
public void testProfilingServiceAsJavaProperty() {
59+
60+
// java -Djruby.cli.profiling.mode=SERVICE -Djruby.cli.profiling.service=org.jruby.runtime.profile.builtin.BuiltinProfilingService -cp jruby.jar org.jruby.Main
61+
62+
// TODO how to test it ??
63+
}
5364
}

0 commit comments

Comments
 (0)
Please sign in to comment.