buffer before gzip when writing analysis data

there were already buffered streams between the gzip streams
  and the file streams; however, the performance improved after
  putting a buffer on top of the gzip streams
This commit is contained in:
Mark Harrah 2010-10-30 15:46:44 -04:00
parent b601804046
commit 9135a26fb3
1 changed files with 10 additions and 10 deletions

View File

@ -4,7 +4,7 @@
package sbt
package inc
import java.io.{File, IOException}
import java.io.{File, InputStream, IOException}
import sbinary._
import Operations.{read, write}
import DefaultProtocol._
@ -15,18 +15,18 @@ object FileBasedStore
def apply(file: File)(implicit analysisF: Format[Analysis], setupF: Format[CompileSetup]): AnalysisStore = new AnalysisStore {
def set(analysis: Analysis, setup: CompileSetup): Unit =
Using.fileOutputStream()(file) { fout =>
Using.gzipOutputStream(fout) { out =>
write[(Analysis, CompileSetup)](out, (analysis, setup) )
}
}
Using.gzipOutputStream(fout) { outg =>
Using.bufferedOutputStream(outg) { out =>
write[(Analysis, CompileSetup)](out, (analysis, setup) )
}}}
def get(): Option[(Analysis, CompileSetup)] =
try { Some(getUncaught()) } catch { case io: IOException => None }
def getUncaught(): (Analysis, CompileSetup) =
Using.fileInputStream(file) { fin =>
Using.gzipInputStream(fin) { in =>
read[(Analysis, CompileSetup)]( in )
}
}
Using.gzipInputStream(fin) { ing =>
Using.bufferedInputStream(ing) { in =>
read[(Analysis, CompileSetup)]( in )
}}}
}
}
}