Search in sources :

Example 6 with FSTStructAllocator

use of org.nustaq.offheap.structs.FSTStructAllocator in project fast-cast by RuedigerMoeller.

the class Protocol method main.

public static void main(String[] s) {
    initStructFactory();
    PriceUpdateStruct template = new PriceUpdateStruct();
    FSTStructAllocator onHeapAlloc = new FSTStructAllocator(0);
    // speed up instantiation by moving template also off heap
    template = onHeapAlloc.newStruct(template);
    // demonstrates that theoretical send rate is >20 millions messages per second on
    // an I7 box
    byte[] networkBuffer = new byte[template.getByteSize()];
    PriceUpdateStruct msg = onHeapAlloc.newStruct(template);
    int sizeOf = msg.getByteSize();
    while (true) {
        do20Millions(networkBuffer, msg, sizeOf);
    }
// System.out.println(msg);
// System.out.println("size:" + msg.getByteSize());
}
Also used : FSTStructAllocator(org.nustaq.offheap.structs.FSTStructAllocator)

Aggregations

FSTStructAllocator (org.nustaq.offheap.structs.FSTStructAllocator)6 FCPublisher (org.nustaq.fastcast.api.FCPublisher)4 RateMeasure (org.nustaq.fastcast.util.RateMeasure)3 Bytez (org.nustaq.offheap.bytez.Bytez)3 Executor (java.util.concurrent.Executor)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 Histogram (org.HdrHistogram.Histogram)2 FCSubscriber (org.nustaq.fastcast.api.FCSubscriber)2 FastCast (org.nustaq.fastcast.api.FastCast)2 PublisherConf (org.nustaq.fastcast.config.PublisherConf)2 Sleeper (org.nustaq.fastcast.util.Sleeper)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 FSTStruct (org.nustaq.offheap.structs.FSTStruct)1