Browse Source

Merge pull request #796 from markkolich/curacao

New benchmark: Curacao
jlucier-techempower 11 years ago
parent
commit
3afffa4509

+ 7 - 0
curacao/.gitignore

@@ -0,0 +1,7 @@
+/project/.*
+/project/target
+/target
+/.project
+/.classpath
+/.cache
+/dist

+ 24 - 0
curacao/README.md

@@ -0,0 +1,24 @@
+# Curacao Benchmarking Test
+
+This is the Curacao portion of TechEmpower's [benchmarking test suite](../) comparing a variety of web development platforms.
+
+## Versions
+
+Curacao 2.0-M10 https://github.com/markkolich/curacao
+
+## Tests
+
+### JSON Serialization
+
+Uses [Google's GSON](https://code.google.com/p/google-gson/) under-the-hood.
+
+See the `json` method in [Benchmarks.java](src/main/java/benchmark/Benchmarks.java)
+
+    http://localhost:8080/json
+
+### Plaintext
+
+See the `plainText` method in [Benchmarks.java](src/main/java/benchmark/Benchmarks.java)
+
+    http://localhost:8080/plaintext
+

+ 0 - 0
curacao/__init__.py


+ 24 - 0
curacao/benchmark_config

@@ -0,0 +1,24 @@
+{
+  "framework" : "curacao",
+  "tests" : [{
+    "default" : {
+      "setup_file" : "setup",
+      "json_url" : "/json",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "None",
+      "framework": "curacao",
+      "language": "Java",
+      "orm": "Raw",
+      "platform": "Curacao",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "Curacao",
+      "notes": "",
+      "versus": ""
+    }
+  }]
+}

+ 35 - 0
curacao/build.sbt

@@ -0,0 +1,35 @@
+import AssemblyKeys._
+
+name := "curacao-benchmark"
+
+organization := "com.kolich"
+
+scalaVersion := "2.10.3"
+
+version := "1.0"
+
+resolvers ++= Seq(
+  "markkolich.github.io repo" at "http://markkolich.github.io/repo"
+)
+
+libraryDependencies ++= Seq(
+  "com.kolich.curacao" % "curacao" % "2.6.2" % "compile",
+  "com.kolich.curacao" % "curacao-gson" % "2.6.2" % "compile",
+  "org.eclipse.jetty" % "jetty-webapp" % "9.2.0.v20140526" % "compile",
+  "javax.servlet" % "javax.servlet-api" % "3.0.1" % "provided",
+  "org.slf4j" % "slf4j-api" % "1.7.2" % "compile",
+  "ch.qos.logback" % "logback-core" % "1.0.7" % "compile",
+  "ch.qos.logback" % "logback-classic" % "1.0.7" % "compile"
+)
+
+classDirectory in Compile <<= baseDirectory(new File(_, "target/classes"))
+
+sbtassembly.Plugin.assemblySettings
+
+mainClass in assembly := Some("benchmark.Bootstrap")
+
+outputPath in assembly := file("dist/curacao-standalone.jar")
+
+assemblyOption in assembly ~= { _.copy(includeScala = false) }
+
+test in assembly := {}

+ 1 - 0
curacao/project/build.properties

@@ -0,0 +1 @@
+sbt.version=0.13.2

+ 3 - 0
curacao/project/plugins.sbt

@@ -0,0 +1,3 @@
+addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
+
+addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")

+ 35 - 0
curacao/setup.py

@@ -0,0 +1,35 @@
+
+import subprocess
+import sys
+import time
+import os
+
+def start(args, logfile, errfile):
+  if os.name == 'nt':
+    subprocess.check_call('"..\\sbt\\sbt.bat" assembly', shell=True, cwd="curacao", stderr=errfile, stdout=logfile)
+  else:
+    subprocess.check_call("../sbt/sbt assembly", shell=True, cwd="curacao", stderr=errfile, stdout=logfile)
+
+  subprocess.Popen("java -jar dist/curacao-standalone.jar", shell=True, cwd="curacao", stderr=errfile, stdout=logfile)
+   
+  time.sleep(5)
+  return 0
+
+def stop(logfile, errfile):
+  if os.name == 'nt':
+    subprocess.check_call("wmic process where \"CommandLine LIKE '%curacao-standalone%'\" call terminate", stderr=errfile, stdout=logfile)
+  else:
+    p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+    out, err = p.communicate()
+    for line in out.splitlines():
+      if 'curacao-standalone' in line:
+        try:
+          pid = int(line.split(None, 2)[1])
+          os.kill(pid, 15)
+        except OSError:
+          pass
+  
+  return 0
+
+##start([], open('log.out','a'), open('error.out','a'))
+##stop(open('log.out','a'), open('error.out','a'))

+ 5 - 0
curacao/source_code

@@ -0,0 +1,5 @@
+./curacao/src/main/java/benchmark
+./curacao/src/main/java/benchmark/Bootstrap.java
+./curacao/src/main/java/benchmark/Benchmarks.java
+./curacao/src/main/java/benchmark/entities
+./curacao/src/main/java/benchmark/entities/HelloWorld.java

+ 21 - 0
curacao/src/main/java/benchmark/Benchmarks.java

@@ -0,0 +1,21 @@
+package benchmark;
+
+import benchmark.entities.HelloWorld;
+import com.kolich.curacao.annotations.Controller;
+import com.kolich.curacao.annotations.methods.RequestMapping;
+import com.kolich.curacao.handlers.requests.matchers.AntPathMatcher;
+
+@Controller
+public final class Benchmarks {
+
+    @RequestMapping(value="/json", matcher=AntPathMatcher.class)
+    public final HelloWorld json() {
+        return new HelloWorld("Hello, World!");
+    }
+
+    @RequestMapping(value="/plaintext", matcher=AntPathMatcher.class)
+    public final String plainText() {
+        return "Hello, World!";
+    }
+
+}

+ 52 - 0
curacao/src/main/java/benchmark/Bootstrap.java

@@ -0,0 +1,52 @@
+package benchmark;
+
+import com.kolich.curacao.CuracaoContextListener;
+import com.kolich.curacao.CuracaoDispatcherServlet;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public final class Bootstrap {
+
+    private static final int DEFAULT_SERVER_LISTEN_PORT = 8080;
+
+    public static void main(final String[] args) throws Exception {
+
+        final File workingDir = getWorkingDir();
+
+        int port;
+        try {
+            port = Integer.parseInt(args[0]);
+        } catch (Exception e) {
+            port = DEFAULT_SERVER_LISTEN_PORT;
+        }
+
+        final Server server = new Server(port);
+
+        final ServletHolder holder = new ServletHolder(CuracaoDispatcherServlet.class);
+        holder.setAsyncSupported(true); // Async supported = true
+        holder.setInitOrder(1); // Load on startup = true
+
+        final WebAppContext context = new WebAppContext();
+        context.addEventListener(new CuracaoContextListener()); // Required
+        context.setContextPath("/");
+        context.setResourceBase(workingDir.getAbsolutePath());
+        context.addServlet(holder, "/*");
+
+        server.setHandler(context);
+
+        server.start();
+        server.join();
+
+    }
+
+    private static final File getWorkingDir() {
+        final Path currentRelativePath = Paths.get("");
+        return currentRelativePath.toAbsolutePath().toFile();
+    }
+
+}

+ 21 - 0
curacao/src/main/java/benchmark/entities/HelloWorld.java

@@ -0,0 +1,21 @@
+package benchmark.entities;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.annotations.SerializedName;
+import com.kolich.curacao.gson.GsonAppendableCuracaoEntity;
+
+public final class HelloWorld extends GsonAppendableCuracaoEntity {
+
+    private static final Gson gson__ =
+        new GsonBuilder().serializeNulls().create();
+
+    @SerializedName("message")
+    private final String message_;
+
+    public HelloWorld(final String message) {
+        super(gson__);
+        message_ = message;
+    }
+
+}

+ 12 - 0
curacao/src/main/resources/application.conf

@@ -0,0 +1,12 @@
+curacao {
+
+  boot-package = "benchmark"
+
+  ## Never timeout.
+  async-context-timeout = 0
+
+  ## Both the request and response thread pools are "unbounded" intentionally.
+  pools.request.size = 0
+  pools.response.size = 0
+
+}

+ 23 - 0
curacao/src/main/resources/logback.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <target>System.out</target>
+        <encoder>
+            <pattern>%date{MM/dd HH:mm:ss.SSS} %-5level[%.15thread] %logger{1} - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <logger name="org.reflections" additivity="false" level="WARN">
+        <appender-ref ref="CONSOLE"/>
+    </logger>
+
+    <logger name="com.kolich.curacao" additivity="false" level="ERROR">
+        <appender-ref ref="CONSOLE"/>
+    </logger>
+
+    <root level="INFO">
+        <appender-ref ref="CONSOLE"/>
+    </root>
+
+</configuration>

BIN
sbt/sbt-launch.jar