0001 classdef GPUBenchApp < handle
0002
0003
0004
0005
0006 properties
0007 AppPath = {'/GPUBench'};
0008 AppClass = 'GPUBenchApp';
0009 AppHandle;
0010 AppCount = 0;
0011 Increment = 1;
0012 Decrement = 0;
0013 Output;
0014 CurrClass;
0015 Version = '13a';
0016 end
0017 methods (Static)
0018 function count = refcount(increment)
0019 persistent AppCount;
0020 if(isempty(AppCount))
0021 AppCount = 1;
0022 else
0023 if(increment)
0024 AppCount = plus(AppCount,1);
0025 else
0026 AppCount = minus(AppCount,1);
0027 end
0028 end
0029 count = AppCount;
0030 end
0031 end
0032
0033 methods
0034
0035 function obj = GPUBenchApp()
0036 obj.CurrClass = metaclass(obj);
0037 startApp(obj)
0038 end
0039
0040 function value = get.AppPath(obj)
0041 appview = com.mathworks.appmanagement.AppManagementViewSilent;
0042 appAPI = com.mathworks.appmanagement.AppManagementApiBuilder.getAppManagementApiCustomView(appview);
0043
0044 myAppsLocation = char(appAPI.getMyAppsLocation);
0045
0046 value = cellfun(@(x) fullfile(myAppsLocation, x), obj.AppPath, 'UniformOutput', false);
0047 end
0048
0049
0050 function startApp(obj)
0051
0052
0053
0054
0055
0056
0057 if nargout(@gpuBenchApp) == 0
0058 eval('gpuBenchApp');
0059 else
0060 obj.AppHandle = eval('gpuBenchApp');
0061 end
0062
0063 GPUBenchApp.refcount(obj.Increment);
0064 if(ishandle(obj.AppHandle))
0065
0066 cleanupObj = onCleanup(@()appinstall.internal.stopapp([],[],obj));
0067 appdata = getappdata(obj.AppHandle);
0068 appfields = fields(appdata);
0069 found = cellfun(@(x) strcmp(x,'AppCleanupCode'), appfields);
0070 if(~any(found))
0071 setappdata(obj.AppHandle, 'AppCleanupCode', cleanupObj);
0072 end
0073 end
0074 end
0075 end
0076 end