Skip to content

Instantly share code, notes, and snippets.

private static final GenericObjectPoolConfig<Channel> GENERIC_OBJECT_POOL_CONFIG = new GenericObjectPoolConfig<>();
static {
// RabbitMQ has channel_max to 2047. https://github.com/rabbitmq/rabbitmq-java-client/issues/366
GENERIC_OBJECT_POOL_CONFIG.setMaxTotal(2_000);
GENERIC_OBJECT_POOL_CONFIG.setMinIdle(2);
GENERIC_OBJECT_POOL_CONFIG.setMaxIdle(10); // Reset long channel
GENERIC_OBJECT_POOL_CONFIG.setMaxWaitMillis(TimeUnit.MINUTES.toMillis(10)); // Avoid too long hung
GENERIC_OBJECT_POOL_CONFIG.setJmxEnabled(false);
}
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(3)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark)
public class ReplaceAllBench {
@Param({ "10", "100", "1000" })
private int size;
scala> val log = new ProcessLogger {
| val sb = new StringBuilder
| override def buffer[T](f: => T): T = f
| override def out(s: => String): Unit = sb.append(s)
| override def err(s: => String): Unit = sb.append(s)
| }
log: scala.sys.process.ProcessLogger{val sb: StringBuilder} = $anon$1@41385767
scala> ("yes -y 100" #| "head -c 1").!(log)
res3: Int = 0
00:02:34.309 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientConfigurationResultsBuilder] Flushing resolved configuration data in Binary store in /tmp/gradle6679032435100154231.bin. Wrote root :mockito:unspecified:classpath.
00:02:34.309 [DEBUG] [org.gradle.configuration.project.BuildScriptProcessor] Timing: Running the build script took 1.745 secs
00:02:34.310 [ERROR] [org.gradle.BuildExceptionReporter]
00:02:34.311 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
00:02:34.311 [ERROR] [org.gradle.BuildExceptionReporter]
00:02:34.311 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
00:02:34.312 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred configuring root project 'mockito'.
00:02:34.312 [ERROR] [org.gradle.BuildExceptionReporter] > Could not resolve all dependencies for configuration ':classpath'.
00:02:34.312 [ERROR] [org.gradle.BuildExceptionReporter] > Could not find any version that matches com
@twillouer
twillouer / ToArrayBench.java
Created November 15, 2014 20:41
Benchmarking of toArray
@State(Scope.Benchmark)
public class ToArrayBench {
ArrayList<Byte> list;
@Setup
public void setup() throws Throwable
{
list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
@twillouer
twillouer / KryoMarshaller.java
Created July 26, 2014 22:34
Kryo + Guava ImmutableList/ImmutableSet
public static final CollectionSerializer IMMUTABLE_SET_SERIALIZER = new CollectionSerializer() {
public Class elementClass;
public Serializer serializer;
public Class genericType;
@Override
public Collection read(Kryo kryo, Input input, Class<Collection> type)
{
@twillouer
twillouer / gist:73e1452ad59b1e7c55f4
Created May 22, 2014 12:35
Reduce GWT compile time
<properties>
<isDraftCompile>false</isDraftCompile>
</properties>
[...]
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>