diff --git a/ParforProgress2.m b/ParforProgress2.m index 5af2fd2..47a685d 100644 --- a/ParforProgress2.m +++ b/ParforProgress2.m @@ -48,7 +48,7 @@ end methods - function o = ParforProgress2(s, n, percentage, do_debug, use_gui) + function o = ParforProgress2(s, n, percentage, do_debug, use_gui, show_execution_time) % ParforProgress Build a Parfor Progress Monitor % Use the syntax: ParforProgress( 'Window Title', N, percentage, do_debug, use_gui ) % where N is the number of iterations in the PARFOR loop @@ -60,7 +60,11 @@ o.Port = []; % initialize server - elseif (nargin == 5 || nargin == 4 || nargin == 3 || nargin == 2) + elseif (nargin == 6 || nargin == 5 || nargin == 4 || nargin == 3 || nargin == 2) + + if nargin < 6 + show_execution_time = 1; + end if nargin < 5 use_gui = 1; @@ -79,7 +83,7 @@ o.OldVersion = 1; end - o.JavaBit = ParforProgressServer2.createServer(s, n, percentage, use_gui); + o.JavaBit = ParforProgressServer2.createServer(s, n, percentage, use_gui, show_execution_time); o.Port = double(o.JavaBit.getPort()); % Get the client host name from pctconfig - needs diff --git a/ParforProgressServer2$1.class b/ParforProgressServer2$1.class index 6b6053e..331bfe0 100644 Binary files a/ParforProgressServer2$1.class and b/ParforProgressServer2$1.class differ diff --git a/ParforProgressServer2.class b/ParforProgressServer2.class index 832f3cc..19fb3fa 100644 Binary files a/ParforProgressServer2.class and b/ParforProgressServer2.class differ diff --git a/ParforProgressServer2.java b/ParforProgressServer2.java index e5399f9..6524a7d 100644 --- a/ParforProgressServer2.java +++ b/ParforProgressServer2.java @@ -60,7 +60,8 @@ public class ParforProgressServer2 implements Runnable, ActionListener { private boolean USE_GUI = true; private int counter; private int DEBUG = 0; - private AtomicBoolean show_execution_time_executed; + private AtomicBoolean enable_show_execution_time; // should we run / execute "show_execution_time"? + private AtomicBoolean show_execution_time_executed; // did we execute "show_execution_time"? private AtomicBoolean stop_program_executed; private Console console; @@ -207,10 +208,10 @@ public String ETA(int maximum) { * Create a "server" progress monitor - this runs on the desktop client and * pops up the progress monitor UI. */ - public static ParforProgressServer2 createServer(String s, int N, double update_percentage, boolean use_gui) throws IOException { + public static ParforProgressServer2 createServer(String s, int N, double update_percentage, boolean use_gui, boolean show_execution_time) throws IOException { ParforProgressServer2 ret = new ParforProgressServer2(); int show_port = 0; - ret.setup(s, N, update_percentage, show_port, use_gui); + ret.setup(s, N, update_percentage, show_port, use_gui, show_execution_time); ret.start(); return ret; } @@ -313,7 +314,8 @@ public static void main( String args[] ) { ParforProgressServer2 myserver = new ParforProgressServer2(); int show_port = 1; boolean use_gui = true; - myserver.setup(displayString, totalNumberRuns, updateEachPercent, show_port, use_gui); + boolean show_execution_time = true; + myserver.setup(displayString, totalNumberRuns, updateEachPercent, show_port, use_gui, show_execution_time); myserver.start(); } @@ -321,7 +323,7 @@ public int getPort() { return ((InetSocketAddress)serverSocket.socket().getLocalSocketAddress()).getPort(); } - public void setup(String s, int N, double update_percentage, int show_port, boolean use_gui) { + public void setup(String s, int N, double update_percentage, int show_port, boolean use_gui, boolean show_execution_time) { serverSocket = null; @@ -364,6 +366,7 @@ public void setup(String s, int N, double update_percentage, int show_port, bool show_execution_time_executed = new AtomicBoolean(false); stop_program_executed = new AtomicBoolean(false); + enable_show_execution_time = new AtomicBoolean(show_execution_time); // initialize console output console = System.console(); @@ -477,7 +480,7 @@ public void stop_program() { } public void show_execution_time() { - if (show_execution_time_executed.get() == false) { + if (show_execution_time_executed.get() == false && enable_show_execution_time.get() == true) { show_execution_time_executed.set(true); diff --git a/ParforProgressStarter2.m b/ParforProgressStarter2.m index 34a3cf4..57d8e86 100644 --- a/ParforProgressStarter2.m +++ b/ParforProgressStarter2.m @@ -1,4 +1,4 @@ -function ppm = ParforProgressStarter2(s, n, percentage, do_debug, run_javaaddpath) +function ppm = ParforProgressStarter2(s, n, percentage, do_debug, run_javaaddpath, show_execution_time) % Starter function for parfor progress-monitor, that will automatically % choose between a text or a GUI progress monitor. You can use this % progress-monitor in both for and parfor loops. @@ -19,8 +19,10 @@ % % by default we always run 'javaaddpath'. Set this to 0 if you are % % making use of globals. % run_javaaddpath = 1; +% % by default we show the execution time once ParforProgress ends. +% show_execution_time = 1; % try % Initialization -% ppm = ParforProgressStarter2('test', N, percentage_update, do_debug, run_javaaddpath); +% ppm = ParforProgressStarter2('test', N, percentage_update, do_debug, run_javaaddpath, show_execution_time); % catch me % make sure "ParforProgressStarter2" didn't get moved to a different directory % if strcmp(me.message, 'Undefined function or method ''ParforProgressStarter2'' for input arguments of type ''char''.') % error('ParforProgressStarter2 not in path.'); @@ -51,7 +53,7 @@ %% if nargin < 2 - disp('usage: ppm = ParforProgressStarter2( text, number_runs, update_percentage, do_debug, run_javaaddpath )'); + disp('usage: ppm = ParforProgressStarter2( text, number_runs, update_percentage, do_debug, run_javaaddpath, show_execution_time )'); ppm = []; return; end @@ -67,6 +69,10 @@ if nargin < 5 run_javaaddpath = 1; end + + if nargin < 6 + show_execution_time = 1; + end %% determine whether java and awt are available java_enabled = 1; @@ -126,10 +132,10 @@ switch version_to_use case 1 use_gui = 1; - ppm = ParforProgress2(s, n, percentage, do_debug, use_gui); + ppm = ParforProgress2(s, n, percentage, do_debug, use_gui, show_execution_time); case 2 use_gui = 0; - ppm = ParforProgress2(s, n, percentage, do_debug, use_gui); + ppm = ParforProgress2(s, n, percentage, do_debug, use_gui, show_execution_time); case 3 % no java, no awt, or old matlab version disp('Progress will update in arbitrary order.'); diff --git a/ParforProgressStressTest2.m b/ParforProgressStressTest2.m index 3e6ad26..ac01f72 100644 --- a/ParforProgressStressTest2.m +++ b/ParforProgressStressTest2.m @@ -1,4 +1,4 @@ -function ParforProgressStressTest2(N, run_javaaddpath) +function ParforProgressStressTest2(N, run_javaaddpath, show_execution_time) % Stress test for 'ParforProgressStarter2'. In case of timeouts, you can % use this function to determine how many simultaneous connections your % computer can handle, and adjust the ppm.increment() call accordingly. @@ -7,6 +7,11 @@ function ParforProgressStressTest2(N, run_javaaddpath) % %% + if nargin < 3 + % by default we show the execution time once ParforProgress ends. + show_execution_time = 1; + end + if nargin < 2 % by default we always run 'javaaddpath'. Set this to 0 if you are % making use of globals. @@ -25,7 +30,7 @@ function ParforProgressStressTest2(N, run_javaaddpath) % show debugging information. do_debug = 1; try % Initialization - ppm = ParforProgressStarter2('test task - ParforProgressStarter2', N, percentage_update, do_debug, run_javaaddpath); + ppm = ParforProgressStarter2('test task - ParforProgressStarter2', N, percentage_update, do_debug, run_javaaddpath, show_execution_time); catch me % make sure "ParforProgressStarter2" didn't get moved to a different directory if strcmp(me.message, 'Undefined function or method ''ParforProgressStarter2'' for input arguments of type ''char''.') error('ParforProgressStarter2 not in path.'); diff --git a/README.md b/README.md index bb75bf7..fc1b25f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## A) About -This is version 0.2.7 of `ParforProgress2`, a simple parfor progress monitor for matlab. See also http://www.mathworks.com/matlabcentral/fileexchange/35609-matlab-parforprogress2. +This is version 0.2.8 of `ParforProgress2`, a simple parfor progress monitor for matlab. See also http://www.mathworks.com/matlabcentral/fileexchange/35609-matlab-parforprogress2. This progress monitor comes with a nice wrapper [`ParforProgressStarter2.m`](ParforProgressStarter2.m) which will take care of adding the classes to the java class path, depending on whether matlabpool / parpool is enabled or not. @@ -45,6 +45,7 @@ Next, startup Matlab and call `ParforProgressStarter2`, but do not run `javaddpa ``` >> % setup parameters + >> show_execution_time = 1; >> run_javaaddpath = 0; >> s = 'dummy task'; >> n = 100; @@ -52,7 +53,7 @@ Next, startup Matlab and call `ParforProgressStarter2`, but do not run `javaddpa >> do_debug = 0; >> >> % initialize the ProgressMonitor - >> ppm = ParforProgressStarter2(s, n, percentage, do_debug, run_javaaddpath) + >> ppm = ParforProgressStarter2(s, n, percentage, do_debug, run_javaaddpath, show_execution_time) >> >> % run your computation >> for j = 1 : n