staticint GetLogSize(int size)
{ for (int i = kSubBits; i < 32; i++) for (int j = 0; j < (1 << kSubBits); j++) if (size <= ((1) << i) + (j << (i - kSubBits))) return (i << kSubBits) + j; return (32 << kSubBits);
}
staticlong MyMultDiv64(long value, long elapsedTime)
{ long freq = 1000; // ms long elTime = elapsedTime; while (freq > 1000000)
{
freq >>>= 1;
elTime >>>= 1;
} if (elTime == 0)
elTime = 1; return value * freq / elTime;
}
staticlong GetCompressRating(int dictionarySize, long elapsedTime, long size)
{ long t = GetLogSize(dictionarySize) - (18 << kSubBits); long numCommandsForOne = 1060 + ((t * t * 10) >> (2 * kSubBits)); long numCommands = (long)(size) * numCommandsForOne; return MyMultDiv64(numCommands, elapsedTime);
}
staticlong GetDecompressRating(long elapsedTime, long outSize, long inSize)
{ long numCommands = inSize * 220 + outSize * 20; return MyMultDiv64(numCommands, elapsedTime);
}
staticlong GetTotalRating( int dictionarySize, long elapsedTimeEn, long sizeEn, long elapsedTimeDe, long inSizeDe, long outSizeDe)
{ return (GetCompressRating(dictionarySize, elapsedTimeEn, sizeEn) +
GetDecompressRating(elapsedTimeDe, inSizeDe, outSizeDe)) / 2;
}
staticvoid PrintValue(long v)
{
String s = "";
s += v; for (int i = 0; i + s.length() < 6; i++)
System.out.print(" ");
System.out.print(s);
}
staticvoid PrintResults( int dictionarySize, long elapsedTime, long size, boolean decompressMode, long secondSize)
{ long speed = MyMultDiv64(size, elapsedTime);
PrintValue(speed / 1024);
System.out.print(" KB/s "); long rating; if (decompressMode)
rating = GetDecompressRating(elapsedTime, size, secondSize); else
rating = GetCompressRating(dictionarySize, elapsedTime, size);
PrintRating(rating);
}
staticpublicint LzmaBenchmark(int numIterations, int dictionarySize) throws Exception
{ if (numIterations <= 0) return 0; if (dictionarySize < (1 << 18))
{
System.out.println("\nError: dictionary size for benchmark must be >= 18 (256 KB)"); return 1;
}
System.out.print("\n Compressing Decompressing\n\n");
SevenZip.Compression.LZMA.Encoder encoder = new SevenZip.Compression.LZMA.Encoder();
SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder();
if (!encoder.SetDictionarySize(dictionarySize)) thrownew Exception("Incorrect dictionary size");
int kBufferSize = dictionarySize + kAdditionalSize; int kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;
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.