42. Perlだと?(雰囲気です)
package Index;
use Mouse;
extends 'Base';
has slim => ( is => 'rw', isa => 'Slim' );
sub run {
my ($self) = @_;
$self->slim->render('template/index.tt');
}
no Mouse;
1;
70. • https://github.com/reactphp/react
「Event-driven, non-blocking I/O with PHP.」
• https://github.com/ratchetphp/Ratchet
WebSocketサーバー(スタンドアロンでサーバ
ーになります)
• https://github.com/marcj/php-pm
「PHP ProcessManager for Request-Response
Applications」
71. • https://github.com/videlalvaro/phacterl
「Implementation of The Actor Model in
PHP.」
「アクターモデル」「マジで!?」
• https://github.com/ircmaxell/PHPPHP
「A PHP VM implementation written in PHP.」
「PHPでPHP実装した」「マジで?!」
• https://github.com/runekaagaard/snowscript
要はPHPのCoffeScript、更新ほぼない
88. Perl (Plack)
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use JSON::XS qw(encode_json);
my $app = sub {
my $env = shift;
return [
200,
[ 'Content-Type' => 'application/json' ],
[ encode_json({ message => 'Hello, World!' }) ],
];
};
return $app;
変哲のない生PlackなHelloWorldウェブアプリ
89. 突然ですがベンチマーク
• 環境
• Vultr (VPS) の下から二つ目のプラン
• 1コア (Vultr Virtual CPU 3392Mhz)
• Mem 1024MB、SSD
• CentOS6
90. Perl 5.20.0
start_server --port=5000 --backlog 16384
-- plackup -E production -s Starlet --max-keepalive-
reqs 1000 --max-reqs-per-child
50000 --min-reqs-per-child 40000 --max-worker
1 -a ./helloworld.psgi
ab -n 10000 -c 10
91. result - perl
Server Software: Plack::Handler::Starlet
Server Hostname: 127.0.0.1
Server Port: 5000
Document Path: /
Document Length: 27 bytes
Concurrency Level: 10
Time taken for tests: 1.606 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1670000 bytes
HTML transferred: 270000 bytes
Requests per second: 6225.76 [#/sec] (mean)
Time per request: 1.606 [ms] (mean)
Time per request: 0.161 [ms] (mean, across all concurrent requests)
Transfer rate: 1015.33 [Kbytes/sec] received
92. result - perl
Concurrency Level: 10
Complete requests: 10000
Requests per second: 6225.76 [#/sec] (mean)
97. result - php + reactPHP
Server Software:
Server Hostname: 127.0.0.1
Server Port: 5000
Document Path: /
Document Length: 36 bytes
Concurrency Level: 10
Time taken for tests: 3.397 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1420000 bytes
HTML transferred: 360000 bytes
Requests per second: 2943.53 [#/sec] (mean)
Time per request: 3.397 [ms] (mean)
Time per request: 0.340 [ms] (mean, across all concurrent requests)
Transfer rate: 408.18 [Kbytes/sec] received
98. result - php + reactPHP
Concurrency Level: 10
Complete requests: 10000
Requests per second: 2943.53 [#/sec] (mean)
102. result - HHVM
Server Software:
Server Hostname: 127.0.0.1
Server Port: 5000
Document Path: /index.php
Document Length: 36 bytes
Concurrency Level: 10
Time taken for tests: 1.230 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1420000 bytes
HTML transferred: 360000 bytes
Requests per second: 8132.90 [#/sec] (mean)
Time per request: 1.230 [ms] (mean)
Time per request: 0.123 [ms] (mean, across all concurrent requests)
Transfer rate: 1127.81 [Kbytes/sec] received
103. result - HHVM
Concurrency Level: 10
Complete requests: 10000
Requests per second: 8132.90 [#/sec] (mean)
109. HHVM httpd result
Server Software:
Server Hostname: 127.0.0.1
Server Port: 5000
Document Path: /index.php
Document Length: 27 bytes
Concurrency Level: 10
Time taken for tests: 1.704 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1240000 bytes
HTML transferred: 270000 bytes
Requests per second: 5868.96 [#/sec] (mean)
Time per request: 1.704 [ms] (mean)
Time per request: 0.170 [ms] (mean, across all concurrent requests)
Transfer rate: 710.69 [Kbytes/sec] received
110. HHVM httpd result
Concurrency Level: 10
Complete requests: 10000
Requests per second: 5868.96 #/sec
118. php the right way
http://ja.phptherightway.com/
安心の日本語翻訳です。ここをよめばとりあえず
最初迷わないでしょう。
PerlMongerの人はこれだけ覚えて帰って下さい。
(ちなみに、PHPの情報を集めるなら、
できれば海外の物が良いでしょう…
まあ、海外もスットコな情報多いですが)
119. 基本的に以上ですが…時間は
あまっている?
One more thing「s」
または
質問タイム
ーーーーーーーーーーー
YAPC登壇者3人+パーフェク
トRuby執筆者1人が書いた
「Webアプリケーション
エンジニア養成読本」
好評発売中!
174. 余談:namespaceがが区切り文字
ということは…
<?php
namespace ¥¥{
class ¥{
static public function ¥(){
echo " is not ¥".PHP_EOL;
}
}
}
namespace {
¥¥¥::¥();
}
こういうコードが可能なので…