Skip to content

Instantly share code, notes, and snippets.

View j2labs's full-sized avatar

The Ghost Of J2 Labs j2labs

View GitHub Profile
@jboner
jboner / latency.txt
Last active April 27, 2024 10:53
Latency Numbers Every Programmer Should Know
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
@robbyt
robbyt / spot_price.py
Created March 19, 2012 02:22
find standard average (mean) ec2 spot instance price
import boto
#type that you want to get pricing on
MY_TYPE = u'm1.small'
ec2 = boto.connect_ec2()
spots = ec2.get_spot_price_history(instance_type= MY_TYPE)
spot_prices = [i.price for i in spots]
@ox
ox / sinatra_autoapi.rb
Created March 15, 2012 03:28
Sinatra AutoAPI generator in the making
require 'sinatra'
require 'sinatra/namespace'
require 'mongoid'
ENV["RACK_ENV"] ||= "development"
Mongoid.load!("mongoid.yml")
class Note
include Mongoid::Document
field :body, type: String
@jhalcrow
jhalcrow / test_serial.py
Created April 2, 2011 14:23
Benchmark of different serialization methods in Python, adapted from a J2 Labs Tumblr post
# Adapted from http://j2labs.tumblr.com/post/4262756632/speed-tests-for-json-and-cpickle-in-python
import time
import cPickle as pickle
import simplejson
import json
import cjson
import jsonlib
import ujson