Skip to content

Instantly share code, notes, and snippets.

@epickrram
epickrram / framework-server-perf-flames.svg
Created March 10, 2017 08:12
framework-server-perf-flames.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.LockSupport;
import java.util.concurrent.locks.ReentrantLock;
public final class SynchronisationThroughputTest
import net.bytebuddy.agent.ByteBuddyAgent;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.method.MethodList;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.dynamic.scaffold.InstrumentedType;
import net.bytebuddy.implementation.Implementation;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.implementation.bind.annotation.Origin;
/**
* Callback for UDP-specific statistics in /proc/net/snmp.
*/
@FunctionalInterface
public interface SnmpUdpStatisticsHandler
{
/**
* Callback method.
* @param inErrors InErrors count
* @param receiveBufferErrors RecvbufErrors count
/**
* Callback for statistics from /proc/net/softnet_stat.
*/
@FunctionalInterface
public interface SoftnetStatsHandler
{
/**
* Callback method.
* @param cpuId zero-based CPU that these statistics refer to
* @param processed softIRQ events processed
udpSocketMonitor.beginMonitoringOf(InetAddress.getByName("239.193.50.102"));
/**
* Handler for socket statistics from /proc/net/udp.
*/
@FunctionalInterface
public interface UdpSocketStatisticsHandler
{
/**
* Callback method.
* @param inetAddress the ip address
* @param port the socket port
@epickrram
epickrram / ExampleLogic.java
Created January 27, 2016 11:55
Example for a blog post
public void performMatching(final Order order) {
transactionReporter.startOfTransaction()
order.executeAggressively(orderBook);
tradeReporter.reportTrades(order.getTrades());
engine.updateAggregateOrderStatistics();
transactionReporter.endOfTransaction();
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
{
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)