Mercurial > hg > gc-bench
view src/main/java/org/openjdk/gcbench/runtime/cmp/ACmpBarriersKnownNulls.java @ 88:583fef4276f5
Update license and copyright headers.
author | shade |
---|---|
date | Wed, 22 Nov 2017 15:58:02 +0100 |
parents | f8496889e1ac |
children |
line wrap: on
line source
/* * Copyright (c) 2017, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.gcbench.runtime.cmp; import org.openjdk.jmh.annotations.*; import java.util.concurrent.TimeUnit; @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Threads(1) @State(Scope.Thread) public class ACmpBarriersKnownNulls { Object target; @Setup public void setup() { target = new Object(); } @Benchmark public void left() { doLeft(target); } @Benchmark public void right() { doRight(target); } @CompilerControl(CompilerControl.Mode.DONT_INLINE) private boolean doLeft(Object t1) { return t1 == null; } @CompilerControl(CompilerControl.Mode.DONT_INLINE) private boolean doRight(Object t2) { return null == t2; } /* i7 4790K, 4.0 Ghz, Linux x86_64, JDK 9 (Shenandoah, 2016-09-05) Benchmark Mode Cnt Score Error Units # Shenandoah ACmpBarriersKnownNulls.left avgt 5 2.235 ± 0.011 ns/op ACmpBarriersKnownNulls.right avgt 5 2.240 ± 0.089 ns/op # G1 ACmpBarriersKnownNulls.left avgt 5 1.971 ± 0.001 ns/op ACmpBarriersKnownNulls.right avgt 5 1.974 ± 0.021 ns/op # Parallel ACmpBarriersKnownNulls.left avgt 5 1.977 ± 0.026 ns/op ACmpBarriersKnownNulls.right avgt 5 1.973 ± 0.001 ns/op The difference is not caused by different compilation of doLeft/doRight methods, but rather the additional read barriers in the JMH loop itself. The generated code for doLeft/doRight in Shenandoah/G1/Parallel is the same: [Verified Entry Point] 11.16% 7.47% 0x00007f309d542240: mov %eax,-0x14000(%rsp) 0.15% 0.07% 0x00007f309d542247: push %rbp 0.22% 0.14% 0x00007f309d542248: sub $0x10,%rsp 11.05% 10.65% 0x00007f309d54224c: test %rdx,%rdx ╭ 0x00007f309d54224f: je 0x00007f309d54225f 0.10% 0.06% │ 0x00007f309d542251: xor %eax,%eax 0.11% 0.08% │ 0x00007f309d542253: add $0x10,%rsp 11.43% 11.21% │ 0x00007f309d542257: pop %rbp 0.07% 0.04% │ 0x00007f309d542258: test %eax,0x18026da2(%rip) 0.07% 0.01% │ 0x00007f309d54225e: retq */ }