Skip to content

Instantly share code, notes, and snippets.

View ajvondrak's full-sized avatar

Alex Vondrak ajvondrak

View GitHub Profile
@ajvondrak
ajvondrak / bench.exs
Last active January 28, 2021 01:14
Benchmarking Enum vs MapSet usage for ajvondrak/remote_ip
defmodule Algorithm do
@enum ~w[forwarded x-forwarded-for x-client-ip x-real-ip]
@mapset MapSet.new(@enum)
def using_enum(input) do
Enum.filter(input, &Enum.member?(@enum, &1))
end
def using_mapset(input) do
Enum.filter(input, &MapSet.member?(@mapset, &1))
@ajvondrak
ajvondrak / exsampling.rb
Created July 14, 2020 02:33
Honeycomb sampling examples
require 'bundler/inline'
gemfile { gem 'honeycomb-beeline', source: 'https://rubygems.org' }
### Configuration ##############################################################
#
# We look at the event for the `app.drop` field. If true, we drop the event. If
# false, we keep the event. We'll then look at how adding the `app.drop` field
# in different ways to different spots affects the overall trace.
#
################################################################################
@ajvondrak
ajvondrak / Gemfile
Last active May 26, 2016 21:16
Goliath dependencies
source 'https://rubygems.org'
gem 'minitest', group: :test
gem 'goliath',
git: '[email protected]:postrank-labs/goliath.git',
ref: '1aeb2ae7e6d95a79897fda8d65bcdd4318336c53'
gem 'em-http-request' # required, but not declared...?
@ajvondrak
ajvondrak / Gemfile
Last active September 17, 2015 20:19
ActiveSupport::TimeWithZone performance
source 'http://rubygems.org'
gem 'activesupport', '4.2.4'
gem 'stackprof'
gem 'fast_blank', require: false
@ajvondrak
ajvondrak / gist:4399762
Created December 28, 2012 17:02
Out-of-SSA fib example
: fib ( a -- b b )
{ fixnum } declare [ 0 1 ] dip [ [ + ] keep swap >fixnum ] times ;
After tweaking ##parallel-copy live-ranges, we get the following out-of-SSA CFG (I've taken the liberty of renaming the vregs per the leader-map):
=== word: fib, label: fib
=== Basic block #0
##safepoint
@ajvondrak
ajvondrak / circular-dependencies.factor
Created November 28, 2012 04:04
Tracking circular dependencies between vocabs in Factor
USING: assocs fry io io.encodings.utf8 io.files kernel
path-finding regexp sequences splitting tools.crossref vocabs
vocabs.hierarchy vocabs.loader ;
IN: circular-dependencies
: vocab-source-code ( vocab -- str )
vocab-source-path [ utf8 file-contents ] [ "" ] if* ;
: using-line ( source -- vocabs )
R/ USING: [^;]* ;/s all-matching-subseqs ?first
@ajvondrak
ajvondrak / bench-diff.py
Created November 4, 2012 04:51
GVN Benchmarks
def benchmarks(infile):
bms = (line.split() for line in open(infile))
return {bm:float(secs) for bm, secs in bms}
lvn = benchmarks('lvn.bench')
gvn = benchmarks('gvn.bench')
def diff(bm):
return 100 * (gvn[bm] - lvn[bm]) / lvn[bm]
@ajvondrak
ajvondrak / GVN
Created September 14, 2012 00:20
SIMD tests
This file has been truncated, but you can view the full file.
! Using GVN
t "print-mr" set
t "print-checks" set
"math.vectors.simd" test
Unit Test: {
[ V{ float } ]
[ [ { float-4 } declare norm-sq ] final-classes ]
}
Unit Test: {