Skip to content

Instantly share code, notes, and snippets.

View tomlobato's full-sized avatar
🎯
Focusing

Tom Lobato tomlobato

🎯
Focusing
View GitHub Profile
@havenwood
havenwood / benchmark_results.rb
Last active May 26, 2021 12:49
Benchmarking serialization speed of YAML, JSON, Marshal, and MessagePack in Ruby, JRuby, and Rubinius
# ruby-2.5.0
user system total real
YAML 15.112795 0.030577 15.143372 ( 15.190573)
JSON 0.648957 0.001520 0.650477 ( 0.652856)
Marshal 0.474775 0.000922 0.475697 ( 0.477678)
MessagePack 0.326430 0.001763 0.328193 ( 0.330159)
# ruby-2.4.3
user system total real
YAML 20.400000 0.050000 20.450000 ( 20.517600)
@sawanoboly
sawanoboly / check_cert_period.rb
Created July 17, 2012 07:39
Checking expiry period of cert by ruby.
#!/usr/bin/env ruby
# -*- coding:utf-8 -*-
require 'socket'
require 'openssl'
require 'timeout'
require 'pp'
include OpenSSL
timeout=15
@jboner
jboner / latency.txt
Last active April 26, 2024 03:40
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
@Majkl578
Majkl578 / gist:892401
Created March 29, 2011 13:54
Heapsort on top of Ruby's array
class Array
def heapsort!
#heapify
1.upto(self.length - 1) do |i|
#move up
child = i
while child > 0
parent = (child - 1) / 2
if self[parent] < self[child]
self[parent], self[child] = self[child], self[parent]