### Question:
FileIDFactory { public static String createFileID() { try { Thread.sleep(2); } catch (InterruptedException e1) { } int uniquePort = 0; byte[] addrBytes = null; ServerSocket serverSocket = null; try { StringBuffer buf = new StringBuffer(); serverSocket = ServerSocketFactory.getDefault().createServerSocket(); serverSocket.bind(null); uniquePort = serverSocket.getLocalPort(); addrBytes = InetAddress.getLocalHost().getAddress(); for (int i = 0; i < 4; i++) { int b = addrBytes[i] & 0xff; buf.append(Integer.toHexString(b)); } buf.append(Integer.toHexString(uniquePort)); buf.append(System.nanoTime()); return buf.toString(); } catch (IOException e) { } finally { if (serverSocket != null) { try { serverSocket.close(); } catch (IOException e) { } } } return Long.toHexString(System.nanoTime()); } private  FileIDFactory(); static String createFileID();  }### Answer:
@Test public void testCreateFileID() { long start = (new Date()).getTime(); HashSet<String> idSet = new HashSet<String>(); int count = 100; for (int i = 0; i < count; i++) { idSet.add(FileIDFactory.createFileID()); } assertEquals(count, idSet.size()); long end = (new Date()).getTime(); long t = (end - start) / count; System.out.println("FileIDFactoryTest.createFileID average time: " + t + " ms"); }