Skip to content

Commit

Permalink
Merge pull request #46 from fracek/techempower-bench
Browse files Browse the repository at this point in the history
Techempower benchmarks #1 and #2
  • Loading branch information
waywardmonkeys committed May 7, 2014
2 parents e05afff + 950ed58 commit 3045f5b
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
[submodule "submodules/concurrency"]
path = submodules/concurrency
url = https://github.com/dylan-foundry/concurrency.git
[submodule "submodules/serialization"]
path = submodules/serialization
url = https://github.com/dylan-foundry/serialization.git
19 changes: 19 additions & 0 deletions examples/techempower-benchmarks/json.dylan
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module: techempower-benchmarks
synopsis: json serialization benchmark.
author: Francesco Ceccon
define class <json-page> (<resource>)
constant slot hello-string = "Hello, World!";
slot message :: <string-table>;
end class;

define method initialize (page :: <json-page>, #key)
page.message := table(<string-table>, "message" => "Hello, World!");
end method;

// set the correct content-type, then send "Hello, World!".
define method respond (page :: <json-page>, #key)
set-header(current-response(), "Content-Type", "application/json");
output(write-object-to-json-string(page.message));
end method respond;

21 changes: 21 additions & 0 deletions examples/techempower-benchmarks/library.dylan
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module: dylan-user
synopsis: TechEmpower plaintext benchmark
author: Francesco Ceccon
define library techempower-benchmarks
use common-dylan;
use http-common;
use http-server;
use serialization;
use collections;
end;


define module techempower-benchmarks
use common-dylan;
use http-common;
use http-server;
use json-serialization;
use table-extensions;
end;

14 changes: 14 additions & 0 deletions examples/techempower-benchmarks/main.dylan
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module: techempower-benchmarks
define function map-resources (server :: <http-server>)
add-resource(server, "/json", make(<json-page>));
add-resource(server, "/plaintext", make(<plaintext-page>));
end function map-resources;

define function main ()
http-server-main(server: make(<http-server>,
listeners: list("127.0.0.1:8000")),
before-startup: map-resources);
end function main;

main();
14 changes: 14 additions & 0 deletions examples/techempower-benchmarks/plaintext.dylan
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module: techempower-benchmarks
synopsis: plaintext benchmark.
author: Francesco Ceccon
define class <plaintext-page> (<resource>)
constant slot hello-string = "Hello, World!";
end class;

// set the correct content-type, then send "Hello, World!".
define method respond (page :: <plaintext-page>, #key)
set-header(current-response(), "Content-Type", "text/plain");
output(page.hello-string);
end method respond;

6 changes: 6 additions & 0 deletions examples/techempower-benchmarks/techempower-benchmarks.lid
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library: techempower-benchmarks
target-type: executable
files: library
plaintext
json
main
1 change: 1 addition & 0 deletions registry/generic/serialization
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abstract://dylan/submodules/serialization/serialization.lid
1 change: 1 addition & 0 deletions registry/generic/techempower-benchmarks
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abstract://dylan/examples/techempower-benchmarks/techempower-benchmarks.lid
1 change: 1 addition & 0 deletions submodules/serialization
Submodule serialization added at 2cdb9f

0 comments on commit 3045f5b

Please sign in to comment.