function testspdiags(N)
M = 200;
cpuorigtot = 0;
cputot = 0;
for i = 1:1000
  m = randperm(N);
  m = m(1);
  n = randperm(N);
  n = n(1);
  v = sprand(m,n,rand);
  maxc = randperm(M);
  maxc = maxc(1);
  c = floor(M*rand(1,maxc))-N/2;
  try
    cpuorig = cputime;
    spdorig = spdiagsorig(v,c);
    cpuorig = cputime-cpuorig;
    cpuorigtot = cpuorigtot+cpuorig;
    cpu = cputime;
    spd = spdiags(v,c);
    cpuspd = cputime-cpu;
    cputot = cputot+cpuspd;
    err = max(max(spdorig-spd));
    if (err ~= 0)
      error('error')
    end
  catch  
    warning('spdiagsorig failed')
  end
end
cpuorigtot
cputot