Evan Walsh

In my experimentation with Ruby, I wondered what options for various tasks were fastest. This is not a complete measure of quality. Use these numbers wisely.

All of this was done on my early 2013 MacBook Pro (2.7 GHz Intel Core i7 processor, 16 GB 1600 MHz DDR3 RAM).

All the code I used for these benchmarks is available here.


I wanted to see the speed difference between all these ways of rendering HTML with Ruby.

The competitors:

Engine Iterations per second
Erubi 2701.7
ERB 1460.4
Liquid 1091.2
Markaby 609.5
Slim 345.8
Handlebars 238.0
HAML 234.2

I was surprised how fast Erubi was and how slow HAML is. The gulf between solutions here is quite great. However, don't underestimate developer productivity here.


I wanted to see how fast different Markdown converters were (especially compared to other markup converters).

The competitors:

Engine Iterations per second
Redcarpet 15475.4
CommonMarker 11321.1
BlueCloth 11233.3
RedCloth 4743.6
Asciidoctor 2377.0
Creole 1947.9
WikiText 1610.2
Maruku 1428.8
Kramdown 940.4

Obviously, gems with a C extension have an edge here. The old standby, Redcarpet, still performs quite well here. Kramdown, my typical choice for static site generators like Jekyll, is slowest but quick enough for most stuff. You probably shouldn't be converting markup that much. Do it once and store the result!


I don't actually remember why I was benchmarking all of these, but I did.

The competitors are:

Given a very simple payload of

data = {
  account_id: 1,
  type: 'artist_update',
  subject: {
    id: 1,
    type: 'Artist'
  author: {
    id: 1,
    type: 'Account'
Format File size (in bytes)
MessagePack 82
JSON 109
YAML 110
BSON 123

Ruby to data

Format Iterations per second
CBOR 892477.6
MessagePack 655391.9
BSON 389066.6
JSON 152686.7
YAML 7831.1

Data to Ruby

Format Iterations per second
CBOR 360230.3
BSON 312189.8
MessagePack 177722.6
JSON 152348.3
YAML 5501.0

I've never used CBOR, but now I know it's a good option!

I'm a big fan of Dokku for simple deployment on my server. It's running this website you're currently reading, for one! However, deploying apps on it that break outside of the patterns. WriteFreely is one of those.

If you want to deploy it via Dokku, it's actually pretty easy. To save others the trouble of having to figure it out themselves, I've put together the required files and instructions in a git repo.

You can also follow the instructions below.


You must have Dokku installed on your server already for these steps to work. I won't walk through all that here.


First, create a new folder on your local computer and create a file named Dockerfile in it. Put the lines below in that file with a text editor:

FROM writeas/writefreely

COPY config.ini .


CMD ["bin/writefreely"]

Next, create a file named config.ini and put the lines below in that file with a text editor (note: you'll want to change some of the values to match your desires):

hidden_host          = 
port                 = 8080
bind                 =
tls_cert_path        = 
tls_key_path         = 
templates_parent_dir = 
static_parent_dir    = 
pages_parent_dir     = 
keys_parent_dir      = 

type     = sqlite3
filename = db/writefreely.db
username = 
password = 
database = 
host     = localhost
port     = 3306

site_name         = Write Freely
site_description  = 
host              = http://writefreely.example.com
theme             = write
disable_js        = false
webfonts          = true
single_user       = false
open_registration = true
min_username_len  = 3
max_blogs         = 3
federation        = true
public_stats      = true
private           = false
local_timeline    = true
user_invites      = user

Then, connect to your server via SSH and create the writefreely app.

dokku apps:create writefreely

Then, setup the directories for WriteFreely's data so it won't be wiped each time you re-deploy.

mkdir -p /var/lib/dokku/data/storage/writefreely/{db,keys}
chown daemon:daemon /var/lib/dokku/data/storage/writefreely/*
dokku storage:mount writefreely /var/lib/dokku/data/storage/writefreely/keys:/go/keys
dokku storage:mount writefreely /var/lib/dokku/data/storage/writefreely/db:/go/db
dokku proxy:ports-set writefreely http:80:8080

Next, open the folder the files you downloaded from this repo are in. Initialize a git repo in it.

git init
git add --all
git commit -m "Init"
git remote add dokku dokku@[YOUR SERVER'S IP OR URL]:writefreely
git push dokku master

This deploy will fail. You can then initialize WriteFreely's database and keys.

dokku run writefreely bin/writefreely --init-db
dokku run writefreely bin/writefreely --gen-keys

Finally, you can rebuild the app and it'll run as expected.

dokku ps:rebuild writefreely

If you have any problems, contact me via Mastodon or Twitter and I'll try to help.