Skip to content

Instantly share code, notes, and snippets.

View tylertreat-wf's full-sized avatar

Tyler Treat tylertreat-wf

View GitHub Profile
@tylertreat-wf
tylertreat-wf / main.go
Created September 20, 2014 00:26
vessel
package main
import (
"time"
"github.com/tylertreat-wf/vessel/vessel"
)
func main() {
vessel := vessel.NewSockJSVessel("/vessel")
@tylertreat-wf
tylertreat-wf / bower.json
Created September 20, 2014 00:28
vessel.js
{
"name": "w-message-client",
"version": "0.0.1",
"dependencies": {
"sockjs-client": "~0.3.4",
"requirejs": "~2.1.15"
}
}
package goplus
import (
"fmt"
"math/rand"
"net/http"
"strconv"
"github.com/Workiva/go-rest/rest"
)
func BenchmarkInsertMulti(b *testing.B) {
ctrie := New(nil)
b.ResetTimer()
for i := 0; i < b.N; i++ {
for j := 0; j < 1000000; j++ {
ctrie.Insert([]byte(strconv.Itoa(j)), 0)
}
}
}
public class Main {
public static void main(String[] args) throws Exception {
ConnectionFactory cf = new ConnectionFactory(Constants.DEFAULT_URL);
final Connection conn = cf.createConnection();
conn.subscribe("foo", new MessageHandler() {
@Override
public void onMessage(Message message) {
conn.publish("bar", "hello".getBytes());
}
@tylertreat-wf
tylertreat-wf / ThreadPoolTest.java
Created November 28, 2016 16:46
thread pool test
import java.util.concurrent.*;
public class ThreadPoolTest {
public static void main(String[] args) {
BlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(64);
ExecutorService threadPool = new LoggingThreadPoolExecutor(1, 10, 30, TimeUnit.SECONDS, queue);
for (int i = 0; i < 1000; i++) {
threadPool.submit(() -> {
import java.util.concurrent.*;
public class ThreadPoolTest {
public static void main(String[] args) {
BlockingQueue<Runnable> queue = new SynchronousQueue<>();
ExecutorService threadPool = new LoggingThreadPoolExecutor(1, 10, 30, TimeUnit.SECONDS, queue, new BlockingRejectedExecutionHandler());
for (int i = 0; i < 1000; i++) {
threadPool.submit(() -> {