Skip to content

Instantly share code, notes, and snippets.

View smerritt's full-sized avatar

Sam Merritt smerritt

View GitHub Profile
#!/bin/bash
set -e
CONTAINER="ds-test"
echo "Test setup"
# Set up some data segments (these are just plain objects)
TOKEN="`swift stat -v | grep "Auth Token" | cut -d : -f 2`"
STORAGE_URL="`swift stat -v | grep "StorageURL" | cut -d : -f 2,3,4,5,6`"

Keybase proof

I hereby claim:

  • I am smerritt on github.
  • I am torgomatic (https://keybase.io/torgomatic) on keybase.
  • I have a public key whose fingerprint is 0884 5E48 A250 564F 5906 892D C21B C799 8554 5617

To claim this, I am signing this object:

#!/usr/bin/env python
import benchmark
from swift.container.backend import ContainerBroker
class BenchmarkListingOperations(benchmark.Benchmark):
def setUp(self):
self.broker = ContainerBroker("big-container-db/big.db",
account='big-a', container='big-c')
#!/usr/bin/env python
#
# Ring Finder 3000: finds rings that break the builder
import os
import pickle
import random
import time
import traceback
from StringIO import StringIO
@smerritt
smerritt / find-max-xattr-size.py
Created December 5, 2014 23:03
find max supported xattr size
#!/usr/bin/env python
import xattr
XATTR_NAME = 'user.xattr-test'
MAX_SIZE = 2**20 + 1 # if it's over 1 MiB, call it infinite
def works(fileno, size):
try:
@smerritt
smerritt / bench-xattr.py
Created December 5, 2014 22:11
benchmarking different xattr sizes on XFS on a spinning disk
#!/usr/bin/env python
import benchmark
import cPickle as pickle
import hashlib
import os
import xattr
PILE_O_METADATA = pickle.dumps(dict(
("attribute%d" % i, hashlib.sha512("thingy %d" % i).hexdigest())
@smerritt
smerritt / Benchmark results
Created November 25, 2014 19:31
Benchmarking Python syscalls vs. exceptions vs. funcalls and such
~$ python bench.py
Benchmark Report
================
BenchmarkFlowControl
--------------------
name | rank | runs | mean | sd | timesBaseline
-------------------|------|-------|-----------|-----------|--------------
209-204-163-11:swift (ec-put-path)$ egrep '^inter.*er$' /usr/share/dict/words
intercarrier
interceder
intercepter
interchanger
interchapter
intercommoner
intercommuner
intercondenser
intercooler
@smerritt
smerritt / gist:bc0e242ed0b3fd424979
Last active August 29, 2015 14:06
zip() is self-inverse
>>> thing = [(1, 2, 3), ('a', 'b', 'c')]
>>> zip(*thing)
[(1, 'a'), (2, 'b'), (3, 'c')]
>>> zip(*zip(*thing))
[(1, 2, 3), ('a', 'b', 'c')]
>>>
function dammit() {
sudo `history -p \!\!`
}