Keith Newman 9 лет назад
Родитель
Сommit
fecd7693f5

+ 0 - 7
frameworks/Scala/plain/.gitignore

@@ -1,7 +0,0 @@
-/project/.*
-/project/target
-/target
-/web-apps/servlet/
-/.project
-/.classpath
-/.cache

+ 0 - 74
frameworks/Scala/plain/benchmark_config.json

@@ -1,74 +0,0 @@
-{
-  "framework": "plain",
-  "tests": [{
-    "default": {
-      "setup_file": "setup",
-      "json_url": "/json",
-      "plaintext_url": "/plaintext",
-      "db_url": "/db",
-      "query_url": "/db?queries=",
-      "update_url": "/update?queries=",
-      "fortune_url": "/fortunes",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "MySQL",
-      "framework": "plain",
-      "language": "Scala",
-      "orm": "Micro",
-      "platform": "Plain",
-      "webserver": "None",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "plain-linux",
-      "notes": "",
-      "versus": ""
-    },
-    "linux-servlet": {
-      "setup_file": "setup",
-      "json_url": "/web-apps/servlet/json",
-      "plaintext_url": "/web-apps/servlet/plaintext",
-      "db_url": "/web-apps/servlet/db",
-      "query_url": "/web-apps/servlet/db?queries=",
-      "update_url": "/web-apps/servlet/update?queries=",
-      "fortune_url": "/web-apps/servlet/fortunes",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "MySQL",
-      "framework": "plain",
-      "language": "Scala",
-      "orm": "Full",
-      "platform": "Plain",
-      "webserver": "None",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "plain-servlet-linux",
-      "notes": "",
-      "versus": ""
-    },
-    "win": {
-      "setup_file": "setup",
-      "json_url": "/json",
-      "plaintext_url": "/plaintext",
-      "db_url": "/db",
-      "query_url": "/db?queries=",
-      "update_url": "/update?queries=",
-      "fortune_url": "/fortunes",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "MySQL",
-      "framework": "plain",
-      "language": "Scala",
-      "orm": "Full",
-      "platform": "Plain",
-      "webserver": "None",
-      "os": "Windows",
-      "database_os": "Linux",
-      "display_name": "plain-windows",
-      "notes": "",
-      "versus": ""
-    }
-  }]
-}

+ 0 - 58
frameworks/Scala/plain/build.sbt

@@ -1,58 +0,0 @@
-import sbt._
-import Keys._
-import spray.revolver.RevolverPlugin
-import sbtassembly.AssemblyPlugin._
-
-name := "plain-benchmark"
-
-organization := "com.ibm"
-
-scalaVersion := "2.11.7"
-
-version := "1.0.1"
-
-test in Compile := {}
-
-mainClass in Compile := Some("com.ibm.plain.bootstrap.Main")
-
-scalacOptions in Compile ++= Seq(
-	"-g:vars",
-	"-encoding", "UTF-8", 
-	"-target:jvm-1.8", 
-	"-deprecation", 
-	"-feature", 
-	"-optimise"
-)
-
-libraryDependencies ++= Seq(
-  "org.scala-lang" % "scala-reflect" % "2.10.3",
-  "org.reflections" % "reflections" % "0.9.8",
-  "com.typesafe" % "config" % "1.0.2",
-  "ch.qos.logback" % "logback-classic" % "1.0.13",
-  "org.codehaus.janino" % "janino" % "2.6.1",
-  "com.typesafe.akka" %% "akka-actor" % "2.4.1",
-  "com.typesafe.akka" %% "akka-slf4j" % "2.4.1",
-  "org.apache.commons" % "commons-lang3" % "3.1",
-  "org.apache.commons" % "commons-compress" % "1.5",
-  "commons-io" % "commons-io" % "2.4",
-  "commons-net" % "commons-net" % "3.3",
-  "commons-codec" % "commons-codec" % "1.8",
-  "javax.servlet" % "javax.servlet-api" % "3.1.0",
-  "org.glassfish.web" % "javax.servlet.jsp" % "2.3.1",
-  "com.googlecode.concurrentlinkedhashmap" % "concurrentlinkedhashmap-lru" % "1.4",
-  "net.jpountz.lz4" % "lz4" % "1.2.0",
-  "net.lingala.zip4j" % "zip4j" % "1.3.1", 
-  "com.fasterxml.jackson.core" % "jackson-databind" % "2.3.0",
-  "com.sun.jersey" % "jersey-json" % "1.17.1",
-  "mysql" % "mysql-connector-java" % "5.1.38",
-  "org.scala-lang" % "scala-xml" % "2.11.0-M4"
-)
-
-RevolverPlugin.settings
-
-scalariformSettings
-
-assemblySettings
-
-test in assembly := {}
-

BIN
frameworks/Scala/plain/lib/plain-library_2.10-1.0.1-SNAPSHOT.jar


+ 0 - 1
frameworks/Scala/plain/project/build.properties

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

+ 0 - 20
frameworks/Scala/plain/project/plugins.sbt

@@ -1,20 +0,0 @@
-logLevel := Level.Warn
-
-resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
-
-resolvers += "spray repo" at "http://repo.spray.io"
-
-addSbtPlugin("com.github.retronym" % "sbt-onejar" % "0.8")
-
-addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
-
-addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.8")
-
-addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0")
-
-addSbtPlugin("me.lessis" % "ls-sbt" % "0.1.2")
-
-addSbtPlugin("io.spray" % "sbt-revolver" % "0.8.0")
-
-addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.1")
-

+ 0 - 9
frameworks/Scala/plain/setup.sh

@@ -1,9 +0,0 @@
-#!/bin/bash
-
-fw_depends java sbt
-
-sed -i 's|127.0.0.1|'"${DBHOST}"'|g' src/main/resources/application.conf
-
-sbt assembly -batch && rm -rf target/scala-2.10/cache
-
-java -jar target/scala-2.10/plain-benchmark-assembly-1.0.1.jar &

+ 0 - 3
frameworks/Scala/plain/source_code

@@ -1,3 +0,0 @@
-./plain/src/main/scala/com/ibm/techempower/
-./plain/src/main/scala/com/ibm/techempower/PlainTextResource.scala
-./plain/src/main/scala/com/ibm/techempower/JsonResource.scala

+ 0 - 47
frameworks/Scala/plain/src/main/resources/application.conf

@@ -1,47 +0,0 @@
-#
-# application.conf
-#
-
-akka {
-	loggers = [ "akka.event.slf4j.Slf4jLogger" ]
-	loglevel = off
-	stdout-loglevel = off
-}
-
-plain {
-	logging.level = ERROR
-	json.encode-output = off
-	http.ignore-accept-header = on
-	http.startup-servers = [ benchmark-server ]
-	jdbc.startup-connection-factories = [ benchmark-mysql ]
-	servlet.web-applications-directory = "../web-apps"
-	servlet.unpack-web-applications-directory = "../web-apps"
-}
-
-benchmark-server {
-	port-range = [ 8080 ]
-	dispatcher = benchmark-dispatcher
-}
-
-benchmark-dispatcher.routes = [ 
-	{ uri = plaintext, resource-class-name = com.ibm.techempower.PlainText }
-	{ uri = json, resource-class-name = com.ibm.techempower.Json }
-	{ uri = db, resource-class-name = com.ibm.techempower.Db }
-	{ uri = update, resource-class-name = com.ibm.techempower.Update }
-	{ uri = fortunes, resource-class-name = com.ibm.techempower.Fortunes }
-	{ uri = "web-apps*", resource-class-name = com.ibm.plain.servlet.ServletResource }
-]
-
-benchmark-mysql {
-	name = MysqlBenchmark
-	jndi-lookup-name = "jdbc/hello_world"
-	driver = mysql-5-6-12
-	datasource-settings {	
-		setUrl = "jdbc:mysql://127.0.0.1:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true"
-		setUser = benchmarkdbuser
-		setPassword = benchmarkdbpass
-	}	
-	min-pool-size = 8
-	max-pool-size = 128
-}
-

+ 0 - 89
frameworks/Scala/plain/src/main/scala/com/ibm/techempower/Db.scala

@@ -1,89 +0,0 @@
-package com.ibm.techempower
-
-import java.util.concurrent.ThreadLocalRandom.{ current => random }
-
-import scala.language.implicitConversions
-import scala.language.postfixOps
-import scala.collection.mutable.MutableList
-
-import com.ibm.plain.ignore
-import com.ibm.plain.rest.{ Form, Resource }
-import com.ibm.plain.json.{ Json => J }
-import com.ibm.plain.jdbc.withConnection
-import com.ibm.plain.jdbc.ConnectionHelper._
-
-final class Db
-
-    extends DbResource {
-
-  Get { get(None) }
-
-  Get { form: Form => get(Some(form)) }
-
-}
-
-final class Update
-
-    extends DbResource {
-
-  Get { form: Form => update(form) }
-
-}
-
-sealed abstract class DbResource
-
-    extends Resource {
-
-  @inline protected[this] final def get(form: Option[Form]): J = {
-    val output = new MutableList[J]
-    val q = form match { case None => 1 case Some(f) => queries(f) }
-    withConnection(datasource) { implicit connection =>
-      for (i <- 1 to q) { for (j <- selectsql << next ! asJson) { output += j } }
-    }
-    form match { case None => output.head case _ => J(output.toList) }
-  }
-
-  @inline protected[this] final def update(form: Form): J = {
-    val input = new MutableList[World]
-    val output = new MutableList[J]
-    val q = queries(form)
-    withConnection(datasource) { implicit connection =>
-      for (i <- 1 to q) { for (j <- selectsql << next ! asTuple) { input += j } }
-      input.foreach {
-        case (id, _) =>
-          val randomNumber = next
-          updatesql << randomNumber << id ++;
-          output += asJson(id, randomNumber)
-      }
-      ignore(updatesql ++!)
-    }
-    J(output.toList)
-  }
-
-  @inline private[this] final def queries(form: Form) = try {
-    form.get("queries").get.head.toInt match {
-      case q if 1 > q => 1
-      case q if 500 < q => 500
-      case q => q
-    }
-  } catch {
-    case _: Throwable => 1
-  }
-
-  @inline private[this] final def asJson = (r: RichResultSet) => J(Map("id" -> r.nextInt, "randomNumber" -> r.nextInt))
-
-  @inline private[this] final def asJson(id: Int, randomNumber: Int) = J(Map("id" -> id, "randomNumber" -> randomNumber))
-
-  @inline private[this] final def asTuple = (r: RichResultSet) => (r.nextInt, r.nextInt)
-
-  @inline private[this] final def next = random.nextInt(1, 10001)
-
-  private[this] final type World = (Int, Int)
-
-  private[this] final val selectsql = "select id, randomNumber from World where id = ?"
-
-  private[this] final val updatesql = "update World set randomNumber = ? where id = ?"
-
-  private[this] final val datasource = "MysqlBenchmark"
-
-}

+ 0 - 41
frameworks/Scala/plain/src/main/scala/com/ibm/techempower/Fortunes.scala

@@ -1,41 +0,0 @@
-package com.ibm.techempower
-
-import scala.collection.mutable.ListBuffer
-import scala.language.implicitConversions
-import scala.xml._
-
-import com.ibm.plain.rest.{ Resource, Html }
-import com.ibm.plain.jdbc.withConnection
-import com.ibm.plain.jdbc.ConnectionHelper._
-
-final class Fortunes
-
-    extends Resource {
-
-  Get {
-    val list = new ListBuffer[(Int, String)]
-    withConnection(datasource) { implicit c => for (row <- sql ! asRow) { list += row } }
-    list += ((0, "Additional fortune added at request time."))
-    html(rows(list.sortBy(_._2)))
-  }
-
-  @inline private[this] final def asRow = (r: RichResultSet) => (r.nextInt, r.nextString)
-
-  @inline private[this] final def rows(list: ListBuffer[(Int, String)]) = list.map { e => row(e._1, e._2) }
-
-  @inline private[this] final def row(id: Int, message: String) = <tr><td>{ id }</td><td>{ message }</td></tr>
-
-  @inline private[this] final def html(rows: ListBuffer[Elem]): Html =
-    <html>
-      <head><title>Fortunes</title></head>
-      <body>  <table>
-                <tr><th>id</th><th>message</th></tr>
-                { rows }
-              </table> </body>
-    </html>
-
-  private[this] final val sql = "select id, message from Fortune"
-
-  private[this] final val datasource = "MysqlBenchmark"
-
-}

+ 0 - 12
frameworks/Scala/plain/src/main/scala/com/ibm/techempower/Json.scala

@@ -1,12 +0,0 @@
-package com.ibm.techempower
-
-import com.ibm.plain.rest.Resource
-import com.ibm.plain.json.{ Json => J }
-
-final class Json
-
-    extends Resource {
-
-  Get { J(Map("message" -> "Hello, World!")) }
-
-}

+ 0 - 28
frameworks/Scala/plain/src/main/scala/com/ibm/techempower/PlainText.scala

@@ -1,28 +0,0 @@
-package com.ibm.techempower
-
-import java.nio.ByteBuffer
-
-import com.ibm.plain.rest.Resource
-import com.ibm.plain.text.`UTF-8`
-
-final class PlainText
-
-    extends Resource {
-
-  import PlainText._
-
-  Get { hello.duplicate }
-
-}
-
-object PlainText {
-
-  private final val hello = {
-    val a = "Hello, World!".getBytes(`UTF-8`)
-    val buf = ByteBuffer.allocateDirect(a.length)
-    buf.put(a)
-    buf.flip
-    buf
-  }
-
-}

BIN
frameworks/Scala/plain/web-apps/servlet.war