Code for Keras plays catch blog post
python qlearn.py
- Generate figures
""" | |
sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0rc0-cp34-cp34m-linux_x86_64.whl | |
""" | |
from __future__ import absolute_import | |
from __future__ import division | |
from __future__ import print_function |
Code for Keras plays catch blog post
python qlearn.py
# Install dependencies | |
# | |
# * checkinstall: package the .deb | |
# * libpcre3, libpcre3-dev: required for HTTP rewrite module | |
# * zlib1g zlib1g-dbg zlib1g-dev: required for HTTP gzip module | |
apt-get install checkinstall libpcre3 libpcre3-dev zlib1g zlib1g-dbg zlib1g-dev && \ | |
mkdir -p ~/sources/ && \ | |
# Compile against OpenSSL to enable NPN |
$stack, $draws = [], {} | |
def method_missing *args | |
return if args[0][/^to_/] | |
$stack << args.map { |a| a or $stack.pop } | |
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
end | |
class Array | |
def +@ |
system ~/projects/jruby $ macruby -rbenchmark -e "class A; def initialize; @a = 1; end; attr_accessor :a; end; 5.times { puts Benchmark.measure { a = A.new; i=0; while i<100_000_000; a.a; i+=1; end } }" | |
5.690000 0.000000 5.690000 ( 5.686256) | |
5.660000 0.000000 5.660000 ( 5.657916) | |
5.670000 0.000000 5.670000 ( 5.664147) | |
5.690000 0.010000 5.700000 ( 5.691450) | |
5.690000 0.000000 5.690000 ( 5.699265) | |
system ~/projects/jruby $ macruby -rbenchmark -e "class A; def initialize; @a = 1; end; def a; @a; end; end; 5.times { puts Benchmark.measure { a = A.new; i=0; while i<100_000_000; a.a; i+=1; end } }" | |
5.680000 0.010000 5.690000 ( 5.685863) | |
5.690000 0.000000 5.690000 ( 5.693407) |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
#!/usr/bin/env ruby | |
rss = '.+?Rss:\s+(\d+)' | |
share = '.+?Shared_Clean:\s+(\d+)' | |
share << '.+?Shared_Dirty:\s+(\d+)' | |
priv = '.+?Private_Clean:\s+(\d+)' | |
priv << '.+?Private_Dirty:\s+(\d+)' | |
MEM_REGEXP = /\[heap\]#{rss}#{share}#{priv}/m | |
def mem_usage() |
#!/usr/bin/env ruby | |
rss = '.+?Rss:\s+(\d+)' | |
share = '.+?Shared_Clean:\s+(\d+)' | |
share << '.+?Shared_Dirty:\s+(\d+)' | |
priv = '.+?Private_Clean:\s+(\d+)' | |
priv << '.+?Private_Dirty:\s+(\d+)' | |
MEM_REGEXP = /\[heap\]#{rss}#{share}#{priv}/m | |
def mem_usage_linux |
This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.
You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf
using homebrew.
# Documentation for HAProxy | |
# http://code.google.com/p/haproxy-docs/w/list | |
# http://haproxy.1wt.eu/download/1.2/doc/architecture.txt | |
# NOTES: | |
# open files limits need to be > 256000, use ulimit -n to set (on most POSIX systems) | |
global | |
log 127.0.0.1 local0 | |
log 127.0.0.1 local1 notice |