Использование superfastha sh in Java - PullRequest
0 голосов
/ 31 марта 2020

Я проверяю сравнение скорости между superfastha sh и алгоритмом хеширования по умолчанию, используемым в Java.

Но я не уверен, что я использую superfastha sh al go правильно, так как я не могу найти документацию о значении этих параметров.

Я получил java импл go здесь .

Это мой код:

public class Main
{

   static List<String> dataArray = new ArrayList<>();

   public static void main(String[] args) throws IOException
   {

      writeToArray();
      System.out.println("Finished writing to the array.");

      //hashing using default java
      long startTime = System.nanoTime();
      dataArray.stream()
               .forEach(s -> s.hashCode());
      long endTime = System.nanoTime();
      long duration = (endTime - startTime);  //divide by 1000000 to get milliseconds.
      System.out.println("Finished hashing the file using default java (nanoseconds): " + duration );

      //hashing using superfasthash algo
      startTime = System.nanoTime();
      dataArray.stream()
               .forEach(s -> {
                  SuperFastHash.calculate(s.getBytes(), 1, 1, 1);
               });
      endTime = System.nanoTime();
      duration = (endTime - startTime);  //divide by 1000000 to get milliseconds.
      System.out.println("Finished hashing superfasthash algo (nanoseconds): " + duration );
   }

   private static void writeToArray()
   {
      String abc = "abcdefghijklmnopqrstuvwxyz";
      String toHash;
      Random r = new Random();
      for (int i = 0; i <= 1000000; i++)
      {
         toHash = "";

         for (int ii = 0; ii < 10; ii++)
         {
            int low = 0;
            int high = 26;
            int result = r.nextInt(high - low) + low;
            toHash = toHash + abc.charAt(result);
         }

         dataArray.add(toHash);
         System.out.println("Writing index = " + i + ". String: " + toHash);
      }
   }
}

, но я не уверен, что писать в параметре при использовании функции вычисления из класса SuperFastHa sh.

...