Пример #1
0
  public static void testOneRandomPathConsume(String dirPath) {
    for (int i = 0; i < 31366; i++) {
      String str = "" + i;
      long start = System.currentTimeMillis();
      String tmpDir = MathUtils.hashKeyForDisk(str);
      String firstDir = tmpDir.substring(0, 2);
      File file = new File(dirPath + "/" + firstDir);
      if (file.exists()) {
        long spend = System.currentTimeMillis() - start;
        Log.v("spend", "find file i " + i + " spend " + spend);
      } else {
        long spend = System.currentTimeMillis() - start;
        Log.v("cyz", "spend not " + spend + " " + i);
        break;
      }
    }

    Log.v("cyz", "finish test OneRandomPathConsume");
  }
Пример #2
0
 /**
  * ********************************************************************* 一级散列
  *
  * @param dirPath
  */
 public static void testOneRandomPathCreateFile(String dirPath) {
   for (int i = 0; i < 31366; i++) {
     String str = "" + i;
     String tmpDir = MathUtils.hashKeyForDisk(str);
     String firstDir = tmpDir.substring(0, 2);
     File file = new File(dirPath + "/" + firstDir);
     try {
       if (!file.exists()) {
         file.mkdirs();
       }
       File file1 = new File(file.getPath() + "/" + str);
       file1.createNewFile();
     } catch (IOException e) {
       e.printStackTrace();
       Log.v("cyz", "e = " + e.getMessage() + " filename " + str + " i " + i);
     }
   }
   Log.v("cyz", "create 31366 files");
 }