Mercurial > hg > ltpda
diff m-toolbox/test/aorepo_proto_test/run_UTN_repo_test.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/test/aorepo_proto_test/run_UTN_repo_test.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,160 @@ +function varargout = run_UTN_repo_test(varargin) + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % + % DESCRIPTION: RUN_UTN_REPO_TEST tests submission/retrieval from a LTPDA + % repository, for different size LTPDA User Objects and repeating each complete + % test to build some statisics. In the case of Analysis Objects (AOs) they + % contain tsdata, and the size is defined by the sampling frequency and + % length in seconds + % + % CALL: res = run_UTN_repo_test(pl) + % + % INPUTS: pl - parameter list(s) + % + % OUTPUTS: res - a matrix of structs containing the test results + % + % PARAMETER LIST: + % <key> <default value> <description> + % 'N_REPEAT' 1 number of repetitions for each test + % 'HOSTNAME' '130.75.117.67' the repository host IP + % 'DBASE' 'ltpda_test' the database name + % 'COLL_RETRIEVE' false retrieval performed via collection ID + % rather than individually + % 'N_OBJ' 10 number of objects to produce at a time. + % Insert 0 for random number + % 'OBJ_TYPE' 'ao' type of object to produce. Use 'RAND' + % or [] for random choice + % 'NSECS' 1000 for AOs: vector with the lengths (in s) to test + % 'FS' 10 for AOs: sampling frequency in Hz + % 'TEST_RESULTS_FILENAME' 'run_001' a filename for the global results + % to be stored + % + % VERSION: $Id: run_UTN_repo_test.m,v 1.10 2008/11/18 17:28:17 mauro Exp $ + % + % HISTORY: 05-01-2008 M Hueller + % Creation + % 18-11-2008 M Hueller + % Formatted for OO toolbox + % Default plist extended + % + % M-FILE INFO: Get information about this methods by calling + % >> ao.getInfo('run_UTN_repo_test') + % + % Get information about a specified set-plist by calling: + % >> ao.getInfo('run_UTN_repo_test', 'None') + % + % SEE ALSO: UTN_repo_test_func + % + % SEE: <a href="matlab: help ao/Contents;">HELP: All Analysis Object Functions:</a> + % <a href="matlab: helpwin ao/Contents;">DOC: All Analysis Object Functions:</a> + % + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + %% Check if this is a call for parameters + if utils.helper.isinfocall(varargin{:}) + varargout{1} = getInfo(varargin{3}); + return + end + + % Collect input variable names + in_names = cell(size(varargin)); + for ii = 1:nargin + in_names{ii} = inputname(ii); + end + + % Collect all plists + pls = utils.helper.collect_objects(varargin(:), 'plist', in_names); + + %% ---------------- Produce one plist + if isa(pls, 'plist') + pls = combine(pls, getDefaultPlist()); + else + pls = getDefaultPlist(); + end + + + %% ---------------- Get parameters + N_repeat = find(pls, 'N_repeat'); + nsecs = find(pls, 'NSECS'); + + %% ---------------- Open the connection with database + % Get the hostname + hostname = find(pls, 'hostname'); + + % Get the database name + database_name = find(pls, 'dbase'); + + % Establish the connection + conn = utils.mysql.connect(hostname, database_name); + + %% ---------------- Main loop + + for jj = 1:length(nsecs) + for kk = 1:N_repeat + % Prepare the plist to pass to the actual test function + pl_test = combine(plist('NSECS', nsecs(jj), ... + 'SUBMIT', true, ... % Actually makes the submission + 'CONN', conn, ... + 'SAVE_OBJS', false, ... % Don't save individual produced objects + 'SAVE_RESULTS', false, ... % Don't save individual tests results + 'RESULTS_FILENAME', ''), ... % Not really needed since we don't save individual tests results + pls); + + % Actual call to the test routine + results(jj, kk) = UTN_repo_test_func(pl_test); + track(jj, kk) = nsecs(jj); + end + end + save([find(pls,'test_results_filename') '.mat'], 'results', 'track'); + + + %% Close the connection + close (conn); + + + %% Outputs + varargout{1} = results; + varargout{2} = track; +end + +%-------------------------------------------------------------------------- +% Get Info Object +%-------------------------------------------------------------------------- +function ii = getInfo(varargin) + if nargin == 1 && strcmpi(varargin{1}, 'None') + sets = {}; + pl = []; + else + sets = {'Default'}; + pl = getDefaultPlist; + end + % Build info object + ii = minfo(mfilename, 'ao', '', utils.const.categories.helper, '$Id: run_UTN_repo_test.m,v 1.10 2008/11/18 17:28:17 mauro Exp $', sets, pl); +end + +%-------------------------------------------------------------------------- +% Get Default Plist +%-------------------------------------------------------------------------- +function plo = getDefaultPlist() + + disp('* creating default plist...'); + plo = plist('HOSTNAME', '130.75.117.67', ... + 'DBASE', 'ltpda_test', ... + 'COLL_RETRIEVE', false, ... + 'OBJ_TYPE', 'rand', ... + 'N_OBJ', 10, ... + 'N_REPEAT', 2, ... + 'NSECS', [1000], ... + 'FS', 10, ... + 'TEST_RESULTS_FILENAME', 'run_001'); + + disp('* done.'); + + + +end + +% END +