This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final class Unicorn | |
{ | |
private static int mainMethodLineOfLastPatInvocation = 0; | |
private static boolean pat() | |
{ | |
boolean result = false; | |
final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); | |
final StackTraceElement mainMethodInvocationPoint = stackTrace[3]; | |
if(mainMethodInvocationPoint.getLineNumber() != mainMethodLineOfLastPatInvocation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static final class Unicorn | |
{ | |
private static int mainMethodLineOfLastPatInvocation = 0; | |
private static boolean pat() | |
{ | |
boolean result = false; | |
final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); | |
final StackTraceElement mainMethodInvocationPoint = stackTrace[3]; | |
if(mainMethodInvocationPoint.getLineNumber() != mainMethodLineOfLastPatInvocation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final class Unicorn | |
{ | |
private static int mainMethodLineOfLastPatInvocation = 0; | |
private static boolean pat() | |
{ | |
boolean result = false; | |
final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); | |
final StackTraceElement mainMethodInvocationPoint = stackTrace[3]; | |
if(mainMethodInvocationPoint.getLineNumber() != mainMethodLineOfLastPatInvocation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BigDecimalBenchmark extends SimpleBenchmark | |
{ | |
private static final BigDecimal QUANTITY_DIVISOR = new BigDecimal(100); | |
private static final BigDecimal PRICE_DIVISOR = new BigDecimal(1000000); | |
private static final BigDecimal QUANTITY_INCREMENT = new BigDecimal("0.001"); | |
private static final BigDecimal PRICE_INCREMENT = new BigDecimal("0.00001"); | |
@Override | |
protected void setUp() throws Exception | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static java.lang.Integer.bitCount; | |
final class IntervalCalculator | |
{ | |
private final int lengthAsPowerOfTwo; | |
private final int mask; | |
private int lastIntervalSize; | |
private int currentIntervalSize; | |
private int pointer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void writeMessage(final long sequence, final byte[] data, final int length) throws IOException | |
{ | |
final long startTime = System.nanoTime(); | |
delegate.writeMessage(sequence, data, length); | |
valueRecorder.recordValue(System.nanoTime() - startTime); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
From http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/io/RandomAccessFile.java#l521 | |
*/ | |
public void seek(long pos) throws IOException { | |
if (pos < 0) { | |
throw new IOException("Negative seek offset"); | |
} else { | |
seek0(pos); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
From http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/native/java/io/RandomAccessFile.c#l126 | |
*/ | |
Java_java_io_RandomAccessFile_seek0(JNIEnv *env, | |
jobject this, jlong pos) { | |
FD fd; | |
fd = GET_FD(this, raf_fd); | |
if (fd == -1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
From http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/solaris/native/java/io/io_util_md.h#l76 | |
*/ | |
#ifdef _ALLBSD_SOURCE | |
#define open64 open | |
#define fstat64 fstat | |
#define stat64 stat | |
#define lseek64 lseek | |
#define ftruncate64 ftruncate | |
#define IO_Lseek lseek |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
From http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/io/RandomAccessFile.java#l492 | |
*/ | |
public void write(byte b[], int off, int len) throws IOException { | |
writeBytes(b, off, len); | |
} | |
// ... | |
/* |
OlderNewer