GoroutineでもCoroutineでもないコルーチン的なもの、 「Koroutine」(造語です)を実装してみます。
KoroutineはThreadより軽量で並行動作可能な処理です。 各KoroutineやメインスレッドはChannelを通して通信します。
以下が実行例です。 スレッド 1...1 KoroutineSystem 1...2 Koroutine 1...1 Fiber の関係性で1スレッドで複数のKoroutineが実行される様子がわかります。
require 'mechanize' | |
require 'logger' | |
require_relative 'random_agent' | |
require_relative 'path' | |
# Mechanize::Page subclasses Mechanize::File, Mechanize::Download is its own thing | |
# module MimeInfo | |
# def size | |
# header["content-length"].to_i |
# Real Time Clock (RTC) Drivers for Linux: https://www.kernel.org/doc/Documentation/rtc.txt | |
cat /proc/driver/rtc | |
# ----------------------------------------x---------------------------------------- | |
echo rtc-pcf8563 0x51 /sys/class/i2c-adapter/i2c-1/new_device | |
# ----------------------------------------x---------------------------------------- |
GoroutineでもCoroutineでもないコルーチン的なもの、 「Koroutine」(造語です)を実装してみます。
KoroutineはThreadより軽量で並行動作可能な処理です。 各KoroutineやメインスレッドはChannelを通して通信します。
以下が実行例です。 スレッド 1...1 KoroutineSystem 1...2 Koroutine 1...1 Fiber の関係性で1スレッドで複数のKoroutineが実行される様子がわかります。
# Elixir v1.0 | |
defmodule Rules do | |
defmacro __using__(_) do | |
quote do | |
import unquote(__MODULE__) | |
@before_compile unquote(__MODULE__) | |
@rules [] | |
end | |
end |
module ActiveRecord | |
module Querying | |
delegate :group_date, :to => :scoped | |
end | |
module QueryMethods | |
def group_date(column_name = nil) | |
return self if column_name.blank? | |
# Rails uses a non standard time zone naming. |
#!perl | |
# Copyright 2012 Jeffrey Kegler | |
# This file is part of Marpa::R2. Marpa::R2 is free software: you can | |
# redistribute it and/or modify it under the terms of the GNU Lesser | |
# General Public License as published by the Free Software Foundation, | |
# either version 3 of the License, or (at your option) any later version. | |
# | |
# Marpa::R2 is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
source 'https://rubygems.org' | |
gem 'sinatra' | |
gem 'sinatra-contrib', require: 'sinatra/streaming' | |
group :development do | |
gem 'thin' | |
gem 'pry-rails' | |
end |
curl --user-agent "Googlebot/2.1 (+http://www.google.com/bot.html)" -v $@ | |
This is just an exercise to measure the performance between Sinatra-like libraries in:
Elixir v0.4.dev (running on top of the Erlang VM R14B03) with Dynamo;
Ruby 1.9.2 with [Sinatra Synchrony] v0.0.3 (https://github.com/kyledrake/sinatra-synchrony) + Thin;
node.js 0.4.7 with [express] v2.3.10(https://github.com/visionmedia/express)
# encoding: utf-8 | |
# Be sure to restart your server when you modify this file. | |
# Add new inflection rules using the following format | |
# (all these examples are active by default): | |
# ActiveSupport::Inflector.inflections do |inflect| | |
# inflect.plural /^(ox)$/i, '\1en' | |
# inflect.singular /^(ox)en/i, '\1' | |
# inflect.irregular 'person', 'people' | |
# inflect.uncountable %w( fish sheep ) |