Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env perl6
class REST::Server {
has $.host = '127.0.0.1';
has $.port = 8080;
has %.options is rw;
has $.debug = 1;
has Supply $!scheduler;
@tony-o
tony-o / srvr.pl6
Last active August 29, 2015 14:02
my $num = 0;
IO::Socket::Async.listen($.host,$.port,).tap(-> $connection {
my $snum = $num++;
my @chunks;
"connected #$snum".say;
my $tap := $connection.chars_supply.tap({
$_.say;
try {
$connection.send("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 6\r\n\r\nstring");
"closing connection $snum".say if $.debug;
{tony@boondocks:~/projects/perl6-http-server-async}% ab -n 2500 -c 1 http://127.0.0.1:8080/test
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 250 requests
Completed 500 requests
Completed 750 requests
Completed 1000 requests
{tony@boondocks:~/projects/perl6-http-server-async}% wrk -t 1 -c 5 http://127.0.0.1:8080/test
Running 10s test @ http://127.0.0.1:8080/test
1 threads and 5 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 128.63ms 67.87ms 207.25ms 45.83%
Req/Sec 34.46 30.00 86.00 45.83%
341 requests in 10.00s, 25.64KB read
Socket errors: connect 0, read 845, write 0, timeout 7
Requests/sec: 34.08
Transfer/sec: 2.56KB
{tony@boondocks:~/projects/perl6-http-server-async}% wrk -t2 -c2 http://127.0.0.1:8080/test
Running 10s test @ http://127.0.0.1:8080/test
2 threads and 2 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 26.50ms 3.58ms 42.28ms 70.61%
Req/Sec 37.13 7.81 51.00 71.88%
747 requests in 10.00s, 56.17KB read
Socket errors: connect 0, read 747, write 0, timeout 0
Requests/sec: 74.69
Transfer/sec: 5.62KB
{tony@boondocks:~/projects/perl6-http-server-async}% !wrk
wrk -c 10 -t 10 http://127.0.0.1:8080/test
Running 10s test @ http://127.0.0.1:8080/test
10 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 259.76ms 151.19ms 646.49ms 63.78%
Req/Sec 4.53 2.56 12.00 82.14%
477 requests in 10.00s, 44.72KB read
Socket errors: connect 0, read 1, write 0, timeout 0
Requests/sec: 47.69
[E 140627 09:43:03 web:1433] Uncaught exception GET /tttt/tttt (127.0.0.1)
HTTPRequest(protocol='http', host='127.0.0.1:8080', method='GET', uri='/tttt/tttt', version='HTTP/1.1', remote_ip='127.0.0.1', headers={'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate', 'Host': '127.0.0.1:8080', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Firefox/31.0', 'Dnt': '1', 'Connection': 'keep-alive', 'Referer': 'http://127.0.0.1:8080/tttt'})
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/tornado/web.py", line 1346, in _when_complete
callback()
File "/usr/local/lib/python2.7/site-packages/tornado/web.py", line 1367, in _execute_method
self._when_complete(method(*self.path_args, **self.path_kwargs),
File "/usr/local/lib/python2.7/site-packages/tornado/web.py", line 2523, in wrapper
return method(self, *args, *
#!/usr/bin/env phantomjs
var page = new WebPage();
var testindex = 0;
var loadInProgress = false;
page.onLoadStarted = function(){
loadInProgress = true;
};
#!/usr/bin/env perl
use Modern::Perl;
use File::Slurp qw<slurp>;
use Data::Dumper;
my $text = slurp("test.txt");
my @headers;
my @data;
my @index;
package MoniCore::Plugin::Equality;
use Exporter();
our @ISA = qw<Exporter>;
our @EXPORT = qw<eq ct>;
our @EXPORT_OK = qw<eq ct>;
use Modern::Perl;
use Scalar::Util qw(looks_like_number);