Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions scruffy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
## generic files to ignore
*~
*.lock
*.DS_Store
*.swp
*.out

# java specific
*.class

# python specific
*.pyc

# sbt specific
target/
project/boot
lib_managed/*
project/build/target
project/build/lib_managed
project/build/src_managed
project/plugins/lib_managed
project/plugins/target
project/plugins/src_managed
project/plugins/project

core/lib_managed
core/target
pubsub/lib_managed
pubsub/target

# eclipse specific
.metadata
jrebel.lic
.settings
.classpath
.project

.ensime*
*.sublime-*
.cache

# intellij
*.eml
*.iml
*.ipr
*.iws
.*.sw?
.idea
34 changes: 34 additions & 0 deletions scruffy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#Scruffy Benchmarking Test

This is the Scruffy portion of a [benchmarking test suite](../) comparing a variety of web development platforms.

## Infrastructure Software Versions

The tests were run with:

* [Java OpenJDK 1.7.0_09](http://openjdk.java.net/)
* [Scruffy 1.4.15](http://scruffy-project.github.io/)

## Test URLs

### Test type 1: JSON serialization

http://localhost:8080/json

This example uses the built-in Jackson for json support.

* [Test 1 source](src/main/scala/scruffy/examples/Test1Endpoint.scala)

### Test type 2: Single database query

This example uses casbah for Mongo queries. Future improvement would be to switch to a nonblocking library.

* [Test 2 source](src/main/scala/scruffy/examples/Test2Endpoint.scala)

http://localhost:8080/db

### Test type 6: Plaintext

http://localhost:8080/plaintext

* [Test 6 source](src/main/scala/scruffy/examples/Test6Endpoint.scala)
Empty file added scruffy/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions scruffy/benchmark_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"framework": "Scruffy",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convention is for this to be lower-case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scruffy won't actually say anything once its started (log wise) as I
disabled all logging. I could add something back in to say "server running"
or something, which when you think about it was stupid of me to take out.

On 21 July 2014 16:47, Alexander Schneider [email protected] wrote:

In scruffy/benchmark_config:

@@ -0,0 +1,26 @@
+{

  • "framework": "Scruffy",

Convention is for this to be lower-case.


Reply to this email directly or view it on GitHub
https://github.com/TechEmpower/FrameworkBenchmarks/pull/867/files#r15176418
.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added an explicit "scruffy is running" line to the console. You should
see something like this when running.

sam@sam-ubuntu:~/development/workspace/FrameworkBenchmarks/scruffy$ java
-jar target/scala-2.11/scruffy-benchmark-assembly-1.0.1.jar
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
details.
Starting Scruffy...
Started on port [8080]. Interrupt to exit.

The other points have been addressed.

On 21 July 2014 16:50, Stephen Samuel (Sam) [email protected] wrote:

Scruffy won't actually say anything once its started (log wise) as I
disabled all logging. I could add something back in to say "server running"
or something, which when you think about it was stupid of me to take out.

On 21 July 2014 16:47, Alexander Schneider [email protected]
wrote:

In scruffy/benchmark_config:

@@ -0,0 +1,26 @@
+{

  • "framework": "Scruffy",

Convention is for this to be lower-case.


Reply to this email directly or view it on GitHub
https://github.com/TechEmpower/FrameworkBenchmarks/pull/867/files#r15176418
.

"tests": [{
"default": {
"setup_file": "setup",
"json_url": "/json",
"db_url": "/db",
"plaintext_url": "/plaintext",
"query_url": "/queries?queries=",
"port": 8080,
"approach": "Realistic",
"classification": "Micro",
"database": "MongoDB",
"framework": "Scruffy",
"language": "Scala",
"orm": "Raw",
"platform": "Netty",
"webserver": "None",
"os": "Linux",
"database_os": "Linux",
"display_name": "Scruffy",
"notes": "",
"versus": "Netty"
}
}]
}
14 changes: 14 additions & 0 deletions scruffy/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name := "scruffy-benchmark"

organization := "com.sksamuel.scruffy"

scalaVersion := "2.11.1"

version := "1.0.1"

libraryDependencies ++= Seq(
"com.sksamuel.scruffy" %% "scruffy-server" % "1.4.15",
"org.mongodb" %% "casbah-core" % "2.7.1"
)

sbtassembly.Plugin.assemblySettings
1 change: 1 addition & 0 deletions scruffy/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=0.13.2
1 change: 1 addition & 0 deletions scruffy/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
35 changes: 35 additions & 0 deletions scruffy/setup.py
Original file line number Diff line number Diff line change
@@ -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="scruffy", stderr=errfile, stdout=logfile)
else:
subprocess.check_call("../sbt/sbt assembly", shell=True, cwd="scruffy", stderr=errfile, stdout=logfile)

subprocess.Popen("java -jar target/scala-2.11/scruffy-benchmark-assembly-1.0.1.jar -Dhostname" + args.database_host,
cwd="scruffy",
shell=True,
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 '%scruffy-benchmark%'\" 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 'scruffy-benchmark' in line:
try:
pid = int(line.split(None, 2)[1])
os.kill(pid, 15)
except OSError:
pass

return 0
4 changes: 4 additions & 0 deletions scruffy/source_code
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
./scruffy/src/main/scala/scruffy/examples/
./scruffy/src/main/scala/scruffy/examples/Main.scala
./scruffy/src/main/scala/scruffy/examples/Test1Route.scala
./scruffy/src/main/scala/scruffy/examples/Test6Route.scala
14 changes: 14 additions & 0 deletions scruffy/src/main/scala/scruffy/examples/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package scruffy.examples

import com.sksamuel.scruffy.{ScruffyConfiguration, Scruffy}

/** @author Stephen Samuel */
object Main extends App {

val port = 8080
val scruffy = new Scruffy(ScruffyConfiguration.port(port).compression(false).requestLogging(false))
scruffy.mount(new Test1Endpoint)
scruffy.mount(new Test2Endpoint(Option(System.getProperty("hostname")).getOrElse("localhost")))
scruffy.mount(new Test6Endpoint)
scruffy.start().await()
}
13 changes: 13 additions & 0 deletions scruffy/src/main/scala/scruffy/examples/Test1Endpoint.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package scruffy.examples

import com.sksamuel.scruffy.EndpointProvider

/** @author Stephen Samuel */
class Test1Endpoint extends EndpointProvider {

get("json").complete {
req => json(Message("Hello World"))
}
}

case class Message(message: String)
26 changes: 26 additions & 0 deletions scruffy/src/main/scala/scruffy/examples/Test2Endpoint.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package scruffy.examples

import com.mongodb.casbah.Imports._
import com.sksamuel.scruffy.EndpointProvider

/** @author Stephen Samuel */
class Test2Endpoint(hostname: String) extends EndpointProvider {

val connection = MongoConnection(hostname, 27017)
val collection = connection.getDB("world").getCollection("world")

val random = new scala.util.Random(System.currentTimeMillis)
val fields = DBObject("_id" -> true, "randomNumber" -> true)

// uncomment to populate
// for ( k <- 1 to 10000 )
// collection.save(DBObject("_id" -> k, "id" -> k, "randomNumber" -> random.nextInt(10000)))

get("db").json {
req =>
val id = random.nextInt(10000)
collection.findOne(DBObject("_id" -> id), fields)
}
}


13 changes: 13 additions & 0 deletions scruffy/src/main/scala/scruffy/examples/Test6Endpoint.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package scruffy.examples

import com.sksamuel.scruffy.EndpointProvider
import com.sksamuel.scruffy.http.MediaType

/** @author Stephen Samuel */
class Test6Endpoint extends EndpointProvider {

get("plaintext").complete {
req => entity("Hello, World!", MediaType.TextPlain)
}

}