From 9c92e04d821fd5f5756c48c101f925ea3dbf3bbc Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Wed, 7 Oct 2015 14:56:36 +0200 Subject: [PATCH] call nanoTime() only if we have flag set to dump timing --- platform/util/src/com/intellij/util/CompressionUtil.java | 8 ++++---- .../intellij/util/io/PersistentHashMapValueStorage.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/util/src/com/intellij/util/CompressionUtil.java b/platform/util/src/com/intellij/util/CompressionUtil.java index fe2fa15d45c3..ee36d99ea042 100644 --- a/platform/util/src/com/intellij/util/CompressionUtil.java +++ b/platform/util/src/com/intellij/util/CompressionUtil.java @@ -63,12 +63,12 @@ public class CompressionUtil { public static final boolean DUMP_COMPRESSION_STATS = SystemProperties.getBooleanProperty("idea.dump.compression.stats", false); public static int writeCompressedWithoutOriginalBufferLength(@NotNull DataOutput out, @NotNull byte[] bytes, int length) throws IOException { - long started = System.nanoTime(); + long started = DUMP_COMPRESSION_STATS ? System.nanoTime() : 0; final byte[] compressedOutputBuffer = spareBufferLocal.getBuffer(Snappy.maxCompressedLength(length)); int compressedSize = Snappy.compress(bytes, 0, length, compressedOutputBuffer, 0); - final long time = System.nanoTime() - started; + final long time = (DUMP_COMPRESSION_STATS ? System.nanoTime() : 0) - started; mySizeAfterCompression.addAndGet(compressedSize); mySizeBeforeCompression.addAndGet(length); int requests = myCompressionRequests.incrementAndGet(); @@ -92,11 +92,11 @@ public class CompressionUtil { in.readFully(bytes, 0, size); int decompressedRequests = myDecompressionRequests.incrementAndGet(); - long started = System.nanoTime(); + long started = DUMP_COMPRESSION_STATS ? System.nanoTime() : 0; byte[] decompressedResult = Snappy.uncompress(bytes, 0, size); - long doneTime = System.nanoTime() - started; + long doneTime = (DUMP_COMPRESSION_STATS ? System.nanoTime() : 0) - started; long decompressedSize = myDecompressedSize.addAndGet(size); long decompressedTime = myDecompressionTime.addAndGet(doneTime); if (DUMP_COMPRESSION_STATS && decompressedRequests % 1000 == 0) { diff --git a/platform/util/src/com/intellij/util/io/PersistentHashMapValueStorage.java b/platform/util/src/com/intellij/util/io/PersistentHashMapValueStorage.java index 20b168a81fd4..ab1a59128a99 100644 --- a/platform/util/src/com/intellij/util/io/PersistentHashMapValueStorage.java +++ b/platform/util/src/com/intellij/util/io/PersistentHashMapValueStorage.java @@ -354,7 +354,7 @@ public class PersistentHashMapValueStorage { forceAppender(myPath); checkCancellation(); - long startedTime = System.nanoTime(); + long startedTime = ourDumpChunkRemovalTime ? System.nanoTime() : 0; long chunk = tailChunkAddress; int chunkCount = 0; @@ -426,7 +426,7 @@ public class PersistentHashMapValueStorage { if (chunkCount > 1 && !myCompactionMode) { checkCancellation(); - long endCompactionTime = System.nanoTime(); + long endCompactionTime = ourDumpChunkRemovalTime ? System.nanoTime() : 0; long diff = endCompactionTime - startedTime; myChunksRemovalTime += diff;