Epoch is a Epoch based HTTP server for Swift 2.
- No
Foundation
dependency (Linux ready) - Completely Asynchronous
Epoch is made of:
- Venice - CSP and TCP/IP
- Luminescence - HTTP parser
struct HTTPServerResponder : HTTPResponderType {
func respond(request: HTTPRequest) -> HTTPResponse {
// do something based on the HTTPRequest
return HTTPResponse(statusCode: 200, reasonPhrase: "OK")
}
}
let responder = HTTPServerResponder()
let server = HTTPServer(port: 8080, responder: responder)
server.start()
Start Epoch Command Line Application and then run:
> ab -n 12800 -c 128 http://localhost:8080/
Results in a Macbook Pro early 2013:
Concurrency Level: 128
Time taken for tests: 4.734 seconds
Complete requests: 12800
Failed requests: 0
Total transferred: 0 bytes
HTML transferred: 0 bytes
Requests per second: 2703.60 [#/sec] (mean)
Time per request: 47.344 [ms] (mean)
Time per request: 0.370 [ms] (mean, across all concurrent requests)
Transfer rate: 0.00 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 8 13.3 0 119
Processing: 1 39 14.2 40 130
Waiting: 0 0 0.0 0 0
Total: 8 47 14.5 42 130
Percentage of the requests served within a certain time (ms)
50% 42
66% 45
75% 47
80% 53
90% 59
95% 62
98% 114
99% 120
100% 130 (longest request)
To make this results have any meaning you should create, for example, a node.js server that responds with 200 OK and compare it with Epoch.
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
CocoaPods 0.39.0+ is required to build Epoch.
To integrate Epoch into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
pod 'Epoch'
Then, run the following command:
$ pod install
Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate Epoch into your Xcode project using Carthage, specify it in your Cartfile
:
github "Zewo/Epoch"
If you prefer not to use a dependency manager, you can integrate Epoch into your project manually.
- Open up Terminal,
cd
into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:
$ git init
- Add Epoch as a git submodule by running the following command:
$ git submodule add https://github.com/Zewo/Epoch.git
-
Open the new
Epoch
folder, and drag theEpoch.xcodeproj
into the Project Navigator of your application's Xcode project.It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.
-
Select the
Epoch.xcodeproj
in the Project Navigator and verify the deployment target matches that of your application target. -
Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.
-
In the tab bar at the top of that window, open the "General" panel.
-
Click on the
+
button under the "Embedded Binaries" section. -
You will see two different
Epoch.xcodeproj
folders each with two different versions of theEpoch.framework
nested inside aProducts
folder.It does not matter which
Products
folder you choose from, but it does matter whether you choose the top or bottomEpoch.framework
. -
Select the top
Epoch.framework
for OS X and the bottom one for iOS.You can verify which one you selected by inspecting the build log for your project. The build target for
Epoch
will be listed as eitherEpoch iOS
orEpoch OSX
. -
And that's it!
The
Epoch.framework
is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.
Epoch is released under the MIT license. See LICENSE for details.