### Question:
PageInfo implements Serializable { private byte[] gzip(byte[] ungzipped) throws IOException, AlreadyGzippedException { if (isGzipped(ungzipped)) { throw new AlreadyGzippedException("The byte[] is already gzipped. It should not be gzipped again."); } final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); final GZIPOutputStream gzipOutputStream = new GZIPOutputStream(bytes); gzipOutputStream.write(ungzipped); gzipOutputStream.close(); return bytes.toByteArray(); } PageInfo(final int statusCode, final String contentType, final Collection headers, final Collection cookies,
                    final byte[] body, boolean storeGzipped, long timeToLiveSeconds); static boolean isGzipped(byte[] candidate); String getContentType(); byte[] getGzippedBody(); List getResponseHeaders(); List getSerializableCookies(); int getStatusCode(); byte[] getUngzippedBody(); boolean hasGzippedBody(); boolean hasUngzippedBody(); boolean isOk(); Date getCreated(); long getTimeToLiveSeconds();  }### Answer:
@Test public void testGzipPerformance() throws IOException, InterruptedException { long initialMemoryUsed = memoryUsed(); byte[] gzip = getGzipFileAsBytes(); byte[] ungzipped = null; int size = 0; long timeTaken = 0; long finalMemoryUsed = 0; long incrementalMemoryUsed = 0; StopWatch stopWatch = new StopWatch(); ungzipped = ungzip1(gzip); stopWatch.getElapsedTime(); for (int i = 0; i < 50; i++) { gzip = gzip(ungzipped); } timeTaken = stopWatch.getElapsedTime() / 50; ungzipped = ungzip1(gzip); size = ungzipped.length; assertEquals(100000, size); finalMemoryUsed = memoryUsed(); incrementalMemoryUsed = finalMemoryUsed - initialMemoryUsed; LOG.info("Average gzip time: " + timeTaken + ". Memory used: " + incrementalMemoryUsed + ". Size: " + size); }