From 0e3c5bcbe6aca73e050053d9ec53f913b24487b1 Mon Sep 17 00:00:00 2001 From: Kilian Koeltzsch Date: Sun, 7 May 2017 18:21:09 +0200 Subject: [PATCH 01/10] add swift/vapor server --- swift/vapor/.gitignore | 4 ++ swift/vapor/Package.pins | 108 +++++++++++++++++++++++++++++++++ swift/vapor/Package.swift | 10 +++ swift/vapor/Sources/main.swift | 19 ++++++ 4 files changed, 141 insertions(+) create mode 100644 swift/vapor/.gitignore create mode 100644 swift/vapor/Package.pins create mode 100644 swift/vapor/Package.swift create mode 100644 swift/vapor/Sources/main.swift diff --git a/swift/vapor/.gitignore b/swift/vapor/.gitignore new file mode 100644 index 00000000000..02c087533d1 --- /dev/null +++ b/swift/vapor/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj diff --git a/swift/vapor/Package.pins b/swift/vapor/Package.pins new file mode 100644 index 00000000000..f7e81141fb1 --- /dev/null +++ b/swift/vapor/Package.pins @@ -0,0 +1,108 @@ +{ + "autoPin": true, + "pins": [ + { + "package": "CLibreSSL", + "reason": null, + "repositoryURL": "https://github.com/vapor/clibressl.git", + "version": "1.0.0" + }, + { + "package": "Console", + "reason": null, + "repositoryURL": "https://github.com/vapor/console.git", + "version": "1.0.2" + }, + { + "package": "Core", + "reason": null, + "repositoryURL": "https://github.com/vapor/core.git", + "version": "1.1.2" + }, + { + "package": "Crypto", + "reason": null, + "repositoryURL": "https://github.com/vapor/crypto.git", + "version": "1.1.0" + }, + { + "package": "Engine", + "reason": null, + "repositoryURL": "https://github.com/vapor/engine.git", + "version": "1.3.12" + }, + { + "package": "Fluent", + "reason": null, + "repositoryURL": "https://github.com/vapor/fluent.git", + "version": "1.4.3" + }, + { + "package": "JSON", + "reason": null, + "repositoryURL": "https://github.com/vapor/json.git", + "version": "1.0.6" + }, + { + "package": "Jay", + "reason": null, + "repositoryURL": "https://github.com/DanToml/Jay.git", + "version": "1.0.1" + }, + { + "package": "Leaf", + "reason": null, + "repositoryURL": "https://github.com/vapor/leaf.git", + "version": "1.0.7" + }, + { + "package": "Node", + "reason": null, + "repositoryURL": "https://github.com/vapor/node.git", + "version": "1.0.1" + }, + { + "package": "PathIndexable", + "reason": null, + "repositoryURL": "https://github.com/vapor/path-indexable.git", + "version": "1.0.0" + }, + { + "package": "Polymorphic", + "reason": null, + "repositoryURL": "https://github.com/vapor/polymorphic.git", + "version": "1.0.1" + }, + { + "package": "Routing", + "reason": null, + "repositoryURL": "https://github.com/vapor/routing.git", + "version": "1.1.0" + }, + { + "package": "Socks", + "reason": null, + "repositoryURL": "https://github.com/vapor/socks.git", + "version": "1.2.7" + }, + { + "package": "TLS", + "reason": null, + "repositoryURL": "https://github.com/vapor/tls.git", + "version": "1.1.2" + }, + { + "package": "Turnstile", + "reason": null, + "repositoryURL": "https://github.com/stormpath/Turnstile.git", + "version": "1.0.6" + }, + { + "package": "Vapor", + "reason": null, + "repositoryURL": "https://github.com/vapor/vapor.git", + "version": "1.1.13" + } + ], + "version": 1 +} \ No newline at end of file diff --git a/swift/vapor/Package.swift b/swift/vapor/Package.swift new file mode 100644 index 00000000000..2684e5e795f --- /dev/null +++ b/swift/vapor/Package.swift @@ -0,0 +1,10 @@ +// swift-tools-version:3.1 + +import PackageDescription + +let package = Package( + name: "server_swift_vapor", + dependencies: [ + .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1, minor: 1) + ] +) diff --git a/swift/vapor/Sources/main.swift b/swift/vapor/Sources/main.swift new file mode 100644 index 00000000000..527fd5df25a --- /dev/null +++ b/swift/vapor/Sources/main.swift @@ -0,0 +1,19 @@ +import Vapor + +let drop = Droplet(environment: .production) + +drop.get("/") { _ in + return "" +} + +drop.get("user", String.self) { _, userID in + return userID +} + +drop.post("user") { _ in + return "" +} + +drop.run(servers: [ + "default": (host: "127.0.0.1", port: 3000, securityLayer: .none) +]) From 5fb5e13390c0d138a1f3809d45c41646a586ac8a Mon Sep 17 00:00:00 2001 From: Kilian Koeltzsch Date: Sun, 7 May 2017 18:21:22 +0200 Subject: [PATCH 02/10] add swift/perfect server --- swift/perfect/.gitignore | 4 +++ swift/perfect/Package.pins | 42 ++++++++++++++++++++++++++++++++ swift/perfect/Package.swift | 10 ++++++++ swift/perfect/Sources/main.swift | 25 +++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 swift/perfect/.gitignore create mode 100644 swift/perfect/Package.pins create mode 100644 swift/perfect/Package.swift create mode 100644 swift/perfect/Sources/main.swift diff --git a/swift/perfect/.gitignore b/swift/perfect/.gitignore new file mode 100644 index 00000000000..02c087533d1 --- /dev/null +++ b/swift/perfect/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj diff --git a/swift/perfect/Package.pins b/swift/perfect/Package.pins new file mode 100644 index 00000000000..208b19d607f --- /dev/null +++ b/swift/perfect/Package.pins @@ -0,0 +1,42 @@ +{ + "autoPin": true, + "pins": [ + { + "package": "COpenSSL", + "reason": null, + "repositoryURL": "https://github.com/PerfectlySoft/Perfect-COpenSSL.git", + "version": "2.0.4" + }, + { + "package": "PerfectHTTP", + "reason": null, + "repositoryURL": "https://github.com/PerfectlySoft/Perfect-HTTP.git", + "version": "2.0.7" + }, + { + "package": "PerfectHTTPServer", + "reason": null, + "repositoryURL": "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", + "version": "2.0.9" + }, + { + "package": "PerfectLib", + "reason": null, + "repositoryURL": "https://github.com/PerfectlySoft/PerfectLib.git", + "version": "2.0.9" + }, + { + "package": "PerfectNet", + "reason": null, + "repositoryURL": "https://github.com/PerfectlySoft/Perfect-Net.git", + "version": "2.0.5" + }, + { + "package": "PerfectThread", + "reason": null, + "repositoryURL": "https://github.com/PerfectlySoft/Perfect-Thread.git", + "version": "2.0.9" + } + ], + "version": 1 +} \ No newline at end of file diff --git a/swift/perfect/Package.swift b/swift/perfect/Package.swift new file mode 100644 index 00000000000..93dcb779567 --- /dev/null +++ b/swift/perfect/Package.swift @@ -0,0 +1,10 @@ +// swift-tools-version:3.1 + +import PackageDescription + +let package = Package( + name: "server_swift_perfect", + dependencies: [ + .Package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", majorVersion: 2, minor: 0) + ] +) diff --git a/swift/perfect/Sources/main.swift b/swift/perfect/Sources/main.swift new file mode 100644 index 00000000000..fff5d7c9478 --- /dev/null +++ b/swift/perfect/Sources/main.swift @@ -0,0 +1,25 @@ +import PerfectHTTP +import PerfectHTTPServer + +let server = HTTPServer() + +var routes = Routes() + +routes.add(method: .get, uri: "/", handler: { _, response in + response.completed() +}) + +routes.add(method: .get, uri: "/user/{id}", handler: { request, response in + response.setBody(string: request.urlVariables["id"]!) + response.completed() +}) + +routes.add(method: .post, uri: "/user", handler: { _, response in + response.completed() +}) + +server.addRoutes(routes) + +server.serverPort = 3000 + +try! server.start() From 6ccb561e22c5a5a58e9a253eb56574166161d8ab Mon Sep 17 00:00:00 2001 From: Kilian Koeltzsch Date: Sun, 7 May 2017 18:21:49 +0200 Subject: [PATCH 03/10] add build targets for vapor & perfect --- Makefile | 13 +++++++++++++ neph.yml | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/Makefile b/Makefile index 9e25eb05382..2ce0ac45903 100644 --- a/Makefile +++ b/Makefile @@ -91,6 +91,19 @@ rocket: cd rust/rocket; cargo build --release ln -s -f ../rust/rocket/target/release/server_rust_rocket bin/. +# --- Swift --- +swift: vapor perfect + +# Vapor +vapor: + cd swift/vapor; swift build --configuration release + ln -s -f ../swift/vapor/.build/release/server_swift_vapor bin/. + +# Perfect +perfect: + cd swift/perfect; swift build --configuration release + ln -s -f ../swift/perfect/.build/release/server_swift_perfect bin/. + # --- Benchmarker --- # client client: diff --git a/neph.yml b/neph.yml index 1e0397ce8be..6c60dde882d 100644 --- a/neph.yml +++ b/neph.yml @@ -140,6 +140,25 @@ plug: chdir: elixir/plug +swift: + depends_on: + - vapor + - perfect + +vapor: + command: | + swift build --configuration release + ln -s -f ../swift/vapor/.build/release/server_swift_vapor ../../bin/. + chdir: + swift/vapor + +perfect: + command: | + swift build --configuration release + ln -s -f ../swift/perfect/.build/release/server_swift_perfect ../../bin/. + chdir: + swift/perfect + benchmarker: command: | crystal build src/benchmarker.cr -o bin/benchmarker --release From 425dc3045d4ffd54d6bc1d0f98e91621430d5b37 Mon Sep 17 00:00:00 2001 From: Kilian Koeltzsch Date: Sun, 7 May 2017 18:21:58 +0200 Subject: [PATCH 04/10] add readme links for vapor and perfect --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 6d9065d6051..8c4f52dfb50 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,9 @@ Measuring response times for each framework(middleware). Each framework has to - [express](https://github.com/expressjs/express) - Elixir - [Plug](http://github.com/elixir-lang/plug) + - Swift + - [Vapor](https://vapor.codes) + - [Perfect](https://www.perfect.org) See Development section when you want to add new languages for frameworks. From fbd5b432592ffc1bc63e9467b6bf3bd462e14593 Mon Sep 17 00:00:00 2001 From: Kilian Koeltzsch Date: Sun, 7 May 2017 20:43:28 +0200 Subject: [PATCH 05/10] unsafe operations aren't nice, even in demo code --- swift/perfect/Sources/main.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swift/perfect/Sources/main.swift b/swift/perfect/Sources/main.swift index fff5d7c9478..e849339657e 100644 --- a/swift/perfect/Sources/main.swift +++ b/swift/perfect/Sources/main.swift @@ -10,7 +10,7 @@ routes.add(method: .get, uri: "/", handler: { _, response in }) routes.add(method: .get, uri: "/user/{id}", handler: { request, response in - response.setBody(string: request.urlVariables["id"]!) + response.setBody(string: request.urlVariables["id"] ?? "") response.completed() }) From b4fcdb5cc6bebee414eed1a4df0c36ee779610ea Mon Sep 17 00:00:00 2001 From: Kilian Koeltzsch Date: Sun, 7 May 2017 20:43:47 +0200 Subject: [PATCH 06/10] add kitura application --- swift/kitura/.gitignore | 4 +++ swift/kitura/Package.pins | 54 +++++++++++++++++++++++++++++++++ swift/kitura/Package.swift | 10 ++++++ swift/kitura/Sources/main.swift | 19 ++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 swift/kitura/.gitignore create mode 100644 swift/kitura/Package.pins create mode 100644 swift/kitura/Package.swift create mode 100644 swift/kitura/Sources/main.swift diff --git a/swift/kitura/.gitignore b/swift/kitura/.gitignore new file mode 100644 index 00000000000..02c087533d1 --- /dev/null +++ b/swift/kitura/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj diff --git a/swift/kitura/Package.pins b/swift/kitura/Package.pins new file mode 100644 index 00000000000..e9b5d59bdf7 --- /dev/null +++ b/swift/kitura/Package.pins @@ -0,0 +1,54 @@ +{ + "autoPin": true, + "pins": [ + { + "package": "CCurl", + "reason": null, + "repositoryURL": "https://github.com/IBM-Swift/CCurl.git", + "version": "0.2.3" + }, + { + "package": "Kitura", + "reason": null, + "repositoryURL": "https://github.com/IBM-Swift/Kitura.git", + "version": "1.7.3" + }, + { + "package": "Kitura-TemplateEngine", + "reason": null, + "repositoryURL": "https://github.com/IBM-Swift/Kitura-TemplateEngine.git", + "version": "1.7.0" + }, + { + "package": "Kitura-net", + "reason": null, + "repositoryURL": "https://github.com/IBM-Swift/Kitura-net.git", + "version": "1.7.4" + }, + { + "package": "LoggerAPI", + "reason": null, + "repositoryURL": "https://github.com/IBM-Swift/LoggerAPI.git", + "version": "1.7.0" + }, + { + "package": "SSLService", + "reason": null, + "repositoryURL": "https://github.com/IBM-Swift/BlueSSLService.git", + "version": "0.12.32" + }, + { + "package": "Socket", + "reason": null, + "repositoryURL": "https://github.com/IBM-Swift/BlueSocket.git", + "version": "0.12.46" + }, + { + "package": "SwiftyJSON", + "reason": null, + "repositoryURL": "https://github.com/IBM-Swift/SwiftyJSON.git", + "version": "16.0.0" + } + ], + "version": 1 +} \ No newline at end of file diff --git a/swift/kitura/Package.swift b/swift/kitura/Package.swift new file mode 100644 index 00000000000..0a56e2731df --- /dev/null +++ b/swift/kitura/Package.swift @@ -0,0 +1,10 @@ +// swift-tools-version:3.1 + +import PackageDescription + +let package = Package( + name: "server_swift_kitura", + dependencies: [ + .Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 7) + ] +) diff --git a/swift/kitura/Sources/main.swift b/swift/kitura/Sources/main.swift new file mode 100644 index 00000000000..53ef3b84bf8 --- /dev/null +++ b/swift/kitura/Sources/main.swift @@ -0,0 +1,19 @@ +import Kitura + +let router = Router() + +router.get("/") { _, res, _ in + try res.send("").end() +} + +router.get("/user/:id") { req, res, _ in + let id = req.parameters["id"] ?? "" + try res.send(id).end() +} + +router.post("/user") { _, res, _ in + try res.send("").end() +} + +Kitura.addHTTPServer(onPort: 3000, with: router) +Kitura.run() From faf7d5d1521961ac0d9cf2068399e3decfcd7380 Mon Sep 17 00:00:00 2001 From: Kilian Koeltzsch Date: Sun, 7 May 2017 20:47:16 +0200 Subject: [PATCH 07/10] add build targets for kitura --- Makefile | 7 ++++++- neph.yml | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2ce0ac45903..43368015256 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,7 @@ rocket: ln -s -f ../rust/rocket/target/release/server_rust_rocket bin/. # --- Swift --- -swift: vapor perfect +swift: vapor perfect kitura # Vapor vapor: @@ -104,6 +104,11 @@ perfect: cd swift/perfect; swift build --configuration release ln -s -f ../swift/perfect/.build/release/server_swift_perfect bin/. +# Kitura +kitura: + cd swift/kitura; swift build --configuration release + ln -s -f ../swift/kitura/.build/release/server_swift_kitura bin/. + # --- Benchmarker --- # client client: diff --git a/neph.yml b/neph.yml index 6c60dde882d..be400bae519 100644 --- a/neph.yml +++ b/neph.yml @@ -144,6 +144,7 @@ swift: depends_on: - vapor - perfect + - kitura vapor: command: | @@ -159,6 +160,13 @@ perfect: chdir: swift/perfect +kitura: + command: | + swift build --configuration release + ln -s -f ../swift/kitura/.build/release/server_swift_kitura ../../bin/. + chdir: + swift/kitura + benchmarker: command: | crystal build src/benchmarker.cr -o bin/benchmarker --release From 98cad6c38f9eb0dd32b0ffcee4b09f69938c726f Mon Sep 17 00:00:00 2001 From: Kilian Koeltzsch Date: Sun, 7 May 2017 20:47:25 +0200 Subject: [PATCH 08/10] add all swift frameworks to benchmarker --- benchmarker/src/benchmarker.cr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/benchmarker/src/benchmarker.cr b/benchmarker/src/benchmarker.cr index b0de1747e8e..984d2ca5c76 100644 --- a/benchmarker/src/benchmarker.cr +++ b/benchmarker/src/benchmarker.cr @@ -33,6 +33,11 @@ LANGS = [ {lang: "Elixir", targets: [ {name: "Plug", exec: "server_elixir_plug"}, ]}, + {lang: "Swift", targets: [ + {name: "Vapor", exec: "server_swift_vapor"}, + {name: "Perfect", exec: "server_swift_perfect"}, + {name: "Kitura", exec: "server_swift_kitura"}, + ]}, ] # struct for benchmark result From 9720930a47cb84494e34a3f3849a56e69d0a7562 Mon Sep 17 00:00:00 2001 From: Kilian Koeltzsch Date: Sun, 7 May 2017 20:51:14 +0200 Subject: [PATCH 09/10] use most current stable vapor version --- swift/vapor/Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swift/vapor/Package.swift b/swift/vapor/Package.swift index 2684e5e795f..e6e9d4c27d9 100644 --- a/swift/vapor/Package.swift +++ b/swift/vapor/Package.swift @@ -5,6 +5,6 @@ import PackageDescription let package = Package( name: "server_swift_vapor", dependencies: [ - .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1, minor: 1) + .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1, minor: 5) ] ) From 120577d27757d85611741586f8c6608b6cda4c6c Mon Sep 17 00:00:00 2001 From: Kilian Koeltzsch Date: Sun, 7 May 2017 20:54:03 +0200 Subject: [PATCH 10/10] Add Kitura link to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8c4f52dfb50..6786b61c606 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Measuring response times for each framework(middleware). Each framework has to - Swift - [Vapor](https://vapor.codes) - [Perfect](https://www.perfect.org) + - [Kitura](http://www.kitura.io) See Development section when you want to add new languages for frameworks.