@Test
    public final void testHeapStress() {
        int count = 1000000; // number of times to call offer, pollFirst, and pollLast
        boolean show = false; // print operations on the heap as they are performed
        for (int i = 0; i < count; ++i) {
            if (!heap.isEmpty() && rand.nextBoolean()) {
                TestItem item = heap.poll();
                if (show)
                    System.out.println("poll " + item.val);
            }
            else {
                TestItem item = new TestItem(rand.nextInt());
                heap.offer(item);
                if (show)
                    System.out.println("offer " + item.val);
            }
            if (show)
                System.out.flush();
            assertIsHeap(heap);
        }
    }