List of usage examples for org.apache.hadoop.hdfs DFSUtilClient bytes2String
public static String bytes2String(byte[] bytes)
From source file:TestDFSUtilClient.java
License:Apache License
@Test public void testBytes2String() { final long numLoop = 100000000; final byte[] bytes = "testBytes2String".getBytes(StandardCharsets.UTF_8); String str = null;//from ww w . j ava2 s. c om long start = Time.monotonicNow(); for (int i = 0; i < numLoop; i++) { str = DFSUtilClient.bytes2String(bytes); } long end = Time.monotonicNow(); System.out.println(str); System.out.println("Elapsed time: " + (end - start)); start = Time.monotonicNow(); for (int i = 0; i < numLoop; i++) { str = new String(bytes, StandardCharsets.UTF_8); } end = Time.monotonicNow(); System.out.println(str); System.out.println("Elapsed time: " + (end - start)); start = Time.monotonicNow(); for (int i = 0; i < numLoop; i++) { str = DFSUtilClient.bytes2String(bytes); } end = Time.monotonicNow(); System.out.println(str); System.out.println("Elapsed time: " + (end - start)); start = Time.monotonicNow(); for (int i = 0; i < numLoop; i++) { str = new String(bytes, StandardCharsets.UTF_8); } end = Time.monotonicNow(); System.out.println(str); System.out.println("Elapsed time: " + (end - start)); }