for (int size : sizes) for (int method : methods)
test(size, method);
}
// JDK doesn't like having zip file contents changed at runtime staticint uniquifier = 42;
staticvoid test(int N, int method) throws Exception {
System.out.println("N="+N+", method="+method); long time = System.currentTimeMillis() / 2000 * 2000;
CRC32 crc32 = new CRC32();
File zipFile = new File(++uniquifier + ".zip"); try {
zipFile.delete(); try (FileOutputStream fos = new FileOutputStream(zipFile);
BufferedOutputStream bos = new BufferedOutputStream(fos);
ZipOutputStream zos = new ZipOutputStream(bos))
{ for (int i = 0; i < N; i++) {
ZipEntry e = new ZipEntry("DIR/"+i);
e.setMethod(method);
e.setTime(time); if (method == ZipEntry.STORED) {
e.setSize(1);
crc32.reset();
crc32.update((byte)i);
e.setCrc(crc32.getValue());
} else {
e.setSize(0);
e.setCrc(0);
}
zos.putNextEntry(e);
zos.write(i);
}
}
try (ZipFile zip = new ZipFile(zipFile)) { if (! (zip.size() == N)) thrownew Exception("Bad ZipFile size: " + zip.size());
Enumeration entries = zip.entries();
for (int i = 0; i < N; i++) { if (i % 1000 == 0) {System.gc(); System.runFinalization();} if (! (entries.hasMoreElements())) thrownew Exception("only " + i + " elements");
ZipEntry e = (ZipEntry)entries.nextElement(); if (! (e.getSize() == 1)) thrownew Exception("bad size: " + e.getSize()); if (! (e.getName().equals("DIR/" + i))) thrownew Exception("bad name: " + i); if (! (e.getMethod() == method)) thrownew Exception("getMethod="+e.getMethod()+", method=" + method); if (! (e.getTime() == time)) thrownew Exception("getTime="+e.getTime()+", time=" + time); if (! (zip.getInputStream(e).read() == (i & 0xff))) thrownew Exception("Bad file contents: " + i);
} if (entries.hasMoreElements()) thrownew Exception("too many elements");
}
} finally {
zipFile.delete();
}
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.