#!/usr/bin/octave -q
## -*-octave-*-

datafiles = argv();
datafiles = {
	     "rtems.dat"
	     "kernel.dat"
	     "readnb-write.dat"
	     "mmapbusy-write.dat"
	     "mmapbusy-mmap.dat"
	     "readbusy-write.dat"
	     "read-write.dat"
	     "mmap-write.dat"
	     "mmap-mmap.dat"
};

quantiles = [0 0.5 0.90 0.99];

mat = zeros(0, length(quantiles) + 1);
names = {};

for i=1:length(argv),
  [d, n, e, v] = fileparts(datafiles{i});
  x = load(datafiles{i})*1e6;
  stat = csv2cell([n, "-stat.txt"], '=');
  lost = stat{6,2};
  q = quantile (x, quantiles);
  q = max(q, 0)';
  mat = [ mat; q lost ];
  names{i} = n;
end

if 0,
  [mat, ind] = sortrows(mat, 2);
  names = names(ind)
end
result = [names', num2cell(mat)];
cell2csv("result", result, ' ', '"');
