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
package zeroalloc; | |
import net.openhft.chronicle.map.ChronicleMap; | |
import net.openhft.chronicle.map.ChronicleMapBuilder; | |
import net.openhft.lang.values.IntValue; | |
import org.junit.Assert; | |
import org.junit.Test; | |
import java.io.File; | |
import java.io.IOException; |
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
package util; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
import java.util.Arrays; | |
import java.util.Comparator; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.stream.Collectors; |
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
package util; | |
/** | |
* Created by daniel on 16/04/15. | |
*/ | |
public class Interrupt { | |
public static void main(String[] args) { | |
Thread sleeperThread = new Thread(){ | |
public void run(){ | |
try { |
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 Task getNextTask(BlockingQueue<Task> queue){ | |
boolean interrupted = false; | |
try{ | |
while(true){ | |
try{ | |
return queue.take(); | |
}catch(InterruptedException e){ | |
interrupted = true; | |
//retry | |
} |
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
package util; | |
public class LatencyMeasureExample { | |
public static void main(String[] args) throws InterruptedException{ | |
//Below are a couple of examples | |
LatencyMeasure lm = new LatencyMeasure(1000000); | |
System.out.println("Thread.sleep() random"); | |
for (int i = 0; i < 100000; i++) { | |
lm.startMeasure(); |
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
package util; | |
import java.util.Arrays; | |
public class LatencyMeasure { | |
private long[] times; | |
private long time; | |
private int index=0; |
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
package util; | |
import java.util.Set; | |
public class Allocation { | |
static int iterations = 10_000_000; | |
public static void main(String[] args) { | |
new Thread(){ |
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
package util; | |
public class Allocation1 { | |
static int iterations = 10_000_000; | |
public static void main(String[] args) { | |
for (int i = 0; i <3 ; i++) { | |
testNoAllocations(); | |
testAllocations(); | |
} |
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
package util; | |
public class Allocation2 { | |
static int iterations = 10_000_000; | |
public static void main(String[] args) { | |
for (int i = 0; i <3 ; i++) { | |
testNoAllocations(); | |
testAllocations(); |
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
package util; | |
import java.io.*; | |
import java.util.zip.GZIPOutputStream; | |
public class LambdaExceptions { | |
public static void main(String[] args) { | |
try { | |
//Write with compression | |
writeToFile(new File("test"), "Hello World", GZIPOutputStream::new); |