<commit_before>package au.com.acegi.hashbench;

import java.nio.ByteBuffer;
import java.security.SecureRandom;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;

import au.com.acegi.hashbench.hashers.AdlerHasher;
import au.com.acegi.hashbench.hashers.CRC32Hasher;
import au.com.acegi.hashbench.hashers.GuavaHasher;
import au.com.acegi.hashbench.hashers.Hasher;
import au.com.acegi.hashbench.hashers.JacksumHasher;
import au.com.acegi.hashbench.hashers.Jp32Hasher;
import au.com.acegi.hashbench.hashers.Jp64Hasher;
import au.com.acegi.hashbench.hashers.SipFwdHasher;
import au.com.acegi.hashbench.hashers.SipInlineHasher;
import au.com.acegi.hashbench.hashers.ZeroAllocHasher;

@State(Scope.Thread)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Fork(2)
@Warmup(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS)
@BenchmarkMode(Mode.AverageTime)
public class HashBench {
  private static final int BUFFER_SIZE = 65536;
  private static final Map<String, Hasher> HASHERS = new HashMap<String, Hasher>();
  private static final int OFFSET;
  private static final Random RND = new SecureRandom();

  static {
    OFFSET = HashBench.RND.nextInt(32000);
    AdlerHasher.register(HashBench.HASHERS);
    CRC32Hasher.register(HashBench.HASHERS);
    GuavaHasher.register(HashBench.HASHERS);
    JacksumHasher.register(HashBench.HASHERS);
    Jp32Hasher.register(HashBench.HASHERS);
    Jp64Hasher.register(HashBench.HASHERS);
    SipFwdHasher.register(HashBench.HASHERS);
    SipInlineHasher.register(HashBench.HASHERS);
    ZeroAllocHasher.register(HashBench.HASHERS);
    for (final String key : HashBench.HASHERS.keySet()) {
      if (key.contains("_")) {
        throw new IllegalStateException(key);
      }
    }
  }

  @Param({
          AdlerHasher.ADLER_32,
          CRC32Hasher.CRC_32,
          GuavaHasher.ADLER32,
          GuavaHasher.CRC32_DELEGATING,
          GuavaHasher.CRC32_RFC,
          GuavaHasher.GOOD_FAST_HASH_32,
          GuavaHasher.GOOD_FAST_HASH_64,
          GuavaHasher.MD5,
          GuavaHasher.MURMUR_3_32,
          GuavaHasher.MURMUR_3_128,
          GuavaHasher.SHA1,
          GuavaHasher.SHA256,
          GuavaHasher.SHA384,
          GuavaHasher.SHA512,
          GuavaHasher.SIP,
          JacksumHasher.HAS160,
          JacksumHasher.HAVAL128H3,
          JacksumHasher.HAVAL128H4,
          JacksumHasher.HAVAL128H5,
          JacksumHasher.HAVAL160H3,
          JacksumHasher.HAVAL160H4,
          JacksumHasher.HAVAL160H5,
          JacksumHasher.HAVAL192H3,
          JacksumHasher.HAVAL192H4,
          JacksumHasher.HAVAL192H5,
          JacksumHasher.HAVAL224H3,<commit_msg>Add more algos from Jacksum.<commit_after>package au.com.acegi.hashbench;

import java.nio.ByteBuffer;
import java.security.SecureRandom;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;

import au.com.acegi.hashbench.hashers.AdlerHasher;
import au.com.acegi.hashbench.hashers.CRC32Hasher;
import au.com.acegi.hashbench.hashers.GuavaHasher;
import au.com.acegi.hashbench.hashers.Hasher;
import au.com.acegi.hashbench.hashers.JacksumHasher;
import au.com.acegi.hashbench.hashers.Jp32Hasher;
import au.com.acegi.hashbench.hashers.Jp64Hasher;
import au.com.acegi.hashbench.hashers.SipFwdHasher;
import au.com.acegi.hashbench.hashers.SipInlineHasher;
import au.com.acegi.hashbench.hashers.ZeroAllocHasher;

@State(Scope.Thread)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Fork(2)
@Warmup(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS)
@BenchmarkMode(Mode.AverageTime)
public class HashBench {
  private static final int BUFFER_SIZE = 65536;
  private static final Map<String, Hasher> HASHERS = new HashMap<String, Hasher>();
  private static final int OFFSET;
  private static final Random RND = new SecureRandom();

  static {
    OFFSET = HashBench.RND.nextInt(32000);
    AdlerHasher.register(HashBench.HASHERS);
    CRC32Hasher.register(HashBench.HASHERS);
    GuavaHasher.register(HashBench.HASHERS);
    JacksumHasher.register(HashBench.HASHERS);
    Jp32Hasher.register(HashBench.HASHERS);
    Jp64Hasher.register(HashBench.HASHERS);
    SipFwdHasher.register(HashBench.HASHERS);
    SipInlineHasher.register(HashBench.HASHERS);
    ZeroAllocHasher.register(HashBench.HASHERS);
    for (final String key : HashBench.HASHERS.keySet()) {
      if (key.contains("_")) {
        throw new IllegalStateException(key);
      }
    }
  }

  @Param({
          AdlerHasher.ADLER_32,
          CRC32Hasher.CRC_32,
          GuavaHasher.ADLER32,
          GuavaHasher.CRC32_DELEGATING,
          GuavaHasher.CRC32_RFC,
          GuavaHasher.GOOD_FAST_HASH_32,
          GuavaHasher.GOOD_FAST_HASH_64,
          GuavaHasher.MD5,
          GuavaHasher.MURMUR_3_32,
          GuavaHasher.MURMUR_3_128,
          GuavaHasher.SHA1,
          GuavaHasher.SHA256,
          GuavaHasher.SHA384,
          GuavaHasher.SHA512,
          GuavaHasher.SIP,
          JacksumHasher.ADLER32_ALT,
          JacksumHasher.ADLER32_DELEGATING,
          JacksumHasher.CKSUM,
          JacksumHasher.CRC16,
          JacksumHasher.CRC24,
          JacksumHasher.CRC32_BZIP2,
          JacksumHasher.CRC32_DELEGATING,
          JacksumHasher.CRC32_FCS_32,
          JacksumHasher.CRC32_MPEG2,
          JacksumHasher.CRC64,
          JacksumHasher.CRC8,
          JacksumHasher.ED2K,
          JacksumHasher.ELF,
          JacksumHasher.FCS16,
          JacksumHasher.GOST,
          JacksumHasher.HAS160,
          JacksumHasher.HAVAL128H3,
          JacksumHasher.HAVAL128H4,
          JacksumHasher.HAVAL128H5,
          JacksumHasher.HAVAL160H3,
          JacksumHasher.HAVAL160H4,
          JacksumHasher.HAVAL160H5,
          JacksumHasher.HAVAL192H3,
          JacksumHasher.HAVAL192H4,
          JacksumHasher.HAVAL192H5,
          JacksumHasher.HAVAL224H3,
{'fraction_non_alphanumeric': 0.09649618536309693, 'fraction_numerical': 0.033060186493359706, 'mean_word_length': 3.543645699614891, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2007995', 'n_tokens_mistral': 2762, 'n_tokens_neox': 2604, 'n_words': 324}