Code Monkey home page Code Monkey logo

epoch's Introduction

Epoch

Swift 2.1 Platforms OS X | iOS Cocoapods Compatible Carthage Compatible License MIT

Epoch is a Epoch based HTTP server for Swift 2.

Features

  • No Foundation dependency (Linux ready)
  • Completely Asynchronous

Dependencies

Epoch is made of:

Usage

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()

Performance

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.

Installation

CocoaPods

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

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"

Manually

If you prefer not to use a dependency manager, you can integrate Epoch into your project manually.

Embedded Framework

  • 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 the Epoch.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 the Epoch.framework nested inside a Products folder.

    It does not matter which Products folder you choose from, but it does matter whether you choose the top or bottom Epoch.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 either Epoch iOS or Epoch 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.

License

Epoch is released under the MIT license. See LICENSE for details.

epoch's People

Contributors

paulofaria avatar terhechte avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.