Example #1
0
    private static byte[] fillBuffer(String fileName) {
      try {
        FileInputStream sif = new FileInputStream(fileName);
        int length = (int) new File(fileName).length();
        int counter = 0;

        // Only allocate size of input file rather than MAX - kmd
        // If compressed file is larger than input file this allocation
        // will fail and out of bound exception will occur
        // In real lie, compress will no do any compression as no
        // space is saved.-- kaivalya
        byte[] result = new byte[length];

        int bytes_read;
        while ((bytes_read = sif.read(result, counter, (length - counter))) > 0) {
          counter += bytes_read;
        }

        sif.close(); // release resources

        if (counter != length) {
          spec.harness.Context.getOut().println("ERROR reading test input file");
        }
        return result;
      } catch (IOException e) {
        e.printStackTrace(Context.getOut());
      }

      return null;
    }
Example #2
0
 static void prepareBuffers() {
   CB = new Compress();
   SOURCES = new Source[FILES_NUMBER];
   for (int i = 0; i < FILES_NUMBER; i++) {
     SOURCES[i] = new Source(Context.getSpecBasePath() + "/" + FILES_NAMES[i]);
   }
   DECOMPRESS_BUFFERS = new byte[Launch.currentNumberBmThreads][Source.MAX_LENGTH];
   COMPRESS_BUFFERS = new byte[Launch.currentNumberBmThreads][Source.MAX_LENGTH];
 }
Example #3
0
 public void runCompress(int btid) {
   spec.harness.Context.getOut().println("Loop count = " + LOOP_COUNT);
   for (int i = 0; i < LOOP_COUNT; i++) {
     for (int j = 0; j < FILES_NUMBER; j++) {
       Source source = SOURCES[j];
       OutputBuffer comprBuffer, decomprBufer;
       comprBuffer =
           CB.performAction(
               source.getBuffer(), source.getLength(), CB.COMPRESS, COMPRESS_BUFFERS[btid - 1]);
       decomprBufer =
           CB.performAction(
               COMPRESS_BUFFERS[btid - 1],
               comprBuffer.getLength(),
               CB.UNCOMPRESS,
               DECOMPRESS_BUFFERS[btid - 1]);
       Context.getOut().print(source.getLength() + " " + source.getCRC() + " ");
       Context.getOut().print(comprBuffer.getLength() + comprBuffer.getCRC() + " ");
       Context.getOut().println(decomprBufer.getLength() + " " + decomprBufer.getCRC());
     }
   }
 }