aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/profiler/analysis/ProfileInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/profiler/analysis/ProfileInfo.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/profiler/analysis/ProfileInfo.java27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/profiler/analysis/ProfileInfo.java b/src/main/java/com/google/devtools/build/lib/profiler/analysis/ProfileInfo.java
index 5050eb4436..6104674086 100644
--- a/src/main/java/com/google/devtools/build/lib/profiler/analysis/ProfileInfo.java
+++ b/src/main/java/com/google/devtools/build/lib/profiler/analysis/ProfileInfo.java
@@ -35,7 +35,6 @@ import com.google.devtools.build.lib.vfs.Path;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
@@ -883,22 +882,23 @@ public class ProfileInfo {
/**
* Loads and parses Blaze profile file.
*
- * @param profileStream profile file path
+ * @param profileFile profile file path
*
* @return ProfileInfo object with some fields populated (call calculateStats()
* and analyzeRelationships() to populate the remaining fields)
* @throws UnsupportedEncodingException if the file format is invalid
* @throws IOException if the file can't be read
*/
- public static ProfileInfo loadProfile(InputStream profileStream) throws IOException {
- // It is extremely important to wrap InflaterInputStream using BufferedInputStream because
- // the majority of reads would be done using readInt()/readLong() methods and
- // InflaterInputStream is very inefficient in handling small read requests (performance
- // difference with 1MB buffer used below is almost 10x).
- DataInputStream in =
- new DataInputStream(
- new BufferedInputStream(
- new InflaterInputStream(profileStream, new Inflater(false), 65536), 1024 * 1024));
+ public static ProfileInfo loadProfile(Path profileFile)
+ throws IOException {
+ // It is extremely important to wrap InflaterInputStream using
+ // BufferedInputStream because majority of reads would be done using
+ // readInt()/readLong() methods and InflaterInputStream is very inefficient
+ // in handling small read requests (performance difference with 1MB buffer
+ // used below is almost 10x).
+ DataInputStream in = new DataInputStream(
+ new BufferedInputStream(new InflaterInputStream(
+ profileFile.getInputStream(), new Inflater(false), 65536), 1024 * 1024));
if (in.readInt() != Profiler.MAGIC) {
in.close();
@@ -995,10 +995,7 @@ public class ProfileInfo {
public static ProfileInfo loadProfileVerbosely(Path profileFile, InfoListener reporter)
throws IOException {
reporter.info("Loading " + profileFile.getPathString());
- ProfileInfo profileInfo;
- try (InputStream in = profileFile.getInputStream()) {
- profileInfo = ProfileInfo.loadProfile(in);
- }
+ ProfileInfo profileInfo = ProfileInfo.loadProfile(profileFile);
if (profileInfo.isCorruptedOrIncomplete()) {
reporter.warn("Profile file is incomplete or corrupted - not all records were parsed");
}