function test1()

% Tests the submit and retrieve time Vs the number of AOs in the database.
% 
% M Hewitson 25-07-07
% 
% $Id: test1.m,v 1.5 2008/03/01 14:53:31 hewitson Exp $
% 

[conn, username] = mysql_connect('130.75.117.61', 'LTPDA2');


% Make an AO


start_time = now;

nsecs = 10;
fs    = 10;

pl = plist();
pl = append(pl, param('nsecs', nsecs));
pl = append(pl, param('fs', fs));
pl = append(pl, param('tsfcn', 'randn(size(t))'));
a1 = ao(pl);

% Run over N submit and retrieves
N  = 1:50000;
S  = zeros(size(N));
R  = zeros(size(N));
T  = zeros(size(N));

for n=N
  
  disp(' ')
  disp(sprintf('*===== Test %d =========', n))
  disp(' ')
  
  [stime, rtime, status] = submitretrieve(conn, username, a1, n);
  
  S(n)  = stime;
  R(n)  = rtime;  
  T(n)  = status;
  
  stop_time = now;
  results.start  = start_time;
  results.stop   = stop_time;
  results.S  = S;
  results.R  = R;
  results.T  = T;
  results.N  = N;
  
  save 'test1_results.mat' results
end

close(conn);

%------------------------------------
function [st, rt, status] = submitretrieve(conn, username, a, N)

sinfo.conn                   = conn;
sinfo.username               = username;
sinfo.experiment_title       = 'Repository Test 1';
sinfo.experiment_description = sprintf('Submit/retrieve of AO # %d', N);
sinfo.reference_ids          = '';
sinfo.additional_comments    = '';
sinfo.additional_authors     = '';

% submit the ao
tic
[AOids, cid] = ltpda_obj_submit(a, sinfo);
st = toc;

% retrieve the ao
tic
b = ltpda_obj_retrieve(conn, cid);
rt = toc;

% check consistency
if a ~= b
    status = 0;
else
    status = 1;
end



% END