Skip to content

Instantly share code, notes, and snippets.

package nanotime;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
/**
* Created by daniel on 28/10/2015.
*/
public class NanoTimer {
public static void main(String[] args) throws InterruptedException {
package nanotime;
public class NanoTimer {
public static void main(String[] args) throws InterruptedException {
long[] samples = new long[1_000_000];
for (int i = 0; i < samples.length; i++) {
long firstTime = System.nanoTime();
long timeForNano = System.nanoTime() - firstTime;
samples[i] = timeForNano;
package nanotime;
import java.util.Arrays;
/**
* Created by daniel on 28/10/2015.
*/
public class NanoTimer {
public static void main(String[] args) throws InterruptedException {
long[] samples = new long[100_000];
int pauseInMicros = 1;
package util;
import java.util.Random;
import java.util.stream.IntStream;
public class RandomString {
public static void main(String[] args) {
Random random = new Random();
IntStream.range(0,10).
forEach(i->System.out.println(generateRandomString(random, 9)));
@danielshaya
danielshaya / GCLogger.java
Last active March 16, 2018 08:15
Allocation free logging
package test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class GCLogger {
@danielshaya
danielshaya / FindSlowCode.java
Created February 11, 2015 13:46
Class to demonstrate the use of Monitor
package example;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Logger;
import java.util.stream.Stream;
/**
* Class to demonstrate the use of Monitor
*/
public class FindSlowCode {
@danielshaya
danielshaya / FixedCompTestBenchmark.java
Created February 3, 2015 14:43
CompTestBenchmark by Aleksey Shipilev
package comp;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
@danielshaya
danielshaya / CompTestBenchmark.java
Last active October 21, 2016 12:56
Comparing sorting implementations
package comp;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
package org.latency.quickfix;
import net.openhft.chronicle.core.Jvm;
import net.openhft.chronicle.core.jlbh.JLBHOptions;
import net.openhft.chronicle.core.jlbh.JLBHTask;
import net.openhft.chronicle.core.jlbh.JLBH;
import quickfix.*;
import quickfix.field.*;
import quickfix.fix42.ExecutionReport;
import quickfix.fix42.NewOrderSingle;
package org.latency.tcp;
import net.openhft.affinity.Affinity;
import net.openhft.chronicle.core.Jvm;
import net.openhft.chronicle.core.jlbh.JLBHOptions;
import net.openhft.chronicle.core.jlbh.JLBHTask;
import net.openhft.chronicle.core.jlbh.JLBH;
import net.openhft.chronicle.core.util.NanoSampler;
import java.io.EOFException;