Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query params benchmark #20

Merged
merged 5 commits into from
Jan 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Bench-Kitura-Core/2.3.2/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ let package = Package(
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(name: "HelloWorld", dependencies: benchmarkDependencies),
.target(name: "QueryParams", dependencies: benchmarkDependencies),
.target(name: "HelloLogging", dependencies: benchmarkDependencies),
.target(name: "HelloSSL", dependencies: benchmarkDependencies),
.target(name: "JSON", dependencies: benchmarkDependencies),
Expand Down
40 changes: 40 additions & 0 deletions Bench-Kitura-Core/2.3.2/Sources/QueryParams/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 Foundation

Log.logger = HeliumLogger(.info)

let port = Int(ProcessInfo.processInfo.environment["PORT"] ?? "8080") ?? 8080

let router = Router()

//
// Plaintext echo of 'message' query parameter
//
router.get("/echo") {
request, response, next in
let echo = request.queryParameters["message"] ?? "Supply a message using ?message=foo"
response.headers["Content-Type"] = "text/plain"
response.status(.OK).send(echo)
try response.end()
}

Kitura.addHTTPServer(onPort: port, with: router)
Kitura.run()
3 changes: 3 additions & 0 deletions Bench-Kitura-Core/benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ function setParams {
# Add an Accept header to trigger Media Type processing
WRK_SCRIPT="$dir/payloads/simpleStructPayload_accept.lua"
;;
QueryParams)
URL="http://localhost:8080/echo?message=foo"
;;
*)
echo "Unknown test '$TESTNAME'"
;;
Expand Down
1 change: 1 addition & 0 deletions Bench-Kitura-Core/latest/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ let package = Package(
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(name: "HelloWorld", dependencies: benchmarkDependencies),
.target(name: "QueryParams", dependencies: benchmarkDependencies),
.target(name: "HelloLogging", dependencies: benchmarkDependencies),
.target(name: "HelloSSL", dependencies: benchmarkDependencies),
.target(name: "JSON", dependencies: benchmarkDependencies),
Expand Down
40 changes: 40 additions & 0 deletions Bench-Kitura-Core/latest/Sources/QueryParams/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 Foundation

Log.logger = HeliumLogger(.info)

let port = Int(ProcessInfo.processInfo.environment["PORT"] ?? "8080") ?? 8080

let router = Router()

//
// Plaintext echo of 'message' query parameter
//
router.get("/echo") {
request, response, next in
let echo = request.queryParameters["message"] ?? "Supply a message using ?message=foo"
response.headers["Content-Type"] = "text/plain"
response.status(.OK).send(echo)
try response.end()
}

Kitura.addHTTPServer(onPort: port, with: router)
Kitura.run()