Skip to content

Instantly share code, notes, and snippets.

@leogomes
leogomes / iterm2-solarized.md
Created April 23, 2018 16:56 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

# JMH 1.18 (released 51 days ago)
# VM version: JDK 1.8.0_131, VM 25.131-b11
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/bin/java
# VM options: -Dfile.encoding=UTF-8
# Warmup: 5 iterations, 5 s each
# Measurement: 5 iterations, 5 s each
# Timeout: 10 min per iteration
# Threads: 32 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: fr.rivieradev.jmh.MapConcurrency.concurrentMap
@leogomes
leogomes / .readme.md
Created November 4, 2016 16:18 — forked from jeanmarc/.readme.md
Reusable connections in Gatling tests

Introduction

Gist explaining a way to add long-living connections to Gatling and create scenarios that reuse the connection(s) to put load on the target system.

I have used the gatling-kafka plugin available on GitHub as inspiration.

Note that the code snippets provided here do not complile right out of the box. You will have to add some dependencies, and code yourself to make things work.

import java.util.*;
import java.io.*;
import java.math.*;
/**
* The machines are gaining ground. Time to show them what we're really made of...
**/
class Player {
public static void main(String args[]) {

Keybase proof

I hereby claim:

  • I am leogomes on github.
  • I am leogomes (https://keybase.io/leogomes) on keybase.
  • I have a public key whose fingerprint is 9B97 A010 A4AE 65A9 457A 5384 285A F9D1 5045 3311

To claim this, I am signing this object:

@leogomes
leogomes / PersonNetwork_Compiling.java
Created October 20, 2013 19:15
New version of generated CompiledNetwork that actually compiles :)
package org.drools.core.reteoo.compiled;
public class Compiledorg_drools_compiler_PersonNetwork extends
org.drools.core.reteoo.compiled.CompiledNetwork {
private org.drools.core.rule.constraint.MvelConstraint mvelConstraint15; // [AlphaNode(15)
// constraint=age
// ==
// 32]
private org.drools.core.rule.ContextEntry contextEntry15;
private org.drools.core.reteoo.LeftInputAdapterNode leftInputAdapterNode16; // [LeftInputAdapterNode(16)]
package org.drools.core.reteoo.compiled;
import java.util.Map;
import org.drools.core.common.InternalFactHandle;
import org.drools.core.common.InternalWorkingMemory;
import org.drools.core.reteoo.ModifyPreviousTuples;
import org.drools.core.spi.PropagationContext;
import org.drools.core.spi.RuleComponent;
import org.kie.api.definition.rule.Rule;
@leogomes
leogomes / InstantTemplate.tpl
Created July 26, 2013 07:19
Testing class changes
{macro main()}
<div {id "main"/} class="theme2">
<div {id "title"/} class="title">
<h1>Hello Instant Aria Templates</h1>
</div>
</div>
{@aria:SelectBox {
label: "New theme: ",
@leogomes
leogomes / gist:1317471
Created October 26, 2011 19:14
Tesseract initialization
-(void) startTesseract {
//Adapted from http://robertcarlsen.net/2009/12/06/ocr-on-iphone-demo-1043
NSString *dataPath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"tessdata"];
/*
Set up the data in the docs dir
want to copy the data to the documents folder if it doesn't already exist
*/
NSFileManager *fileManager = [NSFileManager defaultManager];
// If the expected store doesn't exist, copy the default store.