n = 100000
i = 45
ntimings = 100
histogramTimes = fltarr(ntimings)
whereTimes = fltarr(ntimings)
for j = 0L, ntimings - 1L do begin
d = fix(100 * randomu(seed, n))
t0 = systime(/seconds)
d1 = d
h = histogram(d1, reverse_indices=r)
if (r[i] lt r[i+1]) then d1[r[r[i]:r[i+1]-1]] = 0
t1 = systime(/seconds)
histogramTimes[j] = t1 - t0
t0 = systime(/seconds)
d2 = d
ind = where(d2 eq i, count)
if (count gt 0L) then d2[ind] = 0
t1 = systime(/seconds)
whereTimes[j] = t1 - t0
endfor
print, total(histogramTimes) / ntimings, format='(%"Average time for HISTOGRAM: %f")'
print, total(whereTimes) / ntimings, format='(%"Average time for WHERE: %f")'
end