Skip to content

Commit 9652b90

Browse files
committed
Merge branch 'master' into plaintext
2 parents d9f3ca8 + 6b00c5a commit 9652b90

File tree

648 files changed

+1302
-64057
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

648 files changed

+1302
-64057
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ benchmark.cfg
6767
*.war
6868

6969
# go
70-
go/pkg/
70+
go/pkg/*
71+
beego/pkg/*

aspnet/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# worker_processes n;
22
pid /tmp/nginx.pid;
3-
error_log /dev/null crit;
3+
error_log stderr error;
44

55
events {
66
worker_connections 8192;

beego/src/hello/hello.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import (
66
)
77

88
type MessageStruct struct {
9-
Message string
9+
Message string `json:"message"`
1010
}
1111

1212
type JsonController struct {
1313
beego.Controller
1414
}
1515

1616
func (this *JsonController) Get() {
17-
m := MessageStruct{"Hello, world"}
17+
m := MessageStruct{"Hello, World!"}
1818
this.Data["json"] = &m
1919
this.ServeJson()
2020
}

bottle/app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ def get_random_world(db):
6262
@app.route("/dbs")
6363
def get_random_world_single(db):
6464
wid = randint(1, 10000)
65-
worlds = [db.query(World).get(wid).serialize]
65+
world = db.query(World).get(wid).serialize
6666
response.content_type = 'application/json'
67-
return json.dumps(worlds)
67+
return json.dumps(world)
6868

6969
@app.route("/dbraw")
7070
def get_random_world_raw():
@@ -84,15 +84,15 @@ def get_random_world_single_raw():
8484
connection = db_engine.connect()
8585
wid = randint(1, 10000)
8686
result = connection.execute("SELECT * FROM world WHERE id = " + str(wid)).fetchone()
87-
worlds = [{'id': result[0], 'randomNumber': result[1]}]
87+
worlds = {'id': result[0], 'randomNumber': result[1]}
8888
connection.close()
8989
response.content_type = 'application/json'
9090
return json.dumps(worlds)
9191

9292
@app.route("/fortune")
9393
def fortune_orm(db):
9494
fortunes=db.query(Fortune).all()
95-
fortunes.append(Fortune(message="Additional fortune added at request time."))
95+
fortunes.append(Fortune(id=0, message="Additional fortune added at request time."))
9696
fortunes=sorted(fortunes, key=attrgetter('message'))
9797
return template('fortune-obj', fortunes=fortunes)
9898

cake/deploy/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#user nobody;
22
worker_processes 8;
3-
error_log /dev/null crit;
3+
error_log stderr error;
44

55
#error_log logs/error.log;
66
#error_log logs/error.log notice;

compojure/benchmark_config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"default": {
55
"setup_file": "setup",
66
"json_url": "/compojure/json",
7-
"db_url": "/compojure/db/1",
7+
"db_url": "/compojure/db",
88
"query_url": "/compojure/db/",
99
"fortune_url": "/compojure/fortune-hiccup",
1010
"plaintext_url": "/compojure/plaintext",
@@ -25,7 +25,7 @@
2525
},
2626
"raw": {
2727
"setup_file": "setup",
28-
"db_url": "/compojure/dbraw/1",
28+
"db_url": "/compojure/dbraw",
2929
"query_url": "/compojure/dbraw/",
3030
"port": 8080,
3131
"approach": "Realistic",

compojure/hello/project.clj

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
(defproject hello "compojure"
22
:description "JSON/Database tests"
3-
:url "http://example.com/FIXME"
3+
:url "http://localhost:3000/"
44
:dependencies [[org.clojure/clojure "1.5.1"]
5-
[compojure "1.1.5"]
5+
[compojure "1.1.6"]
66
[ring/ring-json "0.2.0"]
7-
[korma "0.3.0-RC5"]
7+
[korma "0.3.0-RC6"]
88
[log4j "1.2.15" :exclusions [javax.mail/mail javax.jms/jms com.sun.jdmk/jmxtools com.sun.jmx/jmxri]]
99
[mysql/mysql-connector-java "5.1.6"]
1010
[org.clojure/java.jdbc "0.3.0-alpha1"]
1111
[c3p0/c3p0 "0.9.1.2"]
12-
[hiccup "1.0.3"]
13-
[enlive "1.1.1"]
12+
[hiccup "1.0.4"]
1413
]
15-
:plugins [[lein-ring "0.8.2"]]
14+
:plugins [[lein-ring "0.8.10"]]
1615
:ring {:handler hello.handler/app}
1716
:profiles
18-
{:dev {:dependencies [[ring-mock "0.1.3"]]}})
17+
{:dev {:dependencies [[ring-mock "0.1.5"]]}})

compojure/hello/src/hello/handler.clj

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
korma.db
77
korma.core
88
hiccup.core
9-
hiccup.util)
9+
hiccup.util
10+
hiccup.page)
1011
(:require [compojure.handler :as handler]
1112
[compojure.route :as route]
1213
[clojure.java.jdbc :as jdbc]
13-
[clojure.java.jdbc.sql :as sql]
14-
[net.cgrand.enlive-html :as html]))
14+
[clojure.java.jdbc.sql :as sql]))
1515

1616
; Database connection
1717
(defdb db (mysql {:subname "//localhost: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"
@@ -38,11 +38,10 @@
3838

3939
; Run the specified number of queries, return the results
4040
(defn run-queries [queries]
41-
(vec ; Return as a vector
4241
(flatten ; Make it a list of maps
4342
(take
4443
queries ; Number of queries to run
45-
(repeatedly get-world)))))
44+
(repeatedly get-world))))
4645

4746
; Database connection for java.jdbc "raw"
4847
; https://github.com/clojure/java.jdbc/blob/master/doc/clojure/java/jdbc/ConnectionPooling.md
@@ -74,16 +73,17 @@
7473
(defn get-world-raw []
7574
(let [id (inc (rand-int 9999))] ; Num between 1 and 10,000
7675
(jdbc/with-connection (db-raw)
77-
(jdbc/with-query-results rs [(str "select * from world where id = ?") id]
78-
(doall rs)))))
76+
; Set a naming strategy to preserve column name case
77+
(jdbc/with-naming-strategy {:keyword identity}
78+
(jdbc/with-query-results rs [(str "select * from world where id = ?") id]
79+
(doall rs))))))
7980

8081
; Run the specified number of queries, return the results
8182
(defn run-queries-raw [queries]
82-
(vec ; Return as a vector
8383
(flatten ; Make it a list of maps
8484
(take
8585
queries ; Number of queries to run
86-
(repeatedly get-world-raw)))))
86+
(repeatedly get-world-raw))))
8787

8888
(defn get-query-count [queries]
8989
"Parse provided string value of query count, clamping values to between 1 and 500."
@@ -95,7 +95,6 @@
9595
1 ; clamp to 1 min
9696
q)))) ; otherwise use provided value
9797

98-
9998
; Set up entity World and the database representation
10099
(defentity fortune
101100
(pk :id)
@@ -116,7 +115,7 @@ message text, and then return the results."
116115

117116
(defn fortunes-hiccup [fortunes]
118117
"Render the given fortunes to simple HTML using Hiccup."
119-
(html
118+
(html5
120119
[:head
121120
[:title "Fortunes"]]
122121
[:body
@@ -142,7 +141,9 @@ message text, and then return the results."
142141
:headers {"Content-Type" "text/plain; charset=utf-8"}
143142
:body "Hello, World!"})
144143
(GET "/json" [] (response {:message "Hello, World!"}))
144+
(GET "/db" [] (response (first (run-queries 1))))
145145
(GET "/db/:queries" [queries] (response (run-queries (get-query-count queries))))
146+
(GET "/dbraw" [] (response (first (run-queries-raw 1))))
146147
(GET "/dbraw/:queries" [queries] (response (run-queries-raw (get-query-count queries))))
147148
(GET "/fortune" [] (response (get-fortunes)))
148149
(GET "/fortune-hiccup" [] (fortunes-hiccup (get-fortunes)))

config/benchmark_profile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,10 @@ export PATH="$JAVA_HOME/bin:$GRAILS_HOME/bin:$PLAY_HOME:$PLAY1_HOME:$VERTX_HOME/
1717

1818
export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/apr/lib'
1919

20+
export TFB_SERVER_HOST=172.16.98.122'
21+
export TFB_CLIENT_HOST='172.16.98.98'
22+
export TFB_CLIENT_USER='tfb'
23+
export TFB_CLIENT_IDENTITY_FILE='/home/tfb/.ssh/id_rsa-tfb-1'
24+
export TFB_DATABASE_HOST='172.16.98.118'
25+
2026
source ~/.rvm/scripts/'rvm'

config/create-postgres.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
DROP TABLE IF EXISTS World;
33
CREATE TABLE World (
44
id integer NOT NULL,
5-
"randomNumber" integer NOT NULL default 0,
5+
randomnumber integer NOT NULL default 0,
66
PRIMARY KEY (id)
77
);
88

9-
INSERT INTO World (id, randomNumber)
9+
INSERT INTO World (id, randomnumber)
1010
SELECT x.id, random() * 10000 + 1 FROM generate_series(1,10000) as x(id);
1111

1212
DROP TABLE IF EXISTS Fortune;

0 commit comments

Comments
 (0)