Skip to content

Instantly share code, notes, and snippets.

View mtopolnik's full-sized avatar

Marko Topolnik mtopolnik

View GitHub Profile
package testing;
import com.hazelcast.jet.Jet;
import com.hazelcast.jet.JetInstance;
import com.hazelcast.jet.accumulator.LongLongAccumulator;
import com.hazelcast.jet.aggregate.AggregateOperation;
import com.hazelcast.jet.datamodel.KeyedWindowResult;
import com.hazelcast.jet.pipeline.Pipeline;
import com.hazelcast.jet.pipeline.Sinks;
import com.hazelcast.jet.pipeline.SourceBuilder;
@mtopolnik
mtopolnik / NativeLZ4BlockInputStream.java
Last active August 29, 2015 14:24
Native LZ4 input stream
import net.jpountz.lz4.LZ4Factory;
import net.jpountz.lz4.LZ4Exception;
import net.jpountz.lz4.LZ4FastDecompressor;
import net.jpountz.xxhash.XXHash32;
import net.jpountz.xxhash.XXHashFactory;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
@mtopolnik
mtopolnik / gist:8bf825ecf84279cb9b09
Created June 3, 2015 10:12
CpuConsumer (helper in JUnit testing that creates background CPU load)
private static final CpuConsumer cpuConsumer = new CpuConsumer();
@BeforeClass
public static void prepareCpuConsumer() {
cpuConsumer.getReady();
}
private static class CpuConsumer {
final int taskCount = 2 * Runtime.getRuntime().availableProcessors();
volatile CountDownLatch workerLatch = new CountDownLatch(1);
@mtopolnik
mtopolnik / gist:465ad156c68816ea5c91
Created February 3, 2015 09:38
Benchmark division vs. right shift
package org.sample;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
package org.sample;
import static java.util.Arrays.setAll;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
@mtopolnik
mtopolnik / websocket.clj
Created November 5, 2012 20:57
Aleph websocket test to demonstrate problem with closing server-side channel
(ns aleph.test.websocket
(:use
[clojure.test]
[lamina core connections]
[aleph.http]
[aleph.test.utils]))
(defmacro with-server [server & body]
`(let [kill-fn# ~server]
(try