l = 400;
n = 20;
abc = 'A':'Z';
duration = zeros(1,3); dist = 0;

for it = 1:n
  str1 = str2 = abc(randi([1 length(abc)],1,l));
  m = randi(l);
  str1(randi([1 l],1,m)) = abc(randi([1 length(abc)],1,m));
  m = randi(l);
  str2(randi([1 l],1,m)) = abc(randi([1 length(abc)],1,m));
  
  tic; d1 = editdistance(str1,str2); duration(1) += toc; #Berghel and Roach
  tic; [d2 ~] = editdistance(str1,str2); duration(2) += toc; #Former version
  tic; d3 = editdistance(str1,str2,[1 0 1],1); duration(3) += toc; #linear memory usage

  assert(d1 == d2);
  assert(d2 == d3);
  dist += d1;
endfor

disp([duration/n dist/n]);
