- Create a new folder
- Create a build.gradle file
- Inside the build.gradle file, put the following:
buildscript {
repositories {
jcenter()
}
dependencies {
package com.danveloper.providers | |
import com.danveloper.support.ApplicationHolder as AH | |
import org.hibernate.SessionFactory as SF | |
public interface Provider<T> { | |
T get() | |
} | |
class Support { |
List.metaClass.collapse = {-> | |
def start,end | |
def reverse = delegate[0]?.getAt(0)-delegate[0]?.getAt(-1) > 0 | |
def expanded = delegate.flatten().unique().sort() | |
def result = (reverse ? expanded.reverse() : expanded).inject([]) { l, n -> | |
start = start == null ? n : start | |
end = end == null ? n : end | |
if ((reverse?n+1:n-1)==end) { | |
end = n |
public class Promises { | |
private static class PageMetrics { | |
Integer visits; | |
Long avgMsOnPage; | |
@Override | |
public String toString() { | |
return String.format("{ avgMsOnPage=%d, visits=%d }", avgMsOnPage, visits); | |
} |
public class TrampolineLambda { | |
interface TrampolineFunction<T, R> { | |
R apply(T...obj); | |
public default Object trampoline(T...objs) { | |
Object result = apply(objs); | |
if (!(result instanceof TrampolineFunction)) { | |
return result; | |
} else { | |
return this; |
buildscript {
repositories {
jcenter()
}
dependencies {
Ratpack "Hello World" on a t2.micro, Ubuntu 14.04, no extra server configuration.
~30,000 req/s
# ./wrk -t4 -c72 -d60s -R35000 http://localhost:5050
Running 1m test @ http://localhost:5050
4 threads and 72 connections
Thread calibration: mean lat.: 823.764ms, rate sampling interval: 3041ms
Thread calibration: mean lat.: 800.518ms, rate sampling interval: 2902ms
I hereby claim:
To claim this, I am signing this object:
package app | |
import com.fasterxml.jackson.databind.ObjectMapper | |
import com.fasterxml.jackson.databind.node.ObjectNode | |
import com.google.common.io.ByteSource | |
import com.google.common.io.Resources | |
import ratpack.config.ConfigSource | |
import ratpack.file.FileSystemBinding | |
import java.nio.file.Files |
import groovy.transform.Memoized | |
class FibBackoff { | |
int tryNum | |
void backoff() { | |
tryNum = fib(tryNum) | |
sleep(tryNum * 1000) | |
} |
# ./wrk -t72 -c3000 -d30s http://localhost:5050
Running 30s test @ http://localhost:5050
72 threads and 3000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 4.82ms 9.03ms 229.22ms 95.25%
Req/Sec 9.58k 3.52k 34.54k 70.33%