ソースを参照

Updates for Swift 5.10, Remove Kitura and Perfect (#8960)

* Swift 5.10

* Add versus entry for Swift frameworks

* Add Swift level .gitignore, update Swift level README

* Remove Kitura and Perfect

* Remove package level .gitignore now we have one in Swift folder

* Remove vapor-mongo-fluent.
Adam Fowler 1 年間 前
コミット
0ddbb87df5
72 ファイル変更24 行追加3723 行削除
  1. 1 0
      frameworks/Swift/.gitignore
  2. 2 1
      frameworks/Swift/README.md
  3. 1 1
      frameworks/Swift/hummingbird-core/benchmark_config.json
  4. 2 2
      frameworks/Swift/hummingbird-core/hummingbird-core.dockerfile
  5. 0 7
      frameworks/Swift/hummingbird/.gitignore
  6. 1 1
      frameworks/Swift/hummingbird/benchmark_config.json
  7. 2 2
      frameworks/Swift/hummingbird/hummingbird-postgres.dockerfile
  8. 2 2
      frameworks/Swift/hummingbird/hummingbird.dockerfile
  9. 0 6
      frameworks/Swift/kitura/.gitignore
  10. 0 1
      frameworks/Swift/kitura/.swift-version
  11. 0 51
      frameworks/Swift/kitura/Package.swift
  12. 0 56
      frameworks/Swift/kitura/README.md
  13. 0 42
      frameworks/Swift/kitura/Sources/KueryPostgres/Postgres.swift
  14. 0 223
      frameworks/Swift/kitura/Sources/KueryPostgresORM/PostgresORM.swift
  15. 0 285
      frameworks/Swift/kitura/Sources/KueryPostgresRaw/PostgresRaw.swift
  16. 0 44
      frameworks/Swift/kitura/Sources/TechEmpower/main.swift
  17. 0 35
      frameworks/Swift/kitura/Sources/TechEmpowerCommon/Error.swift
  18. 0 90
      frameworks/Swift/kitura/Sources/TechEmpowerCommon/Fortune.swift
  19. 0 70
      frameworks/Swift/kitura/Sources/TechEmpowerCommon/RandomRow.swift
  20. 0 123
      frameworks/Swift/kitura/Sources/TechEmpowerMongoKitten/Mongo.swift
  21. 0 118
      frameworks/Swift/kitura/Sources/TechEmpowerMongoKitten/main.swift
  22. 0 210
      frameworks/Swift/kitura/Sources/TechEmpowerPostgres/main.swift
  23. 0 24
      frameworks/Swift/kitura/Sources/TechEmpowerPostgresMustache/Fortune+Mustache.swift
  24. 0 57
      frameworks/Swift/kitura/Sources/TechEmpowerPostgresMustache/main.swift
  25. 0 166
      frameworks/Swift/kitura/Sources/TechEmpowerPostgresORM/main.swift
  26. 0 136
      frameworks/Swift/kitura/Sources/TechEmpowerPostgresORMCodable/main.swift
  27. 0 12
      frameworks/Swift/kitura/Views/fortunes.mustache
  28. 0 10
      frameworks/Swift/kitura/Views/fortunes.stencil
  29. 0 246
      frameworks/Swift/kitura/benchmark_config.json
  30. 0 16
      frameworks/Swift/kitura/config.json
  31. 0 178
      frameworks/Swift/kitura/config.toml
  32. 0 10
      frameworks/Swift/kitura/kitura-gcd-postgres-orm-codable.dockerfile
  33. 0 10
      frameworks/Swift/kitura/kitura-gcd-postgres-orm.dockerfile
  34. 0 10
      frameworks/Swift/kitura/kitura-gcd-postgres.dockerfile
  35. 0 10
      frameworks/Swift/kitura/kitura-gcd.dockerfile
  36. 0 10
      frameworks/Swift/kitura/kitura-mongodb.dockerfile
  37. 0 11
      frameworks/Swift/kitura/kitura-nio-postgres-orm-codable.dockerfile
  38. 0 11
      frameworks/Swift/kitura/kitura-nio-postgres-orm.dockerfile
  39. 0 11
      frameworks/Swift/kitura/kitura-nio-postgres.dockerfile
  40. 0 11
      frameworks/Swift/kitura/kitura-nio.dockerfile
  41. 0 10
      frameworks/Swift/kitura/kitura-postgres-orm-codable.dockerfile
  42. 0 10
      frameworks/Swift/kitura/kitura-postgres-orm.dockerfile
  43. 0 10
      frameworks/Swift/kitura/kitura-postgres.dockerfile
  44. 0 10
      frameworks/Swift/kitura/kitura.dockerfile
  45. 0 6
      frameworks/Swift/perfect/.gitignore
  46. 0 25
      frameworks/Swift/perfect/Package.swift
  47. 0 43
      frameworks/Swift/perfect/README.md
  48. 0 316
      frameworks/Swift/perfect/Sources/Perfect-MongoDB/main.swift
  49. 0 313
      frameworks/Swift/perfect/Sources/Perfect-MySQL/main.swift
  50. 0 224
      frameworks/Swift/perfect/Sources/Perfect-PostgreSQL/main.swift
  51. 0 78
      frameworks/Swift/perfect/Sources/Perfect/main.swift
  52. 0 80
      frameworks/Swift/perfect/benchmark_config.json
  53. 0 57
      frameworks/Swift/perfect/config.toml
  54. 0 10
      frameworks/Swift/perfect/perfect-mongodb.dockerfile
  55. 0 10
      frameworks/Swift/perfect/perfect-mysql.dockerfile
  56. 0 10
      frameworks/Swift/perfect/perfect-postgresql.dockerfile
  57. 0 10
      frameworks/Swift/perfect/perfect.dockerfile
  58. 0 8
      frameworks/Swift/swift-nio/.gitignore
  59. 0 15
      frameworks/Swift/swift-nio/config.toml
  60. 2 2
      frameworks/Swift/swift-nio/swift-nio.dockerfile
  61. 0 7
      frameworks/Swift/vapor/.gitignore
  62. 1 1
      frameworks/Swift/vapor/benchmark_config.json
  63. 2 2
      frameworks/Swift/vapor/vapor-fluent.dockerfile
  64. 0 29
      frameworks/Swift/vapor/vapor-mongo-fluent.dockerfile
  65. 0 29
      frameworks/Swift/vapor/vapor-mongo-fluent/Package.swift
  66. 0 25
      frameworks/Swift/vapor/vapor-mongo-fluent/Sources/Utilities.swift
  67. 0 14
      frameworks/Swift/vapor/vapor-mongo-fluent/Sources/World.swift
  68. 0 52
      frameworks/Swift/vapor/vapor-mongo-fluent/Sources/main.swift
  69. 2 2
      frameworks/Swift/vapor/vapor-mongo.dockerfile
  70. 2 2
      frameworks/Swift/vapor/vapor-postgres.dockerfile
  71. 2 2
      frameworks/Swift/vapor/vapor-sql-kit.dockerfile
  72. 2 2
      frameworks/Swift/vapor/vapor.dockerfile

+ 1 - 0
frameworks/Swift/hummingbird-core/.gitignore → frameworks/Swift/.gitignore

@@ -5,3 +5,4 @@ xcuserdata/
 .swiftpm/
 DerivedData/
 Package.resolved
+.vscode/

+ 2 - 1
frameworks/Swift/README.md

@@ -8,4 +8,5 @@ For further guidance, review the [documentation](https://frameworkbenchmarks.rea
 
 ### Swift Experts
 
-[tanner0101](https://github.com/tanner0101)
+[Adam Fowler](https://github.com/adam-fowler)
+[Tim Condon](https://github.com/0xTim)

+ 1 - 1
frameworks/Swift/hummingbird-core/benchmark_config.json

@@ -18,7 +18,7 @@
         "database_os": "Linux",
         "display_name": "HummingbirdCore",
         "notes": "",
-        "versus": "None"
+        "versus": "swift-nio"
       }
     }]
 }

+ 2 - 2
frameworks/Swift/hummingbird-core/hummingbird-core.dockerfile

@@ -1,7 +1,7 @@
 # ================================
 # Build image
 # ================================
-FROM swift:5.9 as build
+FROM swift:5.10 as build
 WORKDIR /build
 
 # Copy entire repo into container
@@ -15,7 +15,7 @@ RUN swift build \
 # ================================
 # Run image
 # ================================
-FROM swift:5.9-slim
+FROM swift:5.10-slim
 WORKDIR /run
 
 # Copy build artifacts

+ 0 - 7
frameworks/Swift/hummingbird/.gitignore

@@ -1,7 +0,0 @@
-.DS_Store
-.build/
-/*.xcodeproj
-xcuserdata/
-.swiftpm/
-DerivedData/
-Package.resolved

+ 1 - 1
frameworks/Swift/hummingbird/benchmark_config.json

@@ -18,7 +18,7 @@
         "database_os": "Linux",
         "display_name": "Hummingbird",
         "notes": "",
-        "versus": "None"
+        "versus": "swift-nio"
       },
       "postgres": {
         "db_url": "/db",

+ 2 - 2
frameworks/Swift/hummingbird/hummingbird-postgres.dockerfile

@@ -1,7 +1,7 @@
 # ================================
 # Build image
 # ================================
-FROM swift:5.9 as build
+FROM swift:5.10 as build
 WORKDIR /build
 
 # Copy entire repo into container
@@ -15,7 +15,7 @@ RUN swift build \
 # ================================
 # Run image
 # ================================
-FROM swift:5.9-slim
+FROM swift:5.10-slim
 WORKDIR /run
 
 # Copy build artifacts

+ 2 - 2
frameworks/Swift/hummingbird/hummingbird.dockerfile

@@ -1,7 +1,7 @@
 # ================================
 # Build image
 # ================================
-FROM swift:5.9 as build
+FROM swift:5.10 as build
 WORKDIR /build
 
 # Copy entire repo into container
@@ -15,7 +15,7 @@ RUN swift build \
 # ================================
 # Run image
 # ================================
-FROM swift:5.9-slim
+FROM swift:5.10-slim
 WORKDIR /run
 
 # Copy build artifacts

+ 0 - 6
frameworks/Swift/kitura/.gitignore

@@ -1,6 +0,0 @@
-.DS_Store
-.build
-build_gcd
-.swiftenv
-Packages
-*.xcodeproj

+ 0 - 1
frameworks/Swift/kitura/.swift-version

@@ -1 +0,0 @@
-4.1.2

+ 0 - 51
frameworks/Swift/kitura/Package.swift

@@ -1,51 +0,0 @@
-// swift-tools-version:4.0
-// The swift-tools-version declares the minimum version of Swift required to build this package.
-
-import PackageDescription
-
-let package = Package(
-    name: "Kitura-TechEmpower",
-    dependencies: [
-        .package(url: "https://github.com/IBM-Swift/Kitura.git", .upToNextMinor(from: "2.6.0")),
-        .package(url: "https://github.com/IBM-Swift/LoggerAPI.git", from: "1.8.0"),
-        .package(url: "https://github.com/IBM-Swift/HeliumLogger.git", from: "1.8.0"),
-        .package(url: "https://github.com/IBM-Swift/Configuration.git", from: "3.0.0"),
-        .package(url: "https://github.com/IBM-Swift/Swift-Kuery-PostgreSQL.git", from: "2.0.0"),
-        .package(url: "https://github.com/IBM-Swift/Swift-Kuery-ORM.git", from: "0.4.0"),
-        .package(url: "https://github.com/IBM-Swift/Kitura-StencilTemplateEngine.git", from: "1.9.0"),
-        .package(url: "https://github.com/IBM-Swift/Kitura-MustacheTemplateEngine.git", from: "1.7.2"),
-        .package(url: "https://github.com/OpenKitten/MongoKitten.git", from: "4.1.3"),
-    ],
-    targets: [
-        .target(
-            name: "TechEmpowerCommon",
-            dependencies: []),
-        .target(
-            name: "KueryPostgres",
-            dependencies: [.target(name: "TechEmpowerCommon"), "Configuration", "SwiftKueryPostgreSQL"]),
-        .target(
-            name: "KueryPostgresRaw",
-            dependencies: [.target(name: "KueryPostgres"), "LoggerAPI"]),
-        .target(
-            name: "KueryPostgresORM",
-            dependencies: [.target(name: "KueryPostgres"), "LoggerAPI", "SwiftKueryORM"]),
-        .target(
-            name: "TechEmpower",
-            dependencies: ["Kitura"]),
-        .target(
-            name: "TechEmpowerPostgres",
-            dependencies: [.target(name: "KueryPostgresRaw"), "Kitura", "HeliumLogger", "KituraStencil"]),
-        .target(
-            name: "TechEmpowerPostgresORM",
-            dependencies: [.target(name: "KueryPostgresORM"), "Kitura", "HeliumLogger", "KituraStencil"]),
-        .target(
-            name: "TechEmpowerPostgresORMCodable",
-            dependencies: [.target(name: "KueryPostgresORM"), "Kitura", "HeliumLogger", "KituraStencil"]),
-        .target(
-            name: "TechEmpowerPostgresMustache",
-            dependencies: [.target(name: "KueryPostgresRaw"), "Kitura", "HeliumLogger", "KituraMustache"]),
-        .target(
-            name: "TechEmpowerMongoKitten",
-            dependencies: [.target(name: "TechEmpowerCommon"), "Kitura", "HeliumLogger", "Configuration", "MongoKitten", "KituraStencil"]),
-    ]
-)

+ 0 - 56
frameworks/Swift/kitura/README.md

@@ -1,56 +0,0 @@
-# [Kitura](https://kitura.io) Benchmark Test
-
-This is the [Kitura](https://kitura.io) portion of a [benchmarking test suite](https://www.techempower.com/benchmarks/) comparing a variety of web development platforms.
-
-## Variants
-
-The benchmark is split up into multiple executable targets, demonstrating different database backends and uses of the Kitura routing APIs:
-- `kitura`: Implementations of Plaintext and JSON using 'raw' (Express-style) routing
-- `kitura-postgres`: Implementation of database tests, using Postgres with Swift-Kuery (no ORM)
-- `kitura-postgres-orm`: Equivalent implementation with Postgres and Swift-Kuery-ORM
-- `kitura-postgres-orm-codable`: Equivalent implementation with Postgres, using [Codable Routing together with Swift-Kuery-ORM](https://developer.ibm.com/swift/2018/03/01/introducing-swift-kuery-orm/)
-- `kitura-mongodb`: Implementation of database tests, using MongoDB with MongoKitten (no ORM)
-- `kitura-nio`: `kitura` implementations of Plaintext and JSON run on [Kitura-NIO](https://github.com/IBM-Swift/Kitura-NIO)
-- `kitura-nio-postgres`: Testing `kitura` implementations of database tests using Postgres on [Kitura-NIO](https://github.com/IBM-Swift/Kitura-NIO)
-
-There are additional variants for each of the above implementations, with the '-gcd' suffix: These are compiled from the same source, but use the Grand Central Dispatch threading model (used by default on macOS) instead of a direct epoll implementation (the default on Linux).
-
-Each listens on port 8080, and uses the common URLs described below.
-
-## Versions and Dependencies
-
-This version of the benchmark requires Swift 4.0.3 or higher, and uses the following versions of Kitura and dependencies:
-
-- [Kitura 2.5](https://github.com/IBM-Swift/Kitura)
-- [HeliumLogger 1.x](https://github.com/IBM-Swift/HeliumLogger)
-- [Configuration 3.x](https://github.com/IBM-Swift/Configuration)
-- [SwiftKueryPostgreSQL 1.x](https://github.com/IBM-Swift/Swift-Kuery-PostgreSQL)
-- [SwiftKueryORM 0.x](https://github.com/IBM-Swift/Swift-Kuery-ORM)
-- [KituraStencil 1.x](https://github.com/IBM-Swift/Kitura-StencilTemplateEngine)
-- [KituraMustache 1.x](https://github.com/IBM-Swift/Kitura-MustacheTemplateEngine)
-- [MongoKitten 4.x](https://github.com/OpenKitten/MongoKitten)
-
-## Test URLs
-### JSON serialization
-
-http://localhost:8080/json
-
-### Single database query
-
-http://localhost:8080/db
-
-### Multiple database queries
-
-http://localhost:8080/queries?queries=n
-
-### Fortunes
-
-http://localhost:8080/fortunes
-
-### Database updates
-
-http://localhost:8080/updates?queries=n
-
-### Plaintext
-
-http://localhost:8080/plaintext

+ 0 - 42
frameworks/Swift/kitura/Sources/KueryPostgres/Postgres.swift

@@ -1,42 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Foundation
-import SwiftKuery
-import SwiftKueryPostgreSQL
-import Configuration
-
-#if os(Linux)
-    import Glibc
-#else
-    import Darwin
-#endif
-
-// We will load our database configuration from config.json, but this can be
-// overridden with the TFB_DB_CONFIG environment variable.
-let configurationFilename: String = ProcessInfo.processInfo.environment["TFB_DB_CONFIG"] ?? "config.json"
-let manager = ConfigurationManager().load(file: configurationFilename, relativeFrom: .pwd).load(.environmentVariables)
-
-let dbHost = manager["DB_HOST"] as? String ?? manager["db:host"] as? String ?? "localhost"
-let dbPort = Int32(manager["DB_PORT"] as? String != nil ? Int(manager["DB_PORT"] as! String) ?? 5432 : manager["db:port"] as? Int ?? 5432)
-let dbName = manager["db:name"] as? String ?? "hello_world"
-let dbUser = manager["db:user"] as? String ?? "benchmarkdbuser"
-let dbPass = manager["db:password"] as? String ?? "benchmarkdbpass"
-
-let dbConnPoolOpts = ConnectionPoolOptions(initialCapacity: 20, maxCapacity: 50)
-
-public let dbConnPool = PostgreSQLConnection.createPool(host: dbHost, port: dbPort, options: [.databaseName(dbName), .userName(dbUser), .password(dbPass)], poolOptions: dbConnPoolOpts)
-

+ 0 - 223
frameworks/Swift/kitura/Sources/KueryPostgresORM/PostgresORM.swift

@@ -1,223 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Foundation
-import Dispatch
-import LoggerAPI
-import SwiftKuery
-import SwiftKueryORM
-import KueryPostgres
-import TechEmpowerCommon
-
-// ORM conformance
-extension RandomRow: Model {
-    public static var tableName: String { return "world" }
-}
-
-// ORM conformance
-extension Fortune: Model {
-    public static var tableName: String { return "fortune" }
-}
-
-// Configure our ORM Database connection pool as dbConnPool created by KueryPostgres
-public func setupORM() {
-    Database.default = Database(dbConnPool)
-}
-
-/// Get a list of Fortunes from the database.
-///
-/// - Parameter callback: The callback that will be invoked once the DB query
-///                       has completed and results are available, passing an
-///                       optional [Fortune] (on success) or RequestError on
-///                       failure.
-///
-public func getFortunes(callback: @escaping ([Fortune]?, RequestError?) -> Void) -> Void {
-    Fortune.findAll { (fortunes, err) in
-        if let err = err {
-            return callback(nil, err)
-        } else {
-            callback(fortunes, nil)
-        }
-    }
-}
-
-/// Get a random row (range 1 to 10,000) from the database.
-///
-/// - Parameter callback: The callback that will be invoked once the DB query
-///                       has completed and results are available, passing an
-///                       optional RandomRow (on success) or RequestError on
-///                       failure.
-///
-public func getRandomRow(callback: @escaping (RandomRow?, RequestError?) -> Void) -> Void {
-    // Select random row from database range
-    let rnd = RandomRow.randomId
-    RandomRow.find(id: rnd, callback)
-}
-
-/// Updates a row of World to a new value.
-///
-/// - Parameter callback: The callback that will be invoked once the DB update
-///                       has completed, passing an optional RequestError if the
-///                       update failed.
-///
-public func updateRow(id: Int, callback: @escaping (RequestError?) -> Void) -> Void {
-    // Generate a random number for this row
-    let row = RandomRow(id: id, randomNumber: RandomRow.randomValue)
-    row.update(id: id) { (resultRow, err) in
-        if let err = err {
-            return callback(err)
-        } else {
-            callback(nil)
-        }
-    }
-}
-
-/// Get `count` random rows from the database, and pass the resulting array
-/// to a completion handler (or a RequestError, in the event that a row could
-/// not be retrieved).
-///
-/// - Parameter count: The number of rows to retrieve
-/// - Parameter result: The intermediate result array being built
-/// - Parameter completion: The closure to invoke with the result array, or error
-///
-public func getRandomRows(count: Int, result: [RandomRow] = [], completion: @escaping ([RandomRow]?, RequestError?) -> Void) {
-    if count > 0 {
-        // Select random row from database range
-        RandomRow.find(id: RandomRow.randomId) { (resultRow, err) in
-            if let resultRow = resultRow {
-                var result = result
-                result.append(resultRow)
-                getRandomRows(count: count-1, result: result, completion: completion)
-            } else {
-                if let err = err {
-                    completion(nil, err)
-                } else {
-                    fatalError("Unexpected: result and error both nil")
-                }
-            }
-        }
-    } else {
-        completion(result, nil)
-    }
-}
-
-/// A parallel version of `getRandomRows` that invokes each get in parallel, builds an
-/// array of results and waits for each get to complete before returning.
-///
-/// - Parameter count: The number of rows to retrieve
-/// - Parameter completion: The closure to invoke with the result array, or error
-///
-public func getRandomRowsParallel(count: Int, completion: @escaping ([RandomRow]?, RequestError?) -> Void) {
-    var results: [RandomRow] = []
-    guard count > 0 else {
-        return completion(results, nil)
-    }
-    // Used to protect result array from concurrent modification
-    let updateLock = DispatchSemaphore(value: 1)
-    // Execute each query. Each callback will append its result to `results`
-    for _ in 1...count {
-        RandomRow.find(id: RandomRow.randomId) { (resultRow, err) in
-            guard let resultRow = resultRow else {
-                Log.error("\(err ?? .internalServerError)")
-                completion(nil, err ?? .internalServerError)
-                return
-            }
-            updateLock.wait()
-            results.append(resultRow)
-            if results.count == count {
-                completion(results, nil)
-            }
-            updateLock.signal()
-        }
-    }
-}
-
-/// Update and retrieve `count` random rows from the database, and pass the
-/// resulting array to a completion handler (or a RequestError, in the event
-/// that a row could not be retrieved or updated).
-///
-/// - Parameter count: The number of rows to retrieve
-/// - Parameter result: The intermediate result array being built
-/// - Parameter completion: The closure to invoke with the result array, or error
-///
-public func updateRandomRows(count: Int, result: [RandomRow] = [], completion: @escaping ([RandomRow]?, RequestError?) -> Void) {
-    if count > 0 {
-        // Select random row from database range
-        RandomRow.find(id: RandomRow.randomId) { (resultRow, err) in
-            if let resultRow = resultRow {
-                var result = result
-                let row = RandomRow(id: resultRow.id, randomNumber: RandomRow.randomValue)
-                row.update(id: row.id) { (resultRow, err) in
-                    if let resultRow = resultRow {
-                        result.append(resultRow)
-                        updateRandomRows(count: count-1, result: result, completion: completion)
-                    } else {
-                        completion(nil, err)
-                    }
-                }
-            } else {
-                if let err = err {
-                    completion(nil, err)
-                } else {
-                    fatalError("Unexpected: result and error both nil")
-                }
-            }
-        }
-    } else {
-        completion(result, nil)
-    }
-}
-
-/// A parallel version of `updateRandomRows` that invokes each get/update operation
-/// in parallel, builds an array of results and waits for each get to complete before
-/// returning.
-///
-/// - Parameter count: The number of rows to retrieve
-/// - Parameter completion: The closure to invoke with the result array, or error
-///
-public func updateRandomRowsParallel(count: Int, completion: @escaping ([RandomRow]?, RequestError?) -> Void) {
-    var results: [RandomRow] = []
-    guard count > 0 else {
-        return completion(results, nil)
-    }
-    // Used to protect result array from concurrent modification
-    let updateLock = DispatchSemaphore(value: 1)
-    // Execute each query. Each callback will append its result to `results`
-    for _ in 1...count {
-        RandomRow.find(id: RandomRow.randomId) { (resultRow, err) in
-            guard let resultRow = resultRow else {
-                Log.error("\(err ?? .internalServerError)")
-                completion(nil, err ?? .internalServerError)
-                return
-            }
-            let row = RandomRow(id: resultRow.id, randomNumber: RandomRow.randomValue)
-            row.update(id: row.id) { (resultRow, err) in
-                if let resultRow = resultRow {
-                    updateLock.wait()
-                    results.append(resultRow)
-                    if results.count == count {
-                        completion(results, nil)
-                    }
-                    updateLock.signal()
-                } else {
-                    Log.error("\(err ?? .internalServerError)")
-                    completion(nil, err ?? .internalServerError)
-                    return
-                }
-            }
-        }
-    }
-}

+ 0 - 285
frameworks/Swift/kitura/Sources/KueryPostgresRaw/PostgresRaw.swift

@@ -1,285 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Foundation
-import LoggerAPI
-import SwiftKuery
-import KueryPostgres
-import TechEmpowerCommon
-
-let dbRows = 10000
-let maxValue = 10000
-
-// Kuery table definition for World
-class World: Table {
-    let tableName = "world"
-    
-    let id = Column("id")
-    let randomNumber = Column("randomnumber")
-}
-
-// Kuery table definition for Fortune
-class Fortunes: Table {
-    let tableName = "fortune"
-
-    let id = Column("id")
-    let message = Column("message")
-}
-
-let world = World()
-let fortunes = Fortunes()
-
-// Kuery update statement for Updates
-var update = Update(world, set: [(world.randomNumber, RandomRow.randomValue)])
-    .where(world.id == RandomRow.randomId)
-
-/// Get a list of Fortunes from the database.
-///
-/// - Parameter callback: The callback that will be invoked once the DB query
-///                       has completed and results are available, passing an
-///                       optional [Fortune] (on success) or AppError on
-///                       failure.
-///
-public func getFortunes(callback: @escaping ([Fortune]?, AppError?) -> Void) -> Void {
-    // Get a dedicated connection object for this transaction from the pool
-    dbConnPool.getConnection { (dbConn, dbConnErr) in
-        guard let dbConn = dbConn else {
-            guard let err = dbConnErr else {
-                return callback(nil, AppError.OtherError("Unknown error getting connection from pool"))
-            }
-            return callback(nil, AppError.OtherError("Error getting connection from pool: \(err)"))
-        }
-        // Initiate database query
-        let query = Select(from: fortunes)
-        dbConn.execute(query: query) { result in
-            var resultFortunes: [Fortune] = []
-            // Retrieve all rows from the query result
-            result.asRows {
-                results, err in
-                guard let results = results else {
-                    guard let err = err else {
-                        return callback(nil, AppError.DBKueryError("Query failed, and no error was returned"))
-                    }
-                    return callback(nil, AppError.DBKueryError("Query failed: \(err)"))
-                }
-                do {
-                    // Transform the result rows into an array of Fortune objects
-                    resultFortunes = try results.map { try Fortune.init(row: $0) }
-                } catch {
-                    return callback(nil, AppError.DataFormatError("\(error)"))
-                }
-                // Invoke callback with results
-                callback(resultFortunes, nil)
-            }
-        }
-    }
-}
-
-/// Alternate implementation of getFortunes that uses ResultSet.forEach to fetch each
-/// database row sequentially, rather than QueryResult.asRows (which produces an array
-/// of rows). The benefit of forEach is that we do not need to hold two copies of the
-/// entire result set in memory.
-///
-/// - Parameter callback: The callback that will be invoked once the DB query
-///                       has completed and results are available, passing an
-///                       optional [Fortune] (on success) or AppError on
-///                       failure.
-///
-public func getFortunes_forEach(callback: @escaping ([Fortune]?, AppError?) -> Void) -> Void {
-    // Get a dedicated connection object for this transaction from the pool
-    dbConnPool.getConnection { (dbConn, dbConnErr) in
-        guard let dbConn = dbConn else {
-            guard let err = dbConnErr else {
-                return callback(nil, AppError.OtherError("Unknown error getting connection from pool"))
-            }
-            return callback(nil, AppError.OtherError("Error getting connection from pool: \(err)"))
-        }
-        // Initiate database query
-        let query = Select(from: fortunes)
-        dbConn.execute(query: query) { result in
-            var resultFortunes: [Fortune] = []
-            guard let results = result.asResultSet else {
-                guard let queryErr = result.asError else {
-                    return callback(nil, AppError.DBKueryError("Expected a result set, but result was \(result)"))
-                }
-                return callback(nil, AppError.DBKueryError("Query failed: \(queryErr)"))
-            }
-            // Build an array of Fortune objects
-            results.forEach { (values, rowErr, next) in
-                guard let values = values else {
-                    // Reached the final row - call back with the results
-                    return callback(resultFortunes, nil)
-                }
-                // Append this Fortune to the list
-                do {
-                    resultFortunes.append(try Fortune(values: values))
-                    // Process the next column
-                    next()
-                } catch {
-                    return callback(nil, AppError.DataFormatError("\(error)"))
-                }
-            }
-        }
-    }
-}
-
-/// Get a random row (range 1 to 10,000) from the database.
-///
-/// - Parameter callback: The callback that will be invoked once the DB query
-///                       has completed and results are available, passing an
-///                       optional RandomRow (on success) or AppError on
-///                       failure.
-///
-public func getRandomRow_Raw(callback: @escaping (RandomRow?, AppError?) -> Void) -> Void {
-    // Get a dedicated connection object for this transaction from the pool
-    dbConnPool.getConnection { (dbConn, dbConnErr) in
-        guard let dbConn = dbConn else {
-            guard let dbConnErr = dbConnErr else {
-                return callback(nil, AppError.OtherError("Unknown error getting connection from pool"))
-            }
-            return callback(nil, AppError.OtherError("Error getting connection from pool: \(dbConnErr)"))
-        }
-        // Select random row from database range
-        let rnd = RandomRow.randomId
-        let query = Select(world.randomNumber, from: world)
-            .where(world.id == rnd)
-        // Initiate database query
-        dbConn.execute(query: query) { result in
-            guard let resultSet = result.asResultSet else {
-                guard let queryErr = result.asError else {
-                    return callback(nil, AppError.DBKueryError("Expected a result set, but result was \(result)"))
-                }
-                return callback(nil, AppError.DBKueryError("Query failed: \(queryErr)"))
-            }
-            resultSet.nextRow {
-                values, nextErr in
-                guard let values = values else {
-                    guard let nextErr = nextErr else {
-                        return callback(nil, AppError.DBKueryError("Query failed, and no error was returned"))
-                    }
-                    return callback(nil, AppError.DBKueryError("Query failed: \(nextErr)"))
-                }
-                // There should be exactly one value
-                guard values.count == 1 else {
-                    return callback(nil, AppError.DBKueryError("\(values.count) values returned, expected 1, for query '\(query)'"))
-                }
-                // The value should be an Int32
-                guard let randomNumber = values[0] as? Int32 else {
-                    return callback(nil, AppError.DBKueryError("Could not convert \(String(describing: values[0])) to Int32"))
-                }
-                let resultRow = RandomRow(id: rnd, randomNumber: Int(randomNumber))
-                // Invoke callback with results
-                callback(resultRow, nil)
-            }
-        }
-    }
-}
-
-/// Updates a row of World to a new value.
-///
-/// - Parameter callback: The callback that will be invoked once the DB update
-///                       has completed, passing an optional AppError if the
-///                       update failed.
-///
-public func updateRow_Raw(id: Int, callback: @escaping (AppError?) -> Void) -> Void {
-    // Get a dedicated connection object for this transaction from the pool
-    dbConnPool.getConnection { (dbConn, err) in
-        guard let dbConn = dbConn else {
-            guard let err = err else {
-                return callback(AppError.OtherError("Unknown error getting connection from pool"))
-            }
-            return callback(AppError.OtherError("Error getting connection from pool: \(err)"))
-        }
-        // Generate a random number for this row
-        let rndValue = RandomRow.randomValue
-        let query = Update(world, set: [(world.randomNumber, rndValue)])
-            .where(world.id == id)
-        // Initiate database query
-        dbConn.execute(query: query) { result in
-            guard result.success else {
-                return callback(AppError.DBKueryError("Update failed: \(String(describing: result.asError))"))
-            }
-            // Invoke callback once done
-            callback(nil)
-        }
-    }
-}
-
-/// Get `count` random rows from the database, and pass the resulting array
-/// to a completion handler (or an AppError, in the event that a row could
-/// not be retrieved).
-///
-/// - Parameter count: The number of rows to retrieve
-/// - Parameter result: The intermediate result array being built
-/// - Parameter completion: The closure to invoke with the result array, or error
-///
-public func getRandomRows_Raw(count: Int, result: [RandomRow] = [], completion: @escaping ([RandomRow]?, AppError?) -> Void) {
-    if count > 0 {
-        // Select random row from database range
-        getRandomRow_Raw { (resultRow, err) in
-            if let resultRow = resultRow {
-                var result = result
-                result.append(resultRow)
-                // Call recursively to get remaining rows
-                getRandomRows_Raw(count: count-1, result: result, completion: completion)
-            } else {
-                if let err = err {
-                    completion(nil, err)
-                } else {
-                    fatalError("Unexpected: result and error both nil")
-                }
-            }
-        }
-    } else {
-        completion(result, nil)
-    }
-}
-
-/// Update and retrieve `count` random rows from the database, and pass the
-/// resulting array to a completion handler (or an AppError, in the event
-/// that a row could not be retrieved or updated).
-///
-/// - Parameter count: The number of rows to retrieve
-/// - Parameter result: The intermediate result array being built
-/// - Parameter completion: The closure to invoke with the result array, or error
-///
-public func updateRandomRows_Raw(count: Int, result: [RandomRow] = [], completion: @escaping ([RandomRow]?, AppError?) -> Void) {
-    if count > 0 {
-        // Select random row from database range
-        getRandomRow_Raw { (resultRow, err) in
-            if let resultRow = resultRow {
-                var result = result
-                // Execute inner callback for updating the row
-                updateRow_Raw(id: resultRow.id) { (err) in
-                    if let err = err {
-                        return completion(nil, err)
-                    }
-                    result.append(resultRow)
-                    // Call recursively to update remaining rows
-                    updateRandomRows_Raw(count: count-1, result: result, completion: completion)
-                }
-            } else {
-                if let err = err {
-                    completion(nil, err)
-                } else {
-                    fatalError("Unexpected: result and error both nil")
-                }
-            }
-        }
-    } else {
-        completion(result, nil)
-    }
-}

+ 0 - 44
frameworks/Swift/kitura/Sources/TechEmpower/main.swift

@@ -1,44 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Foundation
-import Kitura
-import TechEmpowerCommon
-
-let router = Router()
-
-//
-// TechEmpower test 6: plaintext
-//
-router.get("/plaintext") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    response.headers["Content-Type"] = "text/plain"
-    try response.status(.OK).send("Hello, world!").end()
-}
-
-//
-// TechEmpower test 1: JSON serialization
-//
-router.get("/json") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    let result = ["message":"Hello, World!"]
-    try response.status(.OK).send(json: result).end()
-}
-
-Kitura.addHTTPServer(onPort: 8080, with: router)
-Kitura.run()

+ 0 - 35
frameworks/Swift/kitura/Sources/TechEmpowerCommon/Error.swift

@@ -1,35 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/// Represents various errors that can occur with the Kitura TechEmpower benchmark.
-public enum AppError: Error {
-
-    /// An error occurring when executing a raw SQL query against a database.
-    case DBError(String, query: String)
-
-    /// An error occurring when executing a Kuery operation against a database.
-    case DBKueryError(String)
-
-    /// An error occurring when the format of the data retrieved by a database
-    /// operation was not as expected.
-    case DataFormatError(String)
-
-    /// An error occurring when a connection to the database cannot be established.
-    case ConnectionError(String)
-
-    /// Any other type of error
-    case OtherError(String)
-}

+ 0 - 90
frameworks/Swift/kitura/Sources/TechEmpowerCommon/Fortune.swift

@@ -1,90 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Foundation
-
-public struct Fortune: Codable {
-
-    /// The id of this Fortune
-    public let id: Int
-
-    /// The message contained within this Fortune
-    public let message: String
-
-    public init(id: Int, message: String) {
-        self.id = id
-        self.message = message
-    }
-
-    /// Create a Fortune instance from a [String: Any?] dictionary,
-    /// such as that retrieved by Kuery using `QueryResult.asRows()`.
-    ///
-    /// - Parameter row: A dictionary representing the fields of a
-    ///                  Fortune database row.
-    /// - throws: if the fields and types contained in the dictionary
-    ///           do not match those expected.
-    public init(row: [String:Any?]) throws {
-        guard let idField = row["id"] else {
-            throw AppError.DataFormatError("Missing 'id' field")
-        }
-        guard let msgField = row["message"] else {
-            throw AppError.DataFormatError("Missing 'message' field")
-        }
-        guard let message = msgField as? String else {
-            throw AppError.DataFormatError("'message' field not a String")
-        }
-        guard let id = idField as? Int32 else {
-            throw AppError.DataFormatError("'id' field not an Int32")
-        }
-        self.init(id: Int(id), message: message)
-    }
-
-    /// Create a Fortune instance from an [Any?] array, such as that retrieved
-    /// by Kuery using `ResultSet.forEach()`.
-    ///
-    /// - Parameter row: An array representing the fields of a Fortune
-    ///                  database row.
-    /// - throws: if the fields and types contained in the array do not match
-    ///           those expected.
-    public init(values: [Any?]) throws {
-        // There should be two columns
-        guard values.count == 2 else {
-            throw AppError.DBKueryError("Expected 2 values but found \(values.count)")
-        }
-        // First should be an Int32
-        guard let id = values[0] as? Int32 else {
-            throw AppError.DataFormatError("Fortune id '\(String(describing: values[0]))' is not an Int")
-        }
-        // Second should be a String
-        guard let msg = values[1] as? String else {
-            throw AppError.DataFormatError("Fortune message '\(String(describing: values[1]))' is not a String")
-        }
-        self.init(id: Int(id), message: msg)
-    }
-
-}
-
-extension Fortune: Comparable {
-
-    public static func == (lhs: Fortune, rhs: Fortune) -> Bool {
-        return lhs.id == rhs.id && lhs.message == rhs.message
-    }
-
-    public static func < (lhs: Fortune, rhs: Fortune) -> Bool {
-        return lhs.message < rhs.message || (lhs.message == rhs.message && lhs.id < rhs.id)
-    }
-
-}

+ 0 - 70
frameworks/Swift/kitura/Sources/TechEmpowerCommon/RandomRow.swift

@@ -1,70 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Foundation
-
-// Return a random number within the range of rows in the database
-private func randomNumberGenerator(_ maxVal: Int) -> Int {
-    #if os(Linux)
-    return Int(random() % maxVal) + 1
-    #else
-    return Int(arc4random_uniform(UInt32(maxVal))) + 1
-    #endif
-}
-
-public struct RandomRow: Codable {
-
-    /// The number of rows in the World table
-    public static let dbRows = 10000
-
-    /// The maximum value for randomNumber
-    public static let maxValue = 10000
-
-    /// A generated random row id suitable for retrieving
-    /// or creating a RandomRow instance.
-    public static var randomId: Int {
-        return randomNumberGenerator(dbRows)
-    }
-
-    /// A generated random value suitable for assigning as the
-    /// `randomNumber` for a RandomRow instance.
-    public static var randomValue: Int {
-        return randomNumberGenerator(maxValue)
-    }
-
-    /// The id for this RandomRow, ranging from 1 to dbRows
-    public let id: Int
-
-    /// A random number ranging from 1 to maxValue
-    public let randomNumber: Int
-
-    public init(id: Int, randomNumber: Int) {
-        self.id = id
-        self.randomNumber = randomNumber
-    }
-
-    /// Map the properties of this type to their corresponding database
-    /// column names (required by the ORM).
-    enum CodingKeys: String, CodingKey {
-        case id
-        case randomNumber = "randomnumber"
-    }
-
-    /// Returns a JSON-convertible dictionary representation of this RandomRow.
-    public func asDictionary() -> [String: Int] {
-        return ["id": self.id, "randomNumber": self.randomNumber]
-    }
-}

+ 0 - 123
frameworks/Swift/kitura/Sources/TechEmpowerMongoKitten/Mongo.swift

@@ -1,123 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Foundation
-import LoggerAPI
-import Configuration
-import MongoKitten
-import TechEmpowerCommon
-
-#if os(Linux)
-    import Glibc
-#else
-    import Darwin
-#endif
-
-public enum MongoAppError: Error {
-    case MongoError(String)
-}
-
-// We will load our database configuration from config.json, but this can be
-// overridden with the TFB_DB_CONFIG environment variable.
-let configurationFilename: String = ProcessInfo.processInfo.environment["TFB_DB_CONFIG"] ?? "config.json"
-let manager = ConfigurationManager().load(file: configurationFilename, relativeFrom: .pwd).load(.environmentVariables)
-
-let dbHost = manager["DB_HOST"] as? String ?? manager["mongodb:host"] as? String ?? "localhost"
-let dbPort = Int32(manager["DB_PORT"] as? String != nil ? Int(manager["DB_PORT"] as! String) ?? 27017 : manager["mongodb:port"] as? Int ?? 27017)
-let dbName = manager["mongodb:name"] as? String ?? "hello_world"
-let dbUser = manager["mongodb:user"] as? String ?? "benchmarkdbuser"
-let dbPass = manager["mongodb:password"] as? String ?? "benchmarkdbpass"
-
-let dbRows = 10000
-let maxValue = 10000
-
-var myDatabase: MongoKitten.Database?
-var world: MongoKitten.Collection?
-var fortune: MongoKitten.Collection?
-
-func connectToDB() throws {
-    let connectString = "mongodb://\(dbHost):\(dbPort)/\(dbName)"
-    Log.info("Connect string = \(connectString)")
-    //myDatabase = try MongoKitten.Database("mongodb://\(dbUser):\(dbPass)@\(dbHost):\(dbPort)/\(dbName)")
-    myDatabase = try MongoKitten.Database(connectString)
-    guard let myDatabase = myDatabase else {
-        throw AppError.ConnectionError("Nil MongoDB connection to \(connectString)")
-    }
-    guard myDatabase.server.isConnected else {
-        throw AppError.ConnectionError("Not connected to \(connectString)")
-    }
-    world = myDatabase["world"]
-    fortune = myDatabase["fortune"]
-}
-
-// Allow construction of a Fortune from a MongoKitten Document
-extension Fortune {
-    init(document: Document) throws {
-        if let id = Int(document["_id"]), let message = String(document["message"]) {
-            self.init(id: id, message: message)
-        } else {
-            throw AppError.DataFormatError("Expected fields of Fortune document could not be retreived")
-        }
-    }
-}
-
-func getFortunes() throws -> [Fortune] {
-    guard let fortune = fortune else {
-        throw MongoAppError.MongoError("Fortune collection not initialized")
-    }
-    
-//    let allFortunes: [Document] = Array(try fortune.find())
-    let allFortunes = try fortune.find()
-    let resultFortunes: [Fortune] = try allFortunes.map { try Fortune.init(document: $0) }
-    return resultFortunes
-}
-
-// Get a random row (range 1 to 10,000) from DB: id(int),randomNumber(int)
-// Convert to object using object-relational mapping (ORM) tool
-// Serialize object to JSON - example: {"id":3217,"randomNumber":2149}
-func getRandomRow() throws -> [String:Int] {
-    guard let world = world else {
-        throw MongoAppError.MongoError("World collection not initialized")
-    }
-
-    let rnd = RandomRow.randomId
-    let result = try world.findOne("_id" == rnd)
-    guard let document = result else {
-        throw AppError.DataFormatError("World entry id=\(rnd) not found")
-    }
-    guard let id = Int(document["_id"]), let randomNumber = Int(document["randomNumber"]) else {
-        throw AppError.DataFormatError("Expected fields of World document could not be retreived")
-    }
-    return ["id":id, "randomNumber":Int(randomNumber)]
-}
-
-// Updates a row of World to a new value.
-func updateRandomRow() throws -> [String:Int] {
-    guard let world = world else {
-        throw MongoAppError.MongoError("World collection not initialized")
-    }
-    
-    let rnd = RandomRow.randomId
-    let rndValue = RandomRow.randomValue
-    let document = try world.findAndUpdate("_id" == rnd, with: ["randomNumber": rndValue])
-    guard let id = Int(document["_id"]), let randomNumber = Int(document["randomNumber"]) else {
-        throw AppError.DataFormatError("Expected fields of World document could not be retreived")
-    }
-    return ["id":id, "randomNumber":Int(randomNumber)]
-}
-
-
-

+ 0 - 118
frameworks/Swift/kitura/Sources/TechEmpowerMongoKitten/main.swift

@@ -1,118 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Kitura
-import LoggerAPI
-import HeliumLogger
-import MongoKitten
-import KituraStencil
-import Stencil
-//import KituraMustache
-import TechEmpowerCommon
-
-Log.logger = HeliumLogger(.info)
-
-// Stencil stuff
-let ext = Extension()
-
-// Stencil does not yet support automatic HTML escaping:
-// https://github.com/kylef/Stencil/pull/80
-//
-ext.registerFilter("htmlencode") { (value: Any?) in
-    if let value = value as? String {
-        return value
-            .replacingOccurrences(of: "&", with: "&amp;")
-            .replacingOccurrences(of: "<", with: "&lt;")
-            .replacingOccurrences(of: ">", with: "&gt;")
-            .replacingOccurrences(of: "'", with: "&apos;")
-            .replacingOccurrences(of: "\"", with: "&quot;")
-    }
-    return value
-}
-
-let router = Router()
-router.add(templateEngine: StencilTemplateEngine(extension: ext))
-//router.add(templateEngine: MustacheTemplateEngine())
-
-//
-// TechEmpower test 2: Single database query (raw, no ORM)
-//
-router.get("/db") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    let dict = try getRandomRow()
-    try response.status(.OK).send(json: dict).end()
-}
-
-//
-// TechEmpower test 3: Multiple database queries (raw, no ORM)
-// Get param provides number of queries: /queries?queries=N
-//
-router.get("/queries") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    let queriesParam = request.queryParameters["queries"] ?? "1"
-    let numQueries = max(1, min(Int(queriesParam) ?? 1, 500))      // Snap to range of 1-500 as per test spec
-    var results: [[String:Int]] = []
-    for _ in 1...numQueries {
-        let dict = try getRandomRow()
-        results.append(dict)
-    }
-    // Return JSON representation of array of results
-    try response.status(.OK).send(json: results).end()
-}
-
-//
-// TechEmpower test 4: fortunes (raw, no ORM)
-//
-router.get("/fortunes") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    response.headers["Content-Type"] = "text/html; charset=UTF-8"
-    var fortunes = try getFortunes()
-    fortunes.append(Fortune(id: 0, message: "Additional fortune added at request time."))
-
-    try response.render("fortunes.stencil", context: ["fortunes": fortunes.sorted()]).end()
-    //try response.render("fortunes.mustache", context: ["fortunes": fortunes.sorted()]).end()
-}
-
-//
-// TechEmpower test 5: updates (raw, no ORM)
-//
-router.get("/updates") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    let queriesParam = request.queryParameters["queries"] ?? "1"
-    let numQueries = max(1, min(Int(queriesParam) ?? 1, 500))      // Snap to range of 1-500 as per test spec
-    var results: [[String:Int]] = []
-    for _ in 1...numQueries {
-        let dict = try updateRandomRow()
-        results.append(dict)
-    }
-    
-    // Return JSON representation of array of results
-    try response.status(.OK).send(json: results).end()
-}
-
-// Initialize MongoDB connection
-do {
-    try connectToDB()
-} catch {
-    print("Error connecting to database: \(error)")
-}
-
-Kitura.addHTTPServer(onPort: 8080, with: router)
-Kitura.run()

+ 0 - 210
frameworks/Swift/kitura/Sources/TechEmpowerPostgres/main.swift

@@ -1,210 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Foundation
-import Kitura
-import LoggerAPI
-import HeliumLogger
-import KituraStencil
-import Stencil
-import TechEmpowerCommon
-import KueryPostgresRaw
-
-Log.logger = HeliumLogger(.info)
-
-// Stencil stuff
-let ext = Extension()
-
-// Stencil does not yet support automatic HTML escaping:
-// https://github.com/kylef/Stencil/pull/80
-//
-ext.registerFilter("htmlencode") { (value: Any?) in
-    if let value = value as? String {
-        return value
-            .replacingOccurrences(of: "&", with: "&amp;")
-            .replacingOccurrences(of: "<", with: "&lt;")
-            .replacingOccurrences(of: ">", with: "&gt;")
-            .replacingOccurrences(of: "'", with: "&apos;")
-            .replacingOccurrences(of: "\"", with: "&quot;")
-    }
-    return value
-}
-
-let router = Router()
-router.add(templateEngine: StencilTemplateEngine(extension: ext))
-
-//
-// TechEmpower test 2: Single database query (raw, no ORM)
-//
-router.get("/db") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    getRandomRow_Raw { (row, err) in
-        guard let row = row else {
-            guard let err = err else {
-                Log.error("Unknown Error")
-                try? response.status(.badRequest).send("Unknown error").end()
-                return
-            }
-            Log.error("\(err)")
-            try? response.status(.badRequest).send("Error: \(err)").end()
-            return
-        }
-        try? response.status(.OK).send(json: row.asDictionary()).end()
-    }
-}
-
-//
-// TechEmpower test 3: Multiple database queries (raw, no ORM)
-// Get param provides number of queries: /queries?queries=N
-//
-router.get("/queries") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    let queriesParam = request.queryParameters["queries"] ?? "1"
-    let numQueries = max(1, min(Int(queriesParam) ?? 1, 500))      // Snap to range of 1-500 as per test spec
-    getRandomRows_Raw(count: numQueries) { (rows, err) in
-        if let rows = rows {
-            try? response.status(.OK).send(json: rows).end()
-        } else if let err = err {
-            try? response.status(.badRequest).send("Error: \(err)").end()
-        } else {
-            fatalError("Unexpected: rows and err both nil")
-        }
-    }
-}
-
-router.get("/queriesParallel") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    let queriesParam = request.queryParameters["queries"] ?? "1"
-    let numQueries = max(1, min(Int(queriesParam) ?? 1, 500))      // Snap to range of 1-500 as per test spec
-    var results: [[String:Int]] = []
-    // Used to protect result array from concurrent modification
-    let updateLock = DispatchSemaphore(value: 1)
-    // Execute each query. Each callback will append its result to `results`
-    for _ in 1...numQueries {
-        getRandomRow_Raw { (row, err) in
-            guard let row = row else {
-                guard let err = err else {
-                    Log.error("Unknown Error")
-                    try? response.status(.badRequest).send("Unknown error").end()
-                    return
-                }
-                Log.error("\(err)")
-                try? response.status(.badRequest).send("Error: \(err)").end()
-                return
-            }
-            updateLock.wait()
-            results.append(row.asDictionary())
-            if results.count == numQueries {
-                // Return JSON representation of array of results
-                try? response.status(.OK).send(json: results).end()
-            }
-            updateLock.signal()
-        }
-    }
-}
-
-//
-// TechEmpower test 4: fortunes (raw, no ORM)
-//
-router.get("/fortunes") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    response.headers["Content-Type"] = "text/html; charset=UTF-8"
-    getFortunes { (fortunes, err) in
-        guard var fortunes = fortunes else {
-            guard let err = err else {
-                Log.error("Unknown Error")
-                try? response.status(.badRequest).send("Unknown error").end()
-                return
-            }
-            Log.error("\(err)")
-            try? response.status(.badRequest).send("Error: \(err)").end()
-            return
-        }
-        fortunes.append(Fortune(id: 0, message: "Additional fortune added at request time."))
-        do {
-          try response.render("fortunes.stencil", context: ["fortunes": fortunes.sorted()]).end()
-        } catch {
-          print("Error: \(error)")
-        }
-    }
-}
-
-//
-// TechEmpower test 5: updates (raw, no ORM)
-//
-router.get("/updates") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    let queriesParam = request.queryParameters["queries"] ?? "1"
-    let numQueries = max(1, min(Int(queriesParam) ?? 1, 500))      // Snap to range of 1-500 as per test spec
-    updateRandomRows_Raw(count: numQueries) { (rows, err) in
-        if let rows = rows {
-            try? response.status(.OK).send(json: rows).end()
-        } else if let err = err {
-            try? response.status(.badRequest).send("Error: \(err)").end()
-        } else {
-            fatalError("Unexpected: rows and err both nil")
-        }
-    }
-}
-
-
-router.get("/updatesParallel") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    let queriesParam = request.queryParameters["queries"] ?? "1"
-    let numQueries = max(1, min(Int(queriesParam) ?? 1, 500))      // Snap to range of 1-500 as per test spec
-    var results: [[String:Int]] = []
-    // Used to protect result array from concurrent modification
-    let updateLock = DispatchSemaphore(value: 1)
-    // Execute each query. Each callback will append its result to `results`
-    for _ in 1...numQueries {
-        getRandomRow_Raw { (row, err) in
-            guard let row = row else {
-                guard let err = err else {
-                    Log.error("Unknown Error")
-                    try? response.status(.badRequest).send("Unknown error").end()
-                    return
-                }
-                Log.error("\(err)")
-                try? response.status(.badRequest).send("Error: \(err)").end()
-                return
-            }
-            // Execute inner callback for updating the row
-            updateRow_Raw(id: row.id) { (err) in
-                if let err = err {
-                    try? response.status(.badRequest).send("Error: \(err)").end()
-                    return
-                }
-                updateLock.wait()
-                results.append(row.asDictionary())
-                if results.count == numQueries {
-                    // Return JSON representation of array of results
-                    try? response.status(.OK).send(json: results).end()
-                }
-                updateLock.signal()
-            }
-        }
-    }
-}
-
-
-Kitura.addHTTPServer(onPort: 8080, with: router)
-Kitura.run()

+ 0 - 24
frameworks/Swift/kitura/Sources/TechEmpowerPostgresMustache/Fortune+Mustache.swift

@@ -1,24 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Mustache
-import TechEmpowerCommon
-
-extension Fortune: MustacheBoxable {
-  public var mustacheBox: MustacheBox {
-    return Box(["id": self.id, "message": self.message])
-  }
-}

+ 0 - 57
frameworks/Swift/kitura/Sources/TechEmpowerPostgresMustache/main.swift

@@ -1,57 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Kitura
-import LoggerAPI
-import HeliumLogger
-import KituraMustache
-import TechEmpowerCommon
-import KueryPostgresRaw
-
-Log.logger = HeliumLogger(.info)
-
-let router = Router()
-router.add(templateEngine: MustacheTemplateEngine())
-
-//
-// TechEmpower test 4: fortunes (raw, no ORM)
-//
-router.get("/fortunes") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    response.headers["Content-Type"] = "text/html; charset=UTF-8"
-    getFortunes { (fortunes, err) in
-        guard var fortunes = fortunes else {
-            guard let err = err else {
-                Log.error("Unknown Error")
-                try? response.status(.badRequest).send("Unknown error").end()
-                return
-            }
-            Log.error("\(err)")
-            try? response.status(.badRequest).send("Error: \(err)").end()
-            return
-        }
-        fortunes.append(Fortune(id: 0, message: "Additional fortune added at request time."))
-        do {
-          try response.render("fortunes.mustache", context: ["fortunes": fortunes.sorted()]).end()
-        } catch {
-          print("Error: \(error)")
-        }
-    }
-}
-
-Kitura.addHTTPServer(onPort: 8080, with: router)
-Kitura.run()

+ 0 - 166
frameworks/Swift/kitura/Sources/TechEmpowerPostgresORM/main.swift

@@ -1,166 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Foundation
-import Kitura
-import LoggerAPI
-import HeliumLogger
-import KituraStencil
-import Stencil
-import TechEmpowerCommon
-import KueryPostgresORM
-
-Log.logger = HeliumLogger(.info)
-
-// Stencil stuff
-let ext = Extension()
-
-// Stencil does not yet support automatic HTML escaping:
-// https://github.com/kylef/Stencil/pull/80
-//
-ext.registerFilter("htmlencode") { (value: Any?) in
-    if let value = value as? String {
-        return value
-            .replacingOccurrences(of: "&", with: "&amp;")
-            .replacingOccurrences(of: "<", with: "&lt;")
-            .replacingOccurrences(of: ">", with: "&gt;")
-            .replacingOccurrences(of: "'", with: "&apos;")
-            .replacingOccurrences(of: "\"", with: "&quot;")
-    }
-    return value
-}
-
-let router = Router()
-router.add(templateEngine: StencilTemplateEngine(extension: ext))
-
-setupORM()
-
-//
-// TechEmpower test 2: Single database query (full ORM)
-//
-router.get("/db") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    getRandomRow { (row, err) in
-        guard let row = row else {
-            guard let err = err else {
-                Log.error("Unknown Error")
-                try? response.status(.badRequest).send("Unknown error").end()
-                return
-            }
-            Log.error("\(err)")
-            try? response.status(.badRequest).send("Error: \(err)").end()
-            return
-        }
-        try? response.status(.OK).send(json: row.asDictionary()).end()
-    }
-}
-
-//
-// TechEmpower test 3: Multiple database queries (full ORM)
-// Get param provides number of queries: /queries?queries=N
-//
-router.get("/queries") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    let queriesParam = request.queryParameters["queries"] ?? "1"
-    let numQueries = max(1, min(Int(queriesParam) ?? 1, 500))      // Snap to range of 1-500 as per test spec
-    getRandomRows(count: numQueries) { (rows, err) in
-        if let rows = rows {
-            try? response.status(.OK).send(json: rows).end()
-        } else if let err = err {
-            try? response.status(.badRequest).send("Error: \(err)").end()
-        } else {
-            fatalError("Unexpected: rows and err both nil")
-        }
-    }
-}
-
-router.get("/queriesParallel") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    let queriesParam = request.queryParameters["queries"] ?? "1"
-    let numQueries = max(1, min(Int(queriesParam) ?? 1, 500))      // Snap to range of 1-500 as per test spec
-    getRandomRowsParallel(count: numQueries) { (rows, err) in
-        if let rows = rows {
-            try? response.status(.OK).send(json: rows).end()
-        } else if let err = err {
-            try? response.status(.badRequest).send("Error: \(err)").end()
-        } else {
-            fatalError("Unexpected: rows and err both nil")
-        }
-    }
-}
-
-//
-// TechEmpower test 4: fortunes (full ORM)
-//
-router.get("/fortunes") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    response.headers["Content-Type"] = "text/html; charset=UTF-8"
-    Fortune.findAll { (fortunes, err) in
-        if var fortunes = fortunes {
-            fortunes.append(Fortune(id: 0, message: "Additional fortune added at request time."))
-            do {
-                try response.render("fortunes.stencil", context: ["fortunes": fortunes.sorted()]).end()
-            } catch {
-                try? response.status(.internalServerError).send("Error: \(error)").end()
-            }
-        } else {
-            try? response.status(.internalServerError).send("Error: \(err ?? .internalServerError)").end()
-        }
-    }
-}
-
-//
-// TechEmpower test 5: updates (full ORM)
-//
-router.get("/updates") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    let queriesParam = request.queryParameters["queries"] ?? "1"
-    let numQueries = max(1, min(Int(queriesParam) ?? 1, 500))      // Snap to range of 1-500 as per test spec
-    updateRandomRows(count: numQueries) { (rows, err) in
-        if let rows = rows {
-            try? response.status(.OK).send(json: rows).end()
-        } else if let err = err {
-            try? response.status(.badRequest).send("Error: \(err)").end()
-        } else {
-            fatalError("Unexpected: rows and err both nil")
-        }
-    }
-}
-
-router.get("/updatesParallel") {
-    request, response, next in
-    response.headers["Server"] = "Kitura"
-    let queriesParam = request.queryParameters["queries"] ?? "1"
-    let numQueries = max(1, min(Int(queriesParam) ?? 1, 500))      // Snap to range of 1-500 as per test spec
-    updateRandomRowsParallel(count: numQueries) { (rows, err) in
-        if let rows = rows {
-            try? response.status(.OK).send(json: rows).end()
-        } else if let err = err {
-            try? response.status(.badRequest).send("Error: \(err)").end()
-        } else {
-            fatalError("Unexpected: rows and err both nil")
-        }
-    }
-}
-
-
-Kitura.addHTTPServer(onPort: 8080, with: router)
-Kitura.run()

+ 0 - 136
frameworks/Swift/kitura/Sources/TechEmpowerPostgresORMCodable/main.swift

@@ -1,136 +0,0 @@
-/*
- * Copyright IBM Corporation 2018
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import Foundation
-import Kitura
-import LoggerAPI
-import HeliumLogger
-import KituraStencil
-import Stencil
-import TechEmpowerCommon
-import KueryPostgres
-import SwiftKueryORM
-import KueryPostgresORM
-
-Log.logger = HeliumLogger(.info)
-
-// Stencil stuff
-let ext = Extension()
-
-// Stencil does not yet support automatic HTML escaping:
-// https://github.com/kylef/Stencil/pull/80
-//
-ext.registerFilter("htmlencode") { (value: Any?) in
-    if let value = value as? String {
-        return value
-            .replacingOccurrences(of: "&", with: "&amp;")
-            .replacingOccurrences(of: "<", with: "&lt;")
-            .replacingOccurrences(of: ">", with: "&gt;")
-            .replacingOccurrences(of: "'", with: "&apos;")
-            .replacingOccurrences(of: "\"", with: "&quot;")
-    }
-    return value
-}
-
-let router = Router()
-router.add(templateEngine: StencilTemplateEngine(extension: ext))
-
-// Configure our ORM Database connection pool as dbConnPool created by KueryPostgres
-Database.default = Database(dbConnPool)
-
-// Define the query parameters we can receive
-struct TFBParams: QueryParams {
-    let queries: Int
-
-    // Override default decode to cater for the query parameter specification:
-    //   If the parameter is missing, is not an integer, or is an integer less
-    //   than 1, the value should be interpreted as 1.
-    // This means that rather than failing to decode on a non-integer value, we
-    // should fall back to a value of 1.
-    public init(from decoder: Decoder) throws {
-        let container = try decoder.container(keyedBy: CodingKeys.self)
-        if let value = try? container.decode(Int.self, forKey: CodingKeys.queries) {
-            self.queries = value
-        } else {
-            self.queries = 1
-        }
-    }
-}
-
-// Set Server header on all responses as per TechEmpower spec
-router.all("/*") {
-    _, response, next in
-    response.headers["Server"] = "Kitura"
-    next()
-}
-
-//
-// TechEmpower test 2: Single database query (full ORM)
-//
-router.get("/db") { (respondWith: @escaping (RandomRow?, RequestError?) -> Void) in
-    // Select random row from database range
-    RandomRow.find(id: RandomRow.randomId, respondWith)
-}
-
-//
-// TechEmpower test 3: Multiple database queries (full ORM)
-// Get param provides number of queries: /queries?queries=N
-//
-router.get("/queries") { (params: TFBParams, respondWith: @escaping ([RandomRow]?, RequestError?) -> Void) in
-    let numQueries = max(1, min(params.queries, 500))  // Snap to range of 1-500 as per test spec
-    getRandomRows(count: numQueries, completion: respondWith)
-}
-router.get("/queriesParallel") { (params: TFBParams, respondWith: @escaping ([RandomRow]?, RequestError?) -> Void) in
-    let numQueries = max(1, min(params.queries, 500))  // Snap to range of 1-500 as per test spec
-    getRandomRowsParallel(count: numQueries, completion: respondWith)
-}
-
-//
-// TechEmpower test 4: fortunes (full ORM)
-// TODO: convert to Codable once templating support is available
-//
-router.get("/fortunes") {
-    request, response, next in
-    response.headers["Content-Type"] = "text/html; charset=UTF-8"
-    Fortune.findAll { (fortunes, err) in
-        if var fortunes = fortunes {
-            fortunes.append(Fortune(id: 0, message: "Additional fortune added at request time."))
-            do {
-                try response.render("fortunes.stencil", context: ["fortunes": fortunes.sorted()]).end()
-            } catch {
-                try? response.status(.internalServerError).send("Error: \(error)").end()
-            }
-        } else {
-            try? response.status(.internalServerError).send("Error: \(err ?? .internalServerError)").end()
-        }
-    }
-}
-
-//
-// TechEmpower test 5: updates (full ORM)
-//
-router.get("/updates") { (params: TFBParams, respondWith: @escaping ([RandomRow]?, RequestError?) -> Void) in
-    let numQueries = max(1, min(params.queries, 500))  // Snap to range of 1-500 as per test spec
-    updateRandomRows(count: numQueries, completion: respondWith)
-}
-router.get("/updatesParallel") { (params: TFBParams, respondWith: @escaping ([RandomRow]?, RequestError?) -> Void) in
-    let numQueries = max(1, min(params.queries, 500))  // Snap to range of 1-500 as per test spec
-    updateRandomRowsParallel(count: numQueries, completion: respondWith)
-}
-
-
-Kitura.addHTTPServer(onPort: 8080, with: router)
-Kitura.run()

+ 0 - 12
frameworks/Swift/kitura/Views/fortunes.mustache

@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head><title>Fortunes</title></head>
-<body>
-<table>
-<tr><th>id</th><th>message</th></tr>
-{{#fortunes}}
-<tr><td>{{id}}</td><td>{{message}}</td></tr>
-{{/fortunes}}
-</table>
-</body>
-</html>

+ 0 - 10
frameworks/Swift/kitura/Views/fortunes.stencil

@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head><title>Fortunes</title></head>
-<body>
-<table>
-<tr><th>id</th><th>message</th></tr>{% for fortune in fortunes %}
-<tr><td>{{ fortune.id }}</td><td>{{ fortune.message | htmlencode }}</td></tr>{% endfor %}
-</table>
-</body>
-</html>

+ 0 - 246
frameworks/Swift/kitura/benchmark_config.json

@@ -1,246 +0,0 @@
-{
-  "framework": "kitura",
-  "tests": [{
-    "default": {
-      "json_url": "/json",
-      "plaintext_url": "/plaintext",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "none",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "none",
-      "platform": "KituraNet",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "postgres": {
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "fortune_url": "/fortunes",
-      "update_url": "/updates?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "Postgres",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "Raw",
-      "platform": "KituraNet",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "postgres-orm": {
-      "db_url": "/db",
-      "fortune_url": "/fortunes",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "Postgres",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "Full",
-      "platform": "KituraNet",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "postgres-orm-codable": {
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "update_url": "/updates?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "Postgres",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "Full",
-      "platform": "KituraNet",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "mongodb": {
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "fortune_url": "/fortunes",
-      "update_url": "/updates?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "MongoDB",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "Raw",
-      "platform": "KituraNet",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "gcd": {
-      "json_url": "/json",
-      "plaintext_url": "/plaintext",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "none",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "none",
-      "platform": "KituraNet",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "nio": {
-      "json_url": "/json",
-      "plaintext_url": "/plaintext",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "none",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "none",
-      "platform": "KituraNIO",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "gcd-postgres": {
-      "db_url": "/db",
-      "fortune_url": "/fortunes",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "Postgres",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "Raw",
-      "platform": "KituraNet",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "nio-postgres": {
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "fortune_url": "/fortunes",
-      "update_url": "/updates?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "Postgres",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "Raw",
-      "platform": "KituraNIO",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "gcd-postgres-orm": {
-      "db_url": "/db",
-      "fortune_url": "/fortunes",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "Postgres",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "Full",
-      "platform": "KituraNet",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "nio-postgres-orm": {
-      "db_url": "/db",
-      "fortune_url": "/fortunes",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "Postgres",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "Full",
-      "platform": "KituraNIO",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "gcd-postgres-orm-codable": {
-      "db_url": "/db",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "Postgres",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "Full",
-      "platform": "KituraNet",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "nio-postgres-orm-codable": {
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "update_url": "/updates?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "Postgres",
-      "framework": "Kitura",
-      "language": "Swift",
-      "orm": "Full",
-      "platform": "KituraNIO",
-      "webserver": "Kitura",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Kitura",
-      "notes": "",
-      "tags": ["broken"]
-    }
-  }]
-}

+ 0 - 16
frameworks/Swift/kitura/config.json

@@ -1,16 +0,0 @@
-{
-  "db": {
-    "host":     "tfb-database",
-    "port":     5432,
-    "name":     "hello_world",
-    "user":     "benchmarkdbuser",
-    "password": "benchmarkdbpass"
-  },
-  "mongodb": {
-    "host":     "tfb-database",
-    "port":     27017,
-    "name":     "hello_world",
-    "user":     "benchmarkdbuser",
-    "password": "benchmarkdbpass"
-  }
-}

+ 0 - 178
frameworks/Swift/kitura/config.toml

@@ -1,178 +0,0 @@
-[framework]
-name = "kitura"
-
-[postgres-orm]
-urls.db = "/db"
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Fullstack"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Full"
-platform = "KituraNet"
-webserver = "Kitura"
-versus = "None"
-
-[gcd-postgres-orm-codable]
-urls.db = "/db"
-approach = "Realistic"
-classification = "Fullstack"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Full"
-platform = "KituraNet"
-webserver = "Kitura"
-versus = "None"
-
-[gcd]
-urls.plaintext = "/plaintext"
-urls.json = "/json"
-approach = "Realistic"
-classification = "Fullstack"
-database = "none"
-database_os = "Linux"
-os = "Linux"
-orm = "none"
-platform = "KituraNet"
-webserver = "Kitura"
-versus = "None"
-
-[main]
-urls.plaintext = "/plaintext"
-urls.json = "/json"
-approach = "Realistic"
-classification = "Fullstack"
-database = "none"
-database_os = "Linux"
-os = "Linux"
-orm = "none"
-platform = "KituraNet"
-webserver = "Kitura"
-versus = "None"
-
-[mongodb]
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Fullstack"
-database = "MongoDB"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "KituraNet"
-webserver = "Kitura"
-versus = "None"
-
-[nio]
-urls.plaintext = "/plaintext"
-urls.json = "/json"
-approach = "Realistic"
-classification = "Fullstack"
-database = "none"
-database_os = "Linux"
-os = "Linux"
-orm = "none"
-platform = "KituraNIO"
-webserver = "Kitura"
-versus = "None"
-
-[gcd-postgres-orm]
-urls.db = "/db"
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Fullstack"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Full"
-platform = "KituraNet"
-webserver = "Kitura"
-versus = "None"
-
-[nio-postgres-orm]
-urls.db = "/db"
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Fullstack"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Full"
-platform = "KituraNIO"
-webserver = "Kitura"
-versus = "None"
-
-[nio-postgres]
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Fullstack"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "KituraNIO"
-webserver = "Kitura"
-versus = "None"
-
-[postgres-orm-codable]
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-approach = "Realistic"
-classification = "Fullstack"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Full"
-platform = "KituraNet"
-webserver = "Kitura"
-versus = "None"
-
-[nio-postgres-orm-codable]
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-approach = "Realistic"
-classification = "Fullstack"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Full"
-platform = "KituraNIO"
-webserver = "Kitura"
-versus = "None"
-
-[gcd-postgres]
-urls.db = "/db"
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Fullstack"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "KituraNet"
-webserver = "Kitura"
-versus = "None"
-
-[postgres]
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Fullstack"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "KituraNet"
-webserver = "Kitura"
-versus = "None"

+ 0 - 10
frameworks/Swift/kitura/kitura-gcd-postgres-orm-codable.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-RUN swift build -c release -Xswiftc -DGCD_ASYNCH
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpowerPostgresORMCodable

+ 0 - 10
frameworks/Swift/kitura/kitura-gcd-postgres-orm.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-RUN swift build -c release -Xswiftc -DGCD_ASYNCH
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpowerPostgresORM

+ 0 - 10
frameworks/Swift/kitura/kitura-gcd-postgres.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-RUN swift build -c release -Xswiftc -DGCD_ASYNCH
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpowerPostgres

+ 0 - 10
frameworks/Swift/kitura/kitura-gcd.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-RUN swift build -c release -Xswiftc -DGCD_ASYNCH
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpower

+ 0 - 10
frameworks/Swift/kitura/kitura-mongodb.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-RUN swift build -c release
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpowerMongoKitten

+ 0 - 11
frameworks/Swift/kitura/kitura-nio-postgres-orm-codable.dockerfile

@@ -1,11 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-ENV KITURA_NIO=1
-RUN swift build -c release
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpowerPostgresORMCodable

+ 0 - 11
frameworks/Swift/kitura/kitura-nio-postgres-orm.dockerfile

@@ -1,11 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-ENV KITURA_NIO=1
-RUN swift build -c release
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpowerPostgresORM

+ 0 - 11
frameworks/Swift/kitura/kitura-nio-postgres.dockerfile

@@ -1,11 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-ENV KITURA_NIO=1
-RUN swift build -c release
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpowerPostgres

+ 0 - 11
frameworks/Swift/kitura/kitura-nio.dockerfile

@@ -1,11 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-ENV KITURA_NIO=1
-RUN swift build -c release
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpower

+ 0 - 10
frameworks/Swift/kitura/kitura-postgres-orm-codable.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-RUN swift build -c release
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpowerPostgresORMCodable

+ 0 - 10
frameworks/Swift/kitura/kitura-postgres-orm.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-RUN swift build -c release
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpowerPostgresORM

+ 0 - 10
frameworks/Swift/kitura/kitura-postgres.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-RUN swift build -c release
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpowerPostgres

+ 0 - 10
frameworks/Swift/kitura/kitura.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD ./ /kitura
-WORKDIR /kitura
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev
-RUN swift build -c release
-
-EXPOSE 8080
-
-CMD .build/release/TechEmpower

+ 0 - 6
frameworks/Swift/perfect/.gitignore

@@ -1,6 +0,0 @@
-.DS_Store
-.build
-build_gcd
-.swiftenv
-Packages
-*.xcodeproj

+ 0 - 25
frameworks/Swift/perfect/Package.swift

@@ -1,25 +0,0 @@
-// swift-tools-version:4.0
-
-import PackageDescription
-
-let package = Package(
-	name: "Perfect-TechEmpower",
-	products: [
-		.executable(name: "Perfect", targets: ["Perfect"]),
-		.executable(name: "Perfect-MySQL", targets: ["Perfect-MySQL"]),
-		.executable(name: "Perfect-PostgreSQL", targets: ["Perfect-PostgreSQL"]),
-		.executable(name: "Perfect-MongoDB", targets: ["Perfect-MongoDB"])
-	],
-	dependencies: [
-		.package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", from: "3.0.0"),
-		.package(url:"https://github.com/PerfectlySoft/Perfect-MySQL.git", from: "3.0.0"),
-		.package(url: "https://github.com/PerfectlySoft/Perfect-PostgreSQL.git", from: "3.0.0"),
-		.package(url:"https://github.com/PerfectlySoft/Perfect-MongoDB.git", from: "3.0.0")
-	],
-	targets: [
-		.target(name: "Perfect", dependencies: ["PerfectHTTPServer"]),
-		.target(name: "Perfect-MySQL", dependencies: ["PerfectHTTPServer", "PerfectMySQL"]),
-		.target(name: "Perfect-PostgreSQL", dependencies: ["PerfectHTTPServer", "PerfectPostgreSQL"]),
-		.target(name: "Perfect-MongoDB", dependencies: ["PerfectHTTPServer", "PerfectMongoDB"])
-	]
-)

+ 0 - 43
frameworks/Swift/perfect/README.md

@@ -1,43 +0,0 @@
-# [Perfect](https://www.perfect.org) Benchmark Test
-
-This is the [Perfect](https://www.perfect.org) portion of a [benchmarking test suite](https://www.techempower.com/benchmarks/) comparing a variety of web development platforms.
-
-## Variants
-
-There is are four versions of the benchmark, three of which use databases:
-- `Perfect`: No DB
-- `Perfect-MySQL`: Using MySQL
-- `Perfect-PostgreSQL`: Using PostgreSQL
-- `Perfect-MongoDB`: Using MongoDB
-
-Each listens on port 8080, and use common URLs described below.
-
-## Versions and Dependencies
-
-This version of the benchmark requires Swift 4.1, and uses the following versions of Perfect and dependencies:
-
-- [Perfect 3.0](https://github.com/PerfectlySoft/Perfect-HTTPServer.git)
-- [Perfect-MySQL 3.0](https://github.com/PerfectlySoft/Perfect-MySQL.git)
-- [Perfect-PostgreSQL 3.0](https://github.com/PerfectlySoft/Perfect-PostgreSQL.git)
-- [Perfect-MongoDB 3.0](https://github.com/PerfectlySoft/Perfect-MongoDB.git)
-
-## Test URLs
-### JSON serialization
-
-http://localhost:8080/json
-
-### Plaintext
-
-http://localhost:8080/plaintext
-
-### DB Store - on all configurations
-
-http://localhost:8080/db
-
-### Queries - on all configurations
-
-http://localhost:8080/queries/queries=2
-
-### Updates - on all configurations
-
-http://localhost:8080/updates/queries=2

+ 0 - 316
frameworks/Swift/perfect/Sources/Perfect-MongoDB/main.swift

@@ -1,316 +0,0 @@
-import PerfectHTTP
-import PerfectHTTPServer
-import PerfectLib
-import PerfectMongoDB
-import Foundation
-
-let tfbHost = "tfb-database"
-let database = "hello_world"
-let username = "benchmarkdbuser"
-let password = "benchmarkdbpass"
-
-let client = try! MongoClient(uri: "mongodb://\(tfbHost)")
-let db = client.getDatabase(name: database)
-let World = db.getCollection(name: "world")
-let Fortune = db.getCollection(name: "fortune")
-
-class LinearCongruntialGenerator {
- 
-    var state = 0 //seed of 0 by default
-    let a, c, m, shift: Int
- 
-    init() {
-        self.a = 214013
-        self.c = 2531011
-        self.m = Int(pow(2.0, 31.0)) //2^31 or 2147483648
-        self.shift = 16
-    }
- 
-    func random() -> Int {
-        state = (a * state + c) % m
-        return state >> shift
-    }
-}
-
-let numGenerator = LinearCongruntialGenerator()
-
-func fetchFromWorld(id: String?) -> [String: Any] {
-
-    var rand:Int = 0
-
-    if id == nil {
-        rand = numGenerator.random() % 10000 + 1
-    } else {
-        rand = Int(id!)!
-    }
-
-    if let world = World {
-
-        var json = [String:Any]()
-        json["id"] = rand
-
-        var fields = [String: Any]()
-        fields["id"] = 1
-        fields["randomNumber"] = 1
-        fields["_id"] = 0
-
-        var fieldString: String = ""
-
-        do {
-            fieldString = try fields.jsonEncodedString()
-        } catch {
-            fieldString = String(describing: fields)
-        }
-
-        do {
-            let jsonString = try json.jsonEncodedString()
-            do {
-                let results = try world.find(query: BSON( json: jsonString ), fields: BSON( json: fieldString ))
-
-                if let res = results {
-                    for item in res {
-                        let itemString = String(describing: item)
-                        return convertStringToDictionary(str: itemString)
-                    }
-                } else {
-                    print("results couldn't be unwrapped: ", rand)
-                }
-            } catch {
-                //
-            }
-        } catch {
-            // empty on purpose
-        } 
-    } else {
-        //
-    }
-    
-    let emptyObj = [String: Any]()
-    return emptyObj
-}
-
-func updateOneFromWorld() -> [String: Any] {
-
-    let worldToUpdate = fetchFromWorld(id: nil)
-    var id = Int()
-    if worldToUpdate["id"] != nil {
-        id = worldToUpdate["id"] as! Int
-    } else {
-        id = 1
-        print("Error trying to fetch a world to update")
-    }
-    let newRandom = numGenerator.random() % 10000
-    var errorObj = [String: Any]()
-
-    if let world = World {
-
-        var json = [String: Any]()
-        json["id"] = id
-
-        var fields = [String: Any]()
-        fields["id"] = 1
-        fields["randomNumber"] = 1
-        fields["_id"] = 0
-
-        var update = [String: Any]()
-        update["randomNumber"] = newRandom
-
-        var fieldString: String = ""
-
-        do {
-            fieldString = try fields.jsonEncodedString()
-        } catch {
-            fieldString = String(describing: fields)
-        }
-
-        var updateString: String = ""
-        var jsonString: String = ""
-
-        do {
-            updateString = try update.jsonEncodedString()
-        } catch {
-            updateString = String(describing: update)
-        }
-
-        do {
-            jsonString = try json.jsonEncodedString()
-        } catch {
-            jsonString = String(describing: json)
-        }
-
-        do {
-            let results = try world.findAndModify(query: BSON( json: jsonString ), sort: nil, update: BSON( json: updateString ), fields: BSON( json: fieldString ), remove: false, upsert: false, new: true)
-            let resultsStr = String(describing: results)
-            return convertUpdateStringToDictionary(str: resultsStr, id: id)
-        } catch {
-            errorObj["id"] = "Error running query findAndModify"
-            return errorObj
-        }
-    } else {
-        errorObj["id"] = "world is empty"
-        return errorObj
-    }
-}
-
-func updatesHandler(request: HTTPRequest, response: HTTPResponse) {
-
-    let queryStr = returnCorrectTuple(queryArr: request.queryParams)
-    var totalQueries = sanitizeQueryValue(queryString: queryStr)
-
-    var updateArr: Array = [[String: Any]]()
-
-    while 0 < totalQueries {
-        updateArr.append(updateOneFromWorld())
-        totalQueries -= 1
-    }
-
-    do {
-
-        response.appendBody(string: try updateArr.jsonEncodedString())
-    } catch {
-
-        response.appendBody(string: String(describing: updateArr))
-    }
-
-    setHeaders(response: response, contentType: "application/json")
-
-    response.completed()
-}
-
-func multipleDatabaseQueriesHandler(request: HTTPRequest, response: HTTPResponse) {
-
-    let queryStr = returnCorrectTuple(queryArr: request.queryParams)
-    var totalQueries = sanitizeQueryValue(queryString: queryStr)
-
-    var queryArr = [[String: Any]]()
-
-    while 0 < totalQueries {
-
-        queryArr.append(fetchFromWorld(id: nil))
-        totalQueries -= 1
-    }  
-
-    do {
-        response.appendBody(string: try queryArr.jsonEncodedString())
-    } catch {
-        response.appendBody(string: String(describing: queryArr))
-    }
-
-    setHeaders(response: response, contentType: "application/json")
-
-    response.completed()
-}
-
-func singleDatabaseQueryHandler(request: HTTPRequest, response: HTTPResponse) {
-
-    let res = fetchFromWorld(id: nil)
-
-    do {
-        response.appendBody(string: try res.jsonEncodedString())
-    } catch {
-        response.appendBody(string: String(describing: res))
-    }
-
-    setHeaders(response: response, contentType: "application/json")
-    response.completed()
-}
-
-// Helpers
-
-func setHeaders(response: HTTPResponse, contentType: String) {
-
-    response.setHeader(.contentType, value: contentType)
-    response.setHeader(.custom(name: "Server"), value: "Perfect")
-
-    let currDate: String = getCurrDate()
-
-	response.setHeader(.custom(name: "Date"), value: currDate)
-}
-
-func getCurrDate() -> String {
-
-    let now = getNow()
-
-    do {
-        let formatted = try formatDate(now, format: "%a, %d %b %Y %H:%M:%S %Z", timezone: nil, locale: nil)
-        return formatted
-    } catch {
-        return "error formatting date string"
-    }
-}
-
-func returnCorrectTuple(queryArr: [(String, String)]) -> String {
-
-    for tup in queryArr {
-        if String(describing: tup.0) == "queries" {
-            return String(describing: tup.1)
-        }
-    }
-
-    return "nil"
-}
-
-func sanitizeQueryValue(queryString: String) -> Int {
-
-    if let queryNum = Int(queryString) {
-
-        if queryNum > 0 && queryNum < 500 {
-            return queryNum
-        } else if queryNum > 500 {
-            return 500
-        } else {
-            return 1
-        }
-    } else {
-        return 1
-    }
-}
-
-func spoofHTML(fortunesArr: [[String: Any]]) -> String {
-
-    var htmlToRet = "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>"
-
-    for fortune in fortunesArr {
-
-        htmlToRet += "<tr><td>\(fortune["id"]!)</td><td>\(fortune["message"]!)</td></tr>"
-    }
-
-    htmlToRet += "</table></body></html>";
-
-    return htmlToRet
-}
-
-func convertStringToDictionary(str: String) -> [String: Any] {
-
-    let strOfWordsArray = str.components(separatedBy: " ")
-
-    var returnObj = [String: Any]()
-
-    returnObj["id"] = Int(strOfWordsArray[3].dropLast())
-    returnObj["randomNumber"] = Int(strOfWordsArray[6])
-
-    return returnObj
-}
-
-func convertUpdateStringToDictionary(str: String, id: Int) -> [String: Any] {
-
-    let strOfWordsArray = str.components(separatedBy: " ")
-
-    var returnObj = [String: Any]()
-    returnObj["id"] = id
-    returnObj["randomNumber"] = Int(strOfWordsArray[16])
-
-    return returnObj
-}
-
-var routes = Routes()
-routes.add(method: .get, uri: "/updates", handler: updatesHandler)
-routes.add(method: .get, uri: "/queries", handler: multipleDatabaseQueriesHandler)
-routes.add(method: .get, uri: "/db", handler: singleDatabaseQueryHandler)
-routes.add(method: .get, uri: "/**",
-		   handler: StaticFileHandler(documentRoot: "./webroot", allowResponseFilters: true).handleRequest)
-try HTTPServer.launch(name: "localhost",
-    port: 8080,
-    routes: routes,
-    responseFilters: [
-    (PerfectHTTPServer.HTTPFilter.contentCompression(data: [:]), HTTPFilterPriority.high)])

+ 0 - 313
frameworks/Swift/perfect/Sources/Perfect-MySQL/main.swift

@@ -1,313 +0,0 @@
-import PerfectHTTP
-import PerfectHTTPServer
-import PerfectLib
-import PerfectMySQL
-import Foundation
-
-let tfbHost = "tfb-database"
-let database = "hello_world"
-let username = "benchmarkdbuser"
-let password = "benchmarkdbpass"
-
-let mysql = MySQL()
-let connected = mysql.connect(host: tfbHost, user: username, password: password)
-let _ = mysql.selectDatabase(named: database)
-
-class LinearCongruntialGenerator {
- 
-    var state = 0
-    let a, c, m, shift: Int
- 
-    init() {
-        self.a = 214013
-        self.c = 2531011
-        self.m = Int(pow(2.0, 31.0))
-        self.shift = 16
-    }
- 
-    func random() -> Int {
-        state = (a * state + c) % m
-        return state >> shift
-    }
-}
-
-let numGenerator = LinearCongruntialGenerator()
-
-func fetchFromFortune() -> [[String: String]] {
-
-    var arrOfFortunes = [[String: String]]()
-    let querySuccess = mysql.query(statement: "SELECT id, message FROM fortune")
-
-    guard querySuccess else {
-
-        let errorObject = ["id": "Failed to execute query"]
-        arrOfFortunes.append(errorObject)
-        
-        return arrOfFortunes
-    }
- 
-    let results = mysql.storeResults()!
-
-    results.forEachRow { row in
-        if let id = row[0], let message = row[1] {
-            
-            let resObj = ["id": String(describing: id), "message": message]
-            arrOfFortunes.append(resObj)
-        } else {
-            print("not correct values returned: ", row)
-        }
-    }
-
-    return arrOfFortunes
-}
-
-func fetchFromWorld(id: String?) -> [String:Any] {
-
-    var returnObj = [String: Any]()
-    var errorObject = [String: Any]()
-    var rand:Int = 0
-
-    if id == nil {
-        rand = numGenerator.random() % 10000 + 1
-    } else {
-        rand = Int(id!)!
-    }
-
-    let querySuccess = mysql.query(statement: "SELECT id, randomNumber FROM World WHERE id = \(rand)")
-
-    guard querySuccess else {
-
-        errorObject["id"] = "Failed to execute query"
-
-        return errorObject
-    }
- 
-    let results = mysql.storeResults()!
-
-    results.forEachRow { row in
-
-        if let id = row[0], let randomNumber = row[1] {
-
-            returnObj["id"] = id
-            returnObj["randomNumber"] = randomNumber
-        } else {
-
-            returnObj["id"] = "No return value"
-            returnObj["randomNumber"] = "what happened?"
-        }
-    }
-
-    return returnObj
-}
-
-func updateOneFromWorld() -> [String: Any] {
-
-    var returnObj = [String: Any]()
-    var errorObject = [String: Any]()
-    let worldToUpdate = fetchFromWorld(id: nil)
-    let id: String = worldToUpdate["id"] as! String 
-    let newRandom = numGenerator.random() % 10000
-
-    let querySuccess = mysql.query(statement: "UPDATE World SET randomNumber = \(newRandom) WHERE id = \(id)")
-
-    guard querySuccess else {
-        errorObject["id"] = "Failed to execute query"
-        return errorObject
-    }
- 
-    if let results = mysql.storeResults() {
-
-        results.forEachRow { row in
-            if let id = row[0], let randomNumber = row[1] {
-                returnObj["id"] = id
-                returnObj["randomNumber"] = randomNumber
-            } else {
-                returnObj["id"] = "No return value"
-                returnObj["randomNumber"] = "what happened?"
-            }
-        }
-        return returnObj
-    } else {
-        returnObj["id"] = id
-        returnObj["randomNumber"] = newRandom
-        return returnObj
-    }
-}
-
-func fortunesHandler(request: HTTPRequest, response: HTTPResponse) {
-
-    var arrOfFortunes = fetchFromFortune()
-
-    let newObj: [String: String] = ["id": "0", "message": "Additional fortune added at request time."]
-
-    arrOfFortunes.append(newObj)
-
-    let sortedArr = arrOfFortunes.sorted(by: ({ $0["message"]! < $1["message"]! }))
-
-    let htmlToRet = spoofHTML(fortunesArr: sortedArr)
-
-    response.appendBody(string: htmlToRet)
-    
-    setHeaders(response: response, contentType: "text/html")
-    response.setHeader(.custom(name: "CustomLength"), value: String(describing: htmlToRet.count + 32))
-
-    response.completed()
-}
-
-func updatesHandler(request: HTTPRequest, response: HTTPResponse) {
-
-    let queryStr = returnCorrectTuple(queryArr: request.queryParams)
-    var totalQueries = sanitizeQueryValue(queryString: queryStr)
-
-    var updateArr: Array = [[String: Any]]()
-
-    while 0 < totalQueries {
-        updateArr.append(updateOneFromWorld())
-        totalQueries -= 1
-    }
-
-    do {
-
-        response.appendBody(string: try updateArr.jsonEncodedString())
-    } catch {
-
-        response.appendBody(string: String(describing: updateArr))
-    }
-
-    setHeaders(response: response, contentType: "application/json")
-
-    response.completed()
-}
-
-func multipleDatabaseQueriesHandler(request: HTTPRequest, response: HTTPResponse) {
-
-    let queryStr = returnCorrectTuple(queryArr: request.queryParams)
-    var totalQueries = sanitizeQueryValue(queryString: queryStr)
-
-    var queryArr: Array = [[String: Any]]()
-
-    while 0 < totalQueries {
-
-        queryArr.append(fetchFromWorld(id: nil))
-        totalQueries -= 1
-    }  
-
-    do {
-
-        response.appendBody(string: try queryArr.jsonEncodedString())
-    } catch {
-
-        response.appendBody(string: String(describing: queryArr))
-    }
-
-    setHeaders(response: response, contentType: "application/json")
-
-    response.completed()
-}
-
-func singleDatabaseQueryHandler(request: HTTPRequest, response: HTTPResponse) {
-
-    let res = fetchFromWorld(id: nil)
-
-    let errorPayload: [String: Any] = [
-        "error": "Could not set body!"
-    ]
-
-    var responseString: String = ""
-    var errorString: String = ""
-    do {
-        errorString = try errorPayload.jsonEncodedString()
-    } catch {
-        // Nothing to do here - we already have an empty value
-    }
-
-    do {
-        responseString = try res.jsonEncodedString()
-        response.appendBody(string: responseString)
-    } catch {
-        response.status = HTTPResponseStatus.internalServerError
-        response.appendBody(string: errorString)
-    }
-
-
-    setHeaders(response: response, contentType: "application/json")
-    response.completed()
-}
-
-// Helpers
-
-func setHeaders(response: HTTPResponse, contentType: String) {
-
-    response.setHeader(.contentType, value: contentType)
-    response.setHeader(.custom(name: "Server"), value: "Perfect")
-
-    let currDate: String = getCurrDate()
-
-	response.setHeader(.custom(name: "Date"), value: currDate)
-}
-
-func getCurrDate() -> String {
-
-    let now = getNow()
-
-    do {
-        let formatted = try formatDate(now, format: "%a, %d %b %Y %H:%M:%S %Z", timezone: nil, locale: nil)
-        return formatted
-    } catch {
-        return "error formatting date string"
-    }
-}
-
-func returnCorrectTuple(queryArr: [(String, String)]) -> String {
-
-    for tup in queryArr {
-        if String(describing: tup.0) == "queries" {
-            return String(describing: tup.1)
-        }
-    }
-
-    return "nil"
-}
-
-func sanitizeQueryValue(queryString: String) -> Int {
-
-    if let queryNum = Int(queryString) {
-
-        if queryNum > 0 && queryNum < 500 {
-            return queryNum
-        } else if queryNum > 500 {
-            return 500
-        } else {
-            return 1
-        }
-    } else {
-        return 1
-    }
-}
-
-func spoofHTML(fortunesArr: [[String: Any]]) -> String {
-
-    var htmlToRet = "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>"
-
-    for fortune in fortunesArr {
-
-        htmlToRet += "<tr><td>\(fortune["id"]!)</td><td>\(fortune["message"]!)</td></tr>"
-    }
-
-    htmlToRet += "</table></body></html>";
-
-    return htmlToRet
-}
-
-var routes = Routes()
-routes.add(method: .get, uri: "/fortunes", handler: fortunesHandler)
-routes.add(method: .get, uri: "/updates", handler: updatesHandler)
-routes.add(method: .get, uri: "/queries", handler: multipleDatabaseQueriesHandler)
-routes.add(method: .get, uri: "/db", handler: singleDatabaseQueryHandler)
-routes.add(method: .get, uri: "/**",
-		   handler: StaticFileHandler(documentRoot: "./webroot", allowResponseFilters: true).handleRequest)
-try HTTPServer.launch(name: "localhost",
-    port: 8080,
-    routes: routes,
-    responseFilters: [
-    (PerfectHTTPServer.HTTPFilter.contentCompression(data: [:]), HTTPFilterPriority.high)])

+ 0 - 224
frameworks/Swift/perfect/Sources/Perfect-PostgreSQL/main.swift

@@ -1,224 +0,0 @@
-import PerfectHTTP
-import PerfectHTTPServer
-import PerfectLib
-import PerfectPostgreSQL
-import Foundation
-
-let tfbHost = "tfb-database"
-let database = "hello_world"
-let username = "benchmarkdbuser"
-let password = "benchmarkdbpass"
-
-let p = PGConnection()
-let status = p.connectdb("postgresql://\(username):\(password)@\(tfbHost):5432/\(database)")
-
-class LinearCongruntialGenerator {
- 
-    var state = 0 //seed of 0 by default
-    let a, c, m, shift: Int
- 
-    init() {
-        self.a = 214013
-        self.c = 2531011
-        self.m = Int(pow(2.0, 31.0)) //2^31 or 2147483648
-        self.shift = 16
-    }
- 
-    func random() -> Int {
-        state = (a * state + c) % m
-        return state >> shift
-    }
-}
-
-let numGenerator = LinearCongruntialGenerator()
-
-func fetchFromWorld(id: String?) -> [String:Any] {
-
-    var returnObj = [String: Any]()
-    var rand:Int = 0
-
-    if id == nil {
-        rand = numGenerator.random() % 10000
-    } else {
-        rand = Int(id!)!
-    }
-
-    let results = p.exec(statement: "select id, randomNumber from world where id = \(rand)")
-
-    returnObj["id"] = results.getFieldString(tupleIndex: 0, fieldIndex: 0)!
-    returnObj["randomNumber"] = results.getFieldString(tupleIndex: 0, fieldIndex: 1)!
-    
-    return returnObj
-}
-
-func updateOneFromWorld() -> [String: Any] {
-
-    var returnObj = [String: Any]()
-    let worldToUpdate = fetchFromWorld(id: nil)
-    let rand = numGenerator.random() % 10000 + 1
-    let id: String = worldToUpdate["id"] as! String
-
-    let _ = p.exec(statement: "UPDATE world SET randomNumber = \(rand) WHERE id = \(id)")
-
-    returnObj["id"] = id
-    returnObj["randomNumber"] = rand
-
-    return returnObj
-}
-
-func updatesHandler(request: HTTPRequest, response: HTTPResponse) {
-
-    let queryStr = returnCorrectTuple(queryArr: request.queryParams)
-    var totalQueries = sanitizeQueryValue(queryString: queryStr)
-
-    var updateArr: Array = [[String: Any]]()
-
-    while 0 < totalQueries {
-        updateArr.append(updateOneFromWorld())
-        totalQueries -= 1
-    }
-
-    do {
-
-        response.appendBody(string: try updateArr.jsonEncodedString())
-    } catch {
-
-        response.appendBody(string: String(describing: updateArr))
-    }
-
-    setHeaders(response: response, contentType: "application/json")
-
-    response.completed()
-}
-
-func multipleDatabaseQueriesHandler(request: HTTPRequest, response: HTTPResponse) {
-
-    let queryStr = returnCorrectTuple(queryArr: request.queryParams)
-    var totalQueries = sanitizeQueryValue(queryString: queryStr)
-
-    var queryArr: Array = [[String: Any]]()
-
-    while 0 < totalQueries {
-
-        queryArr.append(fetchFromWorld(id: nil))
-        totalQueries -= 1
-    }  
-
-    do {
-
-        response.appendBody(string: try queryArr.jsonEncodedString())
-    } catch {
-
-        response.appendBody(string: String(describing: queryArr))
-    }
-
-    setHeaders(response: response, contentType: "application/json")
-
-    response.completed()
-}
-
-func singleDatabaseQueryHandler(request: HTTPRequest, response: HTTPResponse) {
-
-    let res = fetchFromWorld(id: nil)
-
-    let errorPayload: [String: Any] = [
-        "error": "Could not set body!"
-    ]
-
-    var responseString: String = ""
-    var errorString: String = ""
-    do {
-        errorString = try errorPayload.jsonEncodedString()
-    } catch {
-        // Nothing to do here - we already have an empty value
-    }
-
-    do {
-        responseString = try res.jsonEncodedString()
-        response.appendBody(string: responseString)
-    } catch {
-        response.status = HTTPResponseStatus.internalServerError
-        response.appendBody(string: errorString)
-    }
-
-
-    setHeaders(response: response, contentType: "application/json")
-    response.completed()
-}
-
-// Helpers
-
-func setHeaders(response: HTTPResponse, contentType: String) {
-
-    response.setHeader(.contentType, value: contentType)
-    response.setHeader(.custom(name: "Server"), value: "Perfect")
-
-    let currDate: String = getCurrDate()
-
-	response.setHeader(.custom(name: "Date"), value: currDate)
-}
-
-func getCurrDate() -> String {
-
-    let now = getNow()
-
-    do {
-        let formatted = try formatDate(now, format: "%a, %d %b %Y %H:%M:%S %Z", timezone: nil, locale: nil)
-        return formatted
-    } catch {
-        return "error formatting date string"
-    }
-}
-
-func returnCorrectTuple(queryArr: [(String, String)]) -> String {
-
-    for tup in queryArr {
-        if String(describing: tup.0) == "queries" {
-            return String(describing: tup.1)
-        }
-    }
-
-    return "nil"
-}
-
-func sanitizeQueryValue(queryString: String) -> Int {
-
-    if let queryNum = Int(queryString) {
-
-        if queryNum > 0 && queryNum < 500 {
-            return queryNum
-        } else if queryNum > 500 {
-            return 500
-        } else {
-            return 1
-        }
-    } else {
-        return 1
-    }
-}
-
-func spoofHTML(fortunesArr: [[String: Any]]) -> String {
-
-    var htmlToRet = "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>"
-
-    for fortune in fortunesArr {
-
-        htmlToRet += "<tr><td>\(fortune["id"]!)</td><td>\(fortune["message"]!)</td></tr>"
-    }
-
-    htmlToRet += "</table></body></html>";
-
-    return htmlToRet
-}
-
-var routes = Routes()
-routes.add(method: .get, uri: "/updates", handler: updatesHandler)
-routes.add(method: .get, uri: "/queries", handler: multipleDatabaseQueriesHandler)
-routes.add(method: .get, uri: "/db", handler: singleDatabaseQueryHandler)
-routes.add(method: .get, uri: "/**",
-		   handler: StaticFileHandler(documentRoot: "./webroot", allowResponseFilters: true).handleRequest)
-try HTTPServer.launch(name: "localhost",
-    port: 8080,
-    routes: routes,
-    responseFilters: [
-    (PerfectHTTPServer.HTTPFilter.contentCompression(data: [:]), HTTPFilterPriority.high)])

+ 0 - 78
frameworks/Swift/perfect/Sources/Perfect/main.swift

@@ -1,78 +0,0 @@
-import PerfectHTTP
-import PerfectHTTPServer
-import PerfectLib
-import Foundation
-
-func plaintextHandler(request: HTTPRequest, response: HTTPResponse) {
-
-	response.appendBody(string: "Hello, World!")
-
-    setHeaders(response: response, contentType: "text/plain")
-
-	response.completed()
-}
-
-func jsonHandler(request: HTTPRequest, response: HTTPResponse) {
-
-    var helloDictionary: [String: String] = [:]
-    helloDictionary["message"] = "Hello, World!"
-
-    let errorPayload: [String: Any] = [
-        "error": "Could not set body!"
-    ]
-
-    var responseString: String = ""
-    var errorString: String = ""
-    do {
-        errorString = try errorPayload.jsonEncodedString()
-    } catch {
-        // Nothing to do here - we already have an empty value
-    }
-
-    do {
-        responseString = try helloDictionary.jsonEncodedString()
-        response.appendBody(string: responseString)
-    } catch {
-        response.status = HTTPResponseStatus.internalServerError
-        response.appendBody(string: errorString)
-    }
-
-
-    setHeaders(response: response, contentType: "application/json")
-    response.completed()
-}
-
-// Helpers
-
-func setHeaders(response: HTTPResponse, contentType: String) {
-
-    response.setHeader(.contentType, value: contentType)
-    response.setHeader(.custom(name: "Server"), value: "Perfect")
-
-    let currDate: String = getCurrDate()
-
-	response.setHeader(.custom(name: "Date"), value: currDate)
-}
-
-func getCurrDate() -> String {
-
-    let now = getNow()
-
-    do {
-        let formatted = try formatDate(now, format: "%a, %d %b %Y %H:%M:%S %Z", timezone: nil, locale: nil)
-        return formatted
-    } catch {
-        return "error formatting date string"
-    }
-}
-
-var routes = Routes()
-routes.add(method: .get, uri: "/json", handler: jsonHandler)
-routes.add(method: .get, uri: "/plaintext", handler: plaintextHandler)
-routes.add(method: .get, uri: "/**",
-		   handler: StaticFileHandler(documentRoot: "./webroot", allowResponseFilters: true).handleRequest)
-try HTTPServer.launch(name: "localhost",
-    port: 8080,
-    routes: routes,
-    responseFilters: [
-    (PerfectHTTPServer.HTTPFilter.contentCompression(data: [:]), HTTPFilterPriority.high)])

+ 0 - 80
frameworks/Swift/perfect/benchmark_config.json

@@ -1,80 +0,0 @@
-{
-  "framework": "perfect",
-  "tests": [{
-    "default": {
-      "json_url": "/json",
-      "plaintext_url": "/plaintext",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Micro",
-      "database": "None",
-      "framework": "Perfect",
-      "language": "Swift",
-      "orm": "Raw",
-      "platform": "Perfect",
-      "webserver": "Perfect",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Perfect",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "mysql": {
-      "update_url": "/updates?queries=",
-      "query_url": "/queries?queries=",
-      "db_url": "/db",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Micro",
-      "database": "MySQL",
-      "framework": "Perfect",
-      "language": "Swift",
-      "orm": "Raw",
-      "platform": "Perfect",
-      "webserver": "Perfect",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Perfect",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "postgresql": {
-      "update_url": "/updates?queries=",
-      "query_url": "/queries?queries=",
-      "db_url": "/db",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Micro",
-      "database": "Postgres",
-      "framework": "Perfect",
-      "language": "Swift",
-      "orm": "Raw",
-      "platform": "Perfect",
-      "webserver": "Perfect",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Perfect",
-      "notes": "",
-      "tags": ["broken"]
-    },
-    "mongodb": {
-      "update_url": "/updates?queries=",
-      "query_url": "/queries?queries=",
-      "db_url": "/db",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Micro",
-      "database": "MongoDB",
-      "framework": "Perfect",
-      "language": "Swift",
-      "orm": "Raw",
-      "platform": "Perfect",
-      "webserver": "Perfect",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Perfect",
-      "notes": "",
-      "tags": ["broken"]
-    }
-  }]
-}

+ 0 - 57
frameworks/Swift/perfect/config.toml

@@ -1,57 +0,0 @@
-[framework]
-name = "perfect"
-
-[main]
-urls.plaintext = "/plaintext"
-urls.json = "/json"
-approach = "Realistic"
-classification = "Micro"
-database = "None"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "Perfect"
-webserver = "Perfect"
-versus = "None"
-
-[mongodb]
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-approach = "Realistic"
-classification = "Micro"
-database = "MongoDB"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "Perfect"
-webserver = "Perfect"
-versus = "None"
-
-[postgresql]
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-approach = "Realistic"
-classification = "Micro"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "Perfect"
-webserver = "Perfect"
-versus = "None"
-
-[mysql]
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-approach = "Realistic"
-classification = "Micro"
-database = "MySQL"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "Perfect"
-webserver = "Perfect"
-versus = "None"

+ 0 - 10
frameworks/Swift/perfect/perfect-mongodb.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD . /perfect
-WORKDIR /perfect
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev && apt-get install -y xsltproc docbook-xsl uuid-dev clang pkg-config libicu-dev libpython2.7 libxml2-dev wget git libssl-dev uuid-dev libsqlite3-dev libpq-dev libmysqlclient-dev libbson-dev libmongoc-dev libcurl4-openssl-dev && apt-get -y install libmysqlclient-dev libmongoc-1.0-0 libbson-1.0
-RUN swift build
-
-EXPOSE 8080
-
-CMD .build/debug/Perfect-MongoDB

+ 0 - 10
frameworks/Swift/perfect/perfect-mysql.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD . /perfect
-WORKDIR /perfect
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev && apt-get install -y xsltproc docbook-xsl uuid-dev clang pkg-config libicu-dev libpython2.7 libxml2-dev wget git libssl-dev uuid-dev libsqlite3-dev libpq-dev libmysqlclient-dev libbson-dev libmongoc-dev libcurl4-openssl-dev && apt-get -y install libmysqlclient-dev libmongoc-1.0-0 libbson-1.0
-RUN swift build
-
-EXPOSE 8080
-
-CMD .build/debug/Perfect-MySQL

+ 0 - 10
frameworks/Swift/perfect/perfect-postgresql.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD . /perfect
-WORKDIR /perfect
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev && apt-get install -y xsltproc docbook-xsl uuid-dev clang pkg-config libicu-dev libpython2.7 libxml2-dev wget git libssl-dev uuid-dev libsqlite3-dev libpq-dev libmysqlclient-dev libbson-dev libmongoc-dev libcurl4-openssl-dev && apt-get -y install libmysqlclient-dev libmongoc-1.0-0 libbson-1.0
-RUN swift build
-
-EXPOSE 8080
-
-CMD .build/debug/Perfect-PostgreSQL

+ 0 - 10
frameworks/Swift/perfect/perfect.dockerfile

@@ -1,10 +0,0 @@
-FROM swift:4.1
-
-ADD . /perfect
-WORKDIR /perfect
-RUN apt-get update -yqq && apt-get install -yqq libpq-dev && apt-get install -y xsltproc docbook-xsl uuid-dev clang pkg-config libicu-dev libpython2.7 libxml2-dev wget git libssl-dev uuid-dev libsqlite3-dev libpq-dev libmysqlclient-dev libbson-dev libmongoc-dev libcurl4-openssl-dev && apt-get -y install libmysqlclient-dev libmongoc-1.0-0 libbson-1.0
-RUN swift build
-
-EXPOSE 8080
-
-CMD .build/debug/Perfect

+ 0 - 8
frameworks/Swift/swift-nio/.gitignore

@@ -1,8 +0,0 @@
-.DS_Store
-.build/
-.vscode/
-/*.xcodeproj
-xcuserdata/
-.swiftpm/
-DerivedData/
-Package.resolved

+ 0 - 15
frameworks/Swift/swift-nio/config.toml

@@ -1,15 +0,0 @@
-[framework]
-name = "swift-nio"
-
-[main]
-urls.plaintext = "/p"
-urls.json = "/j"
-approach = "Realistic"
-classification = "Platform"
-database = "None"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "None"
-webserver = "None"
-versus = ""

+ 2 - 2
frameworks/Swift/swift-nio/swift-nio.dockerfile

@@ -1,7 +1,7 @@
 # ================================
 # Build image
 # ================================
-FROM swift:5.9 as build
+FROM swift:5.10 as build
 WORKDIR /build
 
 # Copy entire repo into container
@@ -15,7 +15,7 @@ RUN swift build \
 # ================================
 # Run image
 # ================================
-FROM swift:5.9-slim
+FROM swift:5.10-slim
 WORKDIR /run
 
 # Install Swift dependencies

+ 0 - 7
frameworks/Swift/vapor/.gitignore

@@ -1,7 +0,0 @@
-.DS_Store
-.build/
-/*.xcodeproj
-xcuserdata/
-.swiftpm/
-DerivedData/
-Package.resolved

+ 1 - 1
frameworks/Swift/vapor/benchmark_config.json

@@ -16,7 +16,7 @@
       "database_os": "Linux",
       "display_name": "Vapor",
       "notes": "",
-      "versus": "None"
+      "versus": "swift-nio"
     },
     "fluent": {
       "db_url": "/db",

+ 2 - 2
frameworks/Swift/vapor/vapor-fluent.dockerfile

@@ -1,7 +1,7 @@
 # ================================
 # Build image
 # ================================
-FROM swift:5.9 as build
+FROM swift:5.10 as build
 WORKDIR /build
 
 # Copy entire repo into container
@@ -15,7 +15,7 @@ RUN swift build \
 # ================================
 # Run image
 # ================================
-FROM swift:5.9-slim
+FROM swift:5.10-slim
 WORKDIR /run
 
 # Copy build artifacts

+ 0 - 29
frameworks/Swift/vapor/vapor-mongo-fluent.dockerfile

@@ -1,29 +0,0 @@
-# ================================
-# Build image
-# ================================
-FROM swift:5.9 as build
-WORKDIR /build
-
-# Copy entire repo into container
-COPY ./vapor-mongo-fluent .
-
-# Compile with optimizations
-RUN swift build \
-	-c release \
-	-Xswiftc -enforce-exclusivity=unchecked
-
-# ================================
-# Run image
-# ================================
-FROM swift:5.9-slim
-WORKDIR /run
-
-# Copy build artifacts
-COPY --from=build /build/.build/release /run
-
-# Copy Swift runtime libraries
-COPY --from=build /usr/lib/swift/ /usr/lib/swift/
-
-EXPOSE 8080
-
-ENTRYPOINT ["./app", "serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8080"]

+ 0 - 29
frameworks/Swift/vapor/vapor-mongo-fluent/Package.swift

@@ -1,29 +0,0 @@
-// swift-tools-version:5.5
-import PackageDescription
-
-let package = Package(
-    name: "vapor-fluent",
-    platforms: [
-        .macOS(.v12)
-    ],
-    products: [
-        .executable(name: "app", targets: ["App"])
-    ],
-    dependencies: [
-        .package(url: "https://github.com/vapor/vapor.git", from: "4.52.2"),
-        .package(url: "https://github.com/vapor/fluent.git", from: "4.4.0"),
-        .package(url: "https://github.com/vapor/fluent-mongo-driver.git", from: "1.0.2"),
-        .package(url: "https://github.com/orlandos-nl/MongoKitten.git", from: "6.7.1")
-    ],
-    targets: [
-        .executableTarget(
-            name: "App",
-            dependencies: [
-                .product(name: "Fluent", package: "fluent"),
-                .product(name: "FluentMongoDriver", package: "fluent-mongo-driver"),
-                .product(name: "Vapor", package: "vapor"),
-                .product(name: "MongoKitten", package: "MongoKitten"),
-            ],
-            path: "Sources"),
-    ]
-)

+ 0 - 25
frameworks/Swift/vapor/vapor-mongo-fluent/Sources/Utilities.swift

@@ -1,25 +0,0 @@
-import Vapor
-
-extension Int {
-    func bounded(to range: ClosedRange<Int>) -> Int {
-        switch self {
-        case ...range.lowerBound:
-            return range.lowerBound
-        case range.upperBound...:
-            return range.upperBound
-        default:
-            return self
-        }
-    }
-}
-
-extension System {
-    // tfb-server (aka, citrine) uses 28 hyper-threaded cores
-    // postgresql.conf specifies max_connections = 2000
-    //
-    // 2000 / (28 * 2) = 35.7 (theoretical max)
-    //
-    // https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Project-Information-Environment#citrine-self-hosted
-    // https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/toolset/databases/postgres/postgresql.conf#L64
-    static var maxConnectionsPerEventLoop: Int { 32 }
-}

+ 0 - 14
frameworks/Swift/vapor/vapor-mongo-fluent/Sources/World.swift

@@ -1,14 +0,0 @@
-import Fluent
-import Vapor
-
-final class World: Model, Content {
-    static let schema = "world"
-
-    @ID(custom: "id")
-    var id: Float?
-
-    @Field(key: "randomNumber")
-    var randomNumber: Float
-
-    init() { }
-}

+ 0 - 52
frameworks/Swift/vapor/vapor-mongo-fluent/Sources/main.swift

@@ -1,52 +0,0 @@
-import Fluent
-import FluentMongoDriver
-import Vapor
-
-var env = try Environment.detect()
-try LoggingSystem.bootstrap(from: &env)
-
-let connectionString = "mongodb://tfb-database:27017/hello_world"
-
-let app = Application(env)
-
-app.http.server.configuration.serverName = "Vapor"
-
-app.logger.notice("💧 VAPOR")
-app.logger.notice("System.coreCount: \(System.coreCount)")
-app.logger.notice("System.maxConnectionsPerEventLoop: \(System.maxConnectionsPerEventLoop)")
-
-try app.databases.use(.mongo(
-    connectionString: connectionString),
-    as: .mongo)
-
-app.get("db") { req async throws -> World in
-    guard let world = try await World.find(Float(.random(in: 1...10_000)), on: req.db) else {
-        throw Abort(.notFound)
-    }
-
-    return world
-}
-
-app.get("queries") { req async throws -> [World] in
-    let queries = (req.query["queries"] ?? 1).bounded(to: 1...500)
-
-    var worlds: [World] = []
-
-    for _ in queries {
-        guard let world = try await World.find(Float(.random(in: 1...10_000)), on: req.db) else {
-            throw Abort(.notFound)
-        }
-
-        worlds.append(world)
-    }
-
-    return worlds
-}
-
-extension Int: Sequence {
-    public func makeIterator() -> CountableRange<Int>.Iterator {
-        return (0..<self).makeIterator()
-    }
-}
-
-try app.run()

+ 2 - 2
frameworks/Swift/vapor/vapor-mongo.dockerfile

@@ -1,7 +1,7 @@
 # ================================
 # Build image
 # ================================
-FROM swift:5.9 as build
+FROM swift:5.10 as build
 WORKDIR /build
 
 # Copy entire repo into container
@@ -18,7 +18,7 @@ RUN swift build \
 # ================================
 # Run image
 # ================================
-FROM swift:5.9-slim
+FROM swift:5.10-slim
 WORKDIR /run
 
 RUN apt update

+ 2 - 2
frameworks/Swift/vapor/vapor-postgres.dockerfile

@@ -1,7 +1,7 @@
 # ================================
 # Build image
 # ================================
-FROM swift:5.9 as build
+FROM swift:5.10 as build
 WORKDIR /build
 
 # Copy entire repo into container
@@ -15,7 +15,7 @@ RUN swift build \
 # ================================
 # Run image
 # ================================
-FROM swift:5.9-slim
+FROM swift:5.10-slim
 WORKDIR /run
 
 # Copy build artifacts

+ 2 - 2
frameworks/Swift/vapor/vapor-sql-kit.dockerfile

@@ -1,7 +1,7 @@
 # ================================
 # Build image
 # ================================
-FROM swift:5.9 as build
+FROM swift:5.10 as build
 WORKDIR /build
 
 # Copy entire repo into container
@@ -15,7 +15,7 @@ RUN swift build \
 # ================================
 # Run image
 # ================================
-FROM swift:5.9-slim
+FROM swift:5.10-slim
 WORKDIR /run
 
 # Copy build artifacts

+ 2 - 2
frameworks/Swift/vapor/vapor.dockerfile

@@ -1,7 +1,7 @@
 # ================================
 # Build image
 # ================================
-FROM swift:5.9 as build
+FROM swift:5.10 as build
 WORKDIR /build
 
 # Copy entire repo into container
@@ -15,7 +15,7 @@ RUN swift build \
 # ================================
 # Run image
 # ================================
-FROM swift:5.9-slim
+FROM swift:5.10-slim
 WORKDIR /run
 
 # Copy build artifacts