public int computeStep(int metric) { int work = 0; if (nSteps == whenToThrow) { throw new ExpectedRuntimeException("Hash step throw test"); } if (nSteps-- > 0) { if (eachStepTime > 0) { Deadline time = Deadline.in(eachStepTime); while (!time.expired()) { try { Thread.sleep(1); } catch (InterruptedException e) { throw new RuntimeException(e.toString()); } work++; } } else { work = -eachStepTime; TimeBase.step(work); try { Thread.sleep(1); } catch (InterruptedException e) { throw new RuntimeException(e.toString()); } } } return work; }