fastest (low latency) method for Inter Process Communication between Java and C/C++

Just tested latency from Java on my Corei5 2.8GHz, only single byte send/received, 2 Java processes just spawned, without assigning specific CPU cores with taskset: TCP – 25 microseconds Named pipes – 15 microseconds Now explicitly specifying core masks, like taskset 1 java Srv or taskset 2 java Cli: TCP, same cores: 30 microseconds TCP, … Read more

Python – How to check list monotonicity

It’s better to avoid ambiguous terms like “increasing” or “decreasing” as it’s not clear if equality is acceptable or not. You should always use either for example “non-increasing” (clearly equality is accepted) or “strictly decreasing” (clearly equality is NOT accepted). def strictly_increasing(L): return all(x<y for x, y in zip(L, L[1:])) def strictly_decreasing(L): return all(x>y for … Read more

Is it better to reuse a StringBuilder in a loop?

The second one is about 25% faster in my mini-benchmark. public class ScratchPad { static String a; public static void main( String[] args ) throws Exception { long time = System.currentTimeMillis(); for( int i = 0; i < 10000000; i++ ) { StringBuilder sb = new StringBuilder(); sb.append( “someString” ); sb.append( “someString2″+i ); sb.append( “someStrin4g”+i … Read more