< prev index next >

test/java/util/zip/TimeChecksum.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 /* @test
  26  * @bug 7109837
  27  * @summary Test Adler32/CRC32.update(ByteBuffer)

  28  */
  29 
  30 import java.util.*;
  31 import java.util.zip.*;
  32 import java.nio.*;
  33 
  34 public class TimeChecksum {
  35 
  36     static long time(Adler32 adler32, byte[] data, int iters, int len) {
  37         long start_t = System.nanoTime();
  38         for (int i = 0; i < iters; i++) {
  39             adler32.reset();
  40             adler32.update(data, 0, len);
  41         }
  42         long t = System.nanoTime() - start_t;
  43         System.out.printf("%,12d", t / len);
  44         return t;
  45     }
  46 
  47     static long time(Adler32 adler32, ByteBuffer buf, int iters) {




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 /* @test
  26  * @bug 7109837
  27  * @summary Test Adler32/CRC32.update(ByteBuffer)
  28  * @key randomness
  29  */
  30 
  31 import java.util.*;
  32 import java.util.zip.*;
  33 import java.nio.*;
  34 
  35 public class TimeChecksum {
  36 
  37     static long time(Adler32 adler32, byte[] data, int iters, int len) {
  38         long start_t = System.nanoTime();
  39         for (int i = 0; i < iters; i++) {
  40             adler32.reset();
  41             adler32.update(data, 0, len);
  42         }
  43         long t = System.nanoTime() - start_t;
  44         System.out.printf("%,12d", t / len);
  45         return t;
  46     }
  47 
  48     static long time(Adler32 adler32, ByteBuffer buf, int iters) {


< prev index next >