Skip to content

Instantly share code, notes, and snippets.

@punytan
punytan / bench.js
Created April 15, 2011 22:29
node.js vs twiggy hello world benchmark
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {"Content-Type": "text/plain"});
res.end("Hello World");
}).listen(4000, '');
console.log('Server running at http://localhost:4000');
<?xml version="1.0" encoding="UTF-8" ?>
<flashNews flag="0" pubDate="Fri, 06 May 2011 21:12:00 +0900" />
#!perl -w
use common::sense;
use AnyEvent;
use Data::Dumper;
sub sleep_sort {
my @args = @_;
my @output;
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark;
use JSON;
use LWP::UserAgent;
use Storable;
use MIME::Base64;
$ perl benchmark/deserialize.pl
-- deserialize
JSON::XS: 2.3
Data::MessagePack: 0.34
Storable: 2.29
Benchmark: running json, mp, storable for at least 1 CPU seconds...
json: 1 wallclock secs ( 1.03 usr + 0.00 sys = 1.03 CPU) @ 77544.66/s (n=79871)
mp: 1 wallclock secs ( 1.03 usr + 0.00 sys = 1.03 CPU) @ 98247.57/s (n=101195)
storable: 1 wallclock secs ( 1.09 usr + 0.00 sys = 1.09 CPU) @ 71739.45/s (n=78196)
Rate storable json mp
Benchmark for decode/encode large data structure
@punytan
punytan / feeds.sql
Created October 23, 2011 22:57
Post Your Blog Post About #yapcasia 2011
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE posts (
url TEXT UNIQUE,
title TEXT NOT NULL,
time INT NOT NULL
);
INSERT INTO "posts" VALUES('http://mt.endeworks.jp/d-6/2011/10/yapcasia-tokyo-2011-1.html',' YAPC::Asia Tokyo 2011 1日目・・・ - D-6 [相変わらず根無し] ',1318714947);
INSERT INTO "posts" VALUES('http://d.hatena.ne.jp/punitan/20111016/1318722529','YAPC::Asia 2011 に行ってきた - punitan (a.k.a. punytan) のメモ',1318722554);
INSERT INTO "posts" VALUES('http://mt.endeworks.jp/d-6/2011/10/yapcasia-tokyo-2011-backend-apps.html',' YAPC::Asia Tokyo 2011のシステム - D-6 [相変わらず根無し] ',1318723098);
use strict;
use warnings;
# fork of https://github.com/klange/nyancat
package Nyancat;
use Time::HiRes 'sleep';
local $SIG{INT} = sub {
print "\033[?25h\033[0m";
use strict;
use warnings;
use Plack::Request;
use Plack::MIME;
use Plack::App::Directory;
use FindBin;
my $java_bin = `which java` =~ s/[\n\r]//gr
or die 'Install Java :(';
use strict;
use warnings;
use AE;
use AnyEvent::HTTP;
use Twiggy::Server;
use Plack::Request;
use Plack::Session;
use Plack::Builder;