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

datafiles = argv();
datafiles = {
	     "rtems.dat"
	     "kernel.dat"
	     "mmapbusy-mmap.dat"
	     "mmapbusy-write.dat"
	     "readnb-write.dat"
	     "readnb-noirq.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) + 2);
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)';
  avg = mean(x);
  mat = [ mat; q lost avg ];
  names{i} = n;
end

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