1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
function parseptbdownloadlog(fname)
% parseptbdownloadlog(fname) - Download log parser.
%
% Parses a Psychtoolbox online registration logfile
% 'fname', does stats on it, prints the summary.
%
% History:
% 16.10.2006 Written (MK).
if nargin < 1
fname = 'ptbregistration.log';
end
fd=fopen(fname, 'rt');
if fd==-1
error('File not found.');
end
ofl = [];
knownmacids = containers.Map;
transactioncount = 0;
totalcount = 0;
betacount = 0;
stablecount = 0;
trunkcount = 0;
unknowncount = 0;
oldptb306count = 0;
osxcount = 0;
wincount = 0;
linuxcount = 0;
try
while(1)
% Read next line from file:
fl = fgetl(fd);
if fl==-1
% Stop at end of file:
break;
end
% Concatenate it to current piece:
ofl = [ ofl fl ];
% Real end reached?
le = strfind(ofl, '</DATE>');
if isempty(le)
% Nope, just go ahead.
else
% Yes! Process it, then restart.
%fprintf('%s\n', ofl);
% This counts as one transaction:
transactioncount = transactioncount + 1;
% We count each MACID only once:
ls = strfind(ofl, '<MACID>');
le = strfind(ofl, '</MACID>');
% Extract macid as character string:
macid = ofl(ls+7:le-1);
if ~knownmacids.isKey(macid)
% This is a new one. Count it:
knownmacids(macid) = 1;
% Total unique count:
totalcount = totalcount + 1;
if (mod(totalcount, 1000) == 0)
fprintf('Elapsed %i\n', totalcount);
end
% if strfind(ofl, '<FLAVOR>beta</FLAVOR>')
% betacount = betacount + 1;
% end
%
% if strfind(ofl, '<FLAVOR>stable</FLAVOR>')
% stablecount = stablecount + 1;
% end
%
% if strfind(ofl, '<FLAVOR>trunk</FLAVOR>')
% trunkcount = trunkcount + 1;
% end
%
% if strfind(ofl, '<FLAVOR>Psychtoolbox-3.0.6</FLAVOR>')
% oldptb306count = oldptb306count + 1;
% end
%
% if strfind(ofl, '<FLAVOR>unknown</FLAVOR>')
% unknowncount = unknowncount + 1;
% end
if strfind(ofl, '<OS>MacOS-X')
osxcount = osxcount + 1;
end
if strfind(ofl, '<OS>Windows')
wincount = wincount + 1;
end
if strfind(ofl, '<OS>Linux')
linuxcount = linuxcount + 1;
end
end
% Reset for next item:
ofl = [];
end
end
fclose(fd);
catch
fclose(fd);
end
transactioncount
totalcount
betacount
stablecount
trunkcount
oldptb306count
unknowncount
osxcount
wincount
linuxcount
end
|