This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PREFIX="12345" | |
tree=`git write-tree` | |
parent=`git rev-parse HEAD` | |
name=`git config user.name` | |
author=`git config user.name` | |
email=`git config user.email` | |
tzone=`date +%z` | |
declare -i msgIndex=-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'alias ls='sleep 2; ls;' >> ~/.bash_profile && source ~/.bash_profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Unoptimized | |
// list will not be garbage collected | |
// cumbersome instantiation | |
List<Integer> list = someList(); | |
Stats.addGauge("metric_name", new Function0<Object>() { | |
List<Integer> listRef = list; | |
@Override | |
public Double apply() { | |
return (double) listRef.size(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Unoptimized | |
// this performs a synchronized lookup for every increment | |
taskLoop { | |
String suffix = returnCounterType(); | |
Stats.incr("metric_name" + suffix); | |
} | |
// Optimized | |
// ThreadLocalStats does not have any locks. | |
ThreadLocalStats tls = Stats.makeThreadLocalStats(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Unoptimized | |
// this performs a synchronized lookup for every increment | |
void someHighQPSFunction() { | |
Stats.incr("metric_name"); | |
} | |
// Optimized | |
Counter someCounter = Stats.counter("metric_name"); | |
void someHighQPSFunction() { | |
someCounter.incr(); // saves one synchronized lookup per increment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// not preferred, but currently the most common in our code base | |
// this performs a synchronized lookup for every increment | |
// will be marked deprecated to discourage usage | |
Stats.incr("my_metric_name k1=v1"); | |
// preferred | |
Counter someCounter = Stats.counter("my_metric_name k1=v1"); | |
void someHighQPSFunction() { | |
someCounter.incr(); // saves one synchronized lookup per increment | |
} |