Skip to content

Instantly share code, notes, and snippets.

@doom369
Created August 2, 2020 12:05
Show Gist options
  • Save doom369/5b5dfaf226711c61c2dc3dcbb4eb790e to your computer and use it in GitHub Desktop.
Save doom369/5b5dfaf226711c61c2dc3dcbb4eb790e to your computer and use it in GitHub Desktop.
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Fork(1)
@State(Scope.Thread)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 10, time = 1)
public class Hashcode {
UserObjects userObjects;
UserIDEDefault userIDEDefault;
UserApacheCommons3 userApacheCommons3;
UserGuava userGuava;
UserLombok userLombok;
@Setup
public void setup() {
userObjects = new UserObjects("Dmytro", 35);
userIDEDefault = new UserIDEDefault("Dmytro", 35);
userApacheCommons3 = new UserApacheCommons3("Dmytro", 35);
userGuava = new UserGuava("Dmytro", 35);
userLombok = new UserLombok("Dmytro", 35);
}
@Benchmark
public int objectsHashcode() {
return userObjects.hashCode();
}
@Benchmark
public int defaultHashCode() {
return userIDEDefault.hashCode();
}
@Benchmark
public int apacheCommons() {
return userApacheCommons3.hashCode();
}
@Benchmark
public int guava() {
return userGuava.hashCode();
}
@Benchmark
public int lombok() {
return userLombok.hashCode();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment