Created
February 27, 2010 06:05
-
-
Save KirinDave/316514 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>BAD DATA</title> | |
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> | |
<meta content="en-us" http-equiv="Content-Language" /> | |
</head> | |
<body> | |
<header><h1>BAD DATA</h1></header> | |
<article> | |
<h2>Title</h2> | |
<p>Post text!</p> | |
</article> | |
<footer> | |
<p id="copyright">© 2010 Dave Fayram</p> | |
</footer> | |
</body> | |
</html> |
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
(ns server | |
(:require [compojure] | |
[net.cgrand (enlive-html :as en)])) | |
; We use compojure (our webserver) and enlive (our templating engine). | |
; (;'s are comment lines) | |
;; First let's define our template | |
;; Look at simple.html first. | |
;;; This makes a function "index-template" that takes a list of posts and | |
;;; pastes them into simple-html. | |
(en/deftemplate index-template "enlive-template.html" [posts] | |
[:title] (en/content "Hello World!") | |
[:header :h1] (en/content "This is my title!") | |
[:article] (en/clone-for [{:keys [title text]} posts] | |
[:h2] (en/content title) | |
[:p] (en/content text))) | |
;;; Next let's makes some posts | |
;;; This just sets *posts* to a vector of hash tables. | |
(def *posts* [{:title "Enlive is cool.", | |
:text "Isn't it though?"}, | |
{:title "Hello world!", | |
:text "I promise I will post in this blog a LOT."}]) | |
;;; Next let's set up our routing table. | |
;;;; This maps /index.html -> our template. | |
(defroutes microblog | |
(ANY "/index.html" (index-template *posts*)) | |
(ANY "*" [404 "Not Found"])) | |
;;; Finally, a function to run our server using jetty. | |
(defn start-server | |
([port] (run-server {:port port} "/*" (servlet microblog))) | |
([] (start-server 8080))) |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>Hello World!</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta http-equiv="Content-Language" content="en-us" /> | |
<link type="text/css" rel="stylesheet" media="screen, projection" href="screen.css" /> | |
</head> | |
<body> | |
<header><h1>This is my title!</h1></header> | |
<article> | |
<h2>Enlive is cool.</h2> | |
<p>Isn't it though?</p> | |
</article><article> | |
<h2>Hello world!</h2> | |
<p>I promise I will post in this blog a LOT.</p> | |
</article> | |
<footer> | |
<p id="copyright">© 2010 Dave Fayram</p> | |
</footer> | |
</body> | |
</html> |
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
~ % 〕ab -n 3000 http://localhost:8080/testing ← 0 | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking localhost (be patient) | |
Completed 300 requests | |
Completed 600 requests | |
Completed 900 requests | |
Completed 1200 requests | |
Completed 1500 requests | |
Completed 1800 requests | |
Completed 2100 requests | |
Completed 2400 requests | |
Completed 2700 requests | |
Completed 3000 requests | |
Finished 3000 requests | |
Server Software: Jetty(6.1.21) | |
Server Hostname: localhost | |
Server Port: 8080 | |
Document Path: /index.html | |
Document Length: 669 bytes | |
Concurrency Level: 1 | |
Time taken for tests: 10.582 seconds | |
Complete requests: 3000 | |
Failed requests: 0 | |
Write errors: 0 | |
Total transferred: 2133000 bytes | |
HTML transferred: 2007000 bytes | |
Requests per second: 283.51 [#/sec] (mean) | |
Time per request: 3.527 [ms] (mean) | |
Time per request: 3.527 [ms] (mean, across all concurrent requests) | |
Transfer rate: 196.85 [Kbytes/sec] received | |
Connection Times (ms) | |
min mean[+/-sd] median max | |
Connect: 0 0 0.1 0 2 | |
Processing: 3 3 1.1 3 19 | |
Waiting: 2 3 1.1 3 19 | |
Total: 3 3 1.1 3 19 | |
Percentage of the requests served within a certain time (ms) | |
50% 3 | |
66% 3 | |
75% 3 | |
80% 4 | |
90% 4 | |
95% 5 | |
98% 6 | |
99% 6 | |
100% 19 (longest request) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment