-
Notifications
You must be signed in to change notification settings - Fork 2k
Adding support for Scruffy with Benchmarks 1, 2 and 6 #867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
73011f2
Adding support for Scuffy with Benchmarks 1 and 6
sksamuel 0723ce0
Updated benchmark config. Updated scruffy version.
sksamuel 52d6203
Updated readme
sksamuel 07cd265
Added test 2 to scruffy benchmarks
sksamuel 343b106
Bumped scruffy version to fix compression
sksamuel 9cd4ac9
Disabled request logging
sksamuel f0964b2
Added install.sh file
sksamuel b75ad64
Lowercased name in config
sksamuel 78ed059
Added console output for startup
sksamuel bf47fef
Updated json test to output exact text required. Updated db test to o…
sksamuel 26e32e8
Commented out db population script
sksamuel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "framework": "Scruffy", | ||
| "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" | ||
| } | ||
| }] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| sbt.version=0.13.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
13
scruffy/src/main/scala/scruffy/examples/Test1Endpoint.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
26
scruffy/src/main/scala/scruffy/examples/Test2Endpoint.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
13
scruffy/src/main/scala/scruffy/examples/Test6Endpoint.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| } | ||
|
|
||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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: