public class Main {
    public static void main(String[] args) {
        String s1 = null;
        String s2 = null;

        // equal 1 (standard)
        s1 = "1234567890123456789012345678901234567890";
        s2 = "1234567890123456789012345678901234567890";
        long start = System.currentTimeMillis();
        for (long i = 0; i < 10000000000L; i += 1) {
            boolean b = s1.equals(s2);
        }
        System.out.println("equal: " + (System.currentTimeMillis() - start) + " milis");

        // equal 2 (with length & hash check)
        s1 = "1234567890123456789012345678901234567891";
        s2 = "1234567890123456789012345678901234567891";
        start = System.currentTimeMillis();
        for (long i = 0; i < 10000000000L; i += 1) {
            boolean b = s1.length() == s2.length() && s1.hashCode() == s2.hashCode()
                    && s1.equals(s2);
        }
        System.out.println("equal: " + (System.currentTimeMillis() - start) + " milis");

        // equal 3 (with hash check)
        s1 = "1234567890123456789012345678901234567892";
        s2 = "1234567890123456789012345678901234567892";
        start = System.currentTimeMillis();
        for (long i = 0; i < 10000000000L; i += 1) {
            boolean b = s1.hashCode() == s2.hashCode() && s1.equals(s2);
        }
        System.out.println("equal: " + (System.currentTimeMillis() - start) + " milis");

        // equal 4 (with length check)
        s1 = "1234567890123456789012345678901234567893";
        s2 = "1234567890123456789012345678901234567893";
        start = System.currentTimeMillis();
        for (long i = 0; i < 10000000000L; i += 1) {
            boolean b = s1.length() == s2.length() && s1.equals(s2);
        }
        System.out.println("equal: " + (System.currentTimeMillis() - start) + " milis");
        System.out.println();

        // different 1 (standard)
        s1 = "1234567890123456789012345678901234567890";
        s2 = "1234567890123456789012345678901234567891";
        start = System.currentTimeMillis();
        for (long i = 0; i < 10000000000L; i += 1) {
            boolean b = s1.equals(s2);
        }
        System.out.println("different: " + (System.currentTimeMillis() - start) + " milis");

        // different 2 (with length & hash check)
        s1 = "1234567890123456789012345678901234567891";
        s2 = "1234567890123456789012345678901234567892";
        start = System.currentTimeMillis();
        for (long i = 0; i < 10000000000L; i += 1) {
            boolean b = s1.length() == s2.length() && s1.hashCode() == s2.hashCode()
                    && s1.equals(s2);
        }
        System.out.println("different: " + (System.currentTimeMillis() - start) + " milis");

        // different 3 (with hash check)
        s1 = "1234567890123456789012345678901234567892";
        s2 = "1234567890123456789012345678901234567893";
        start = System.currentTimeMillis();
        for (long i = 0; i < 10000000000L; i += 1) {
            boolean b = s1.hashCode() == s2.hashCode() && s1.equals(s2);
        }
        System.out.println("different: " + (System.currentTimeMillis() - start) + " milis");

        // different 4 (with length check)
        s1 = "1234567890123456789012345678901234567893";
        s2 = "1234567890123456789012345678901234567894";
        start = System.currentTimeMillis();
        for (long i = 0; i < 10000000000L; i += 1) {
            boolean b = s1.length() == s2.length() && s1.equals(s2);
        }
        System.out.println("different: " + (System.currentTimeMillis() - start) + " milis");
        System.out.println();

        // different size 1 (standard)
        s1 = "1234567890123456789012345678901234567890";
        s2 = "12345678901234567890123456789012345678901";
        start = System.currentTimeMillis();
        for (long i = 0; i < 10000000000L; i += 1) {
            boolean b = s1.equals(s2);
        }
        System.out.println("different size: " + (System.currentTimeMillis() - start) + " milis");

        // different size 2 (with length & hash check)
        s1 = "1234567890123456789012345678901234567891";
        s2 = "12345678901234567890123456789012345678912";
        start = System.currentTimeMillis();
        for (long i = 0; i < 10000000000L; i += 1) {
            boolean b = s1.length() == s2.length() && s1.hashCode() == s2.hashCode()
                    && s1.equals(s2);
        }
        System.out.println("different size: " + (System.currentTimeMillis() - start) + " milis");

        // different size 3 (with hash check)
        s1 = "1234567890123456789012345678901234567892";
        s2 = "12345678901234567890123456789012345678923";
        start = System.currentTimeMillis();
        for (long i = 0; i < 10000000000L; i += 1) {
            boolean b = s1.hashCode() == s2.hashCode() && s1.equals(s2);
        }
        System.out.println("different size: " + (System.currentTimeMillis() - start) + " milis");

        // different size 4 (with length check)
        s1 = "1234567890123456789012345678901234567893";
        s2 = "12345678901234567890123456789012345678934";
        start = System.currentTimeMillis();
        for (long i = 0; i < 10000000000L; i += 1) {
            boolean b = s1.length() == s2.length() && s1.equals(s2);
        }
        System.out.println("different size: " + (System.currentTimeMillis() - start) + " milis");
    }
}
