This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from benchmarker import Benchmarker | |
import collections | |
with Benchmarker(width=40, loop=100000) as bm: | |
for _ in bm('empty dict'): | |
collections.Counter({}) | |
for _ in bm('none'): | |
collections.Counter() | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nose.tools import eq_, assert_equal | |
a = [1, 2, 3] | |
b = [1, 5, 3] | |
def test_eq(): | |
eq_(a, b) | |
def test_assert_equal(): | |
assert_equal(a, b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nose.tools import assert_equal | |
a = [] | |
b = [] | |
for i in xrange(1000): | |
a.append(i) | |
b.append(i) | |
a.append('a') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from benchmarker import Benchmarker | |
items = [1, 'foo', 'bar', 0, 0, 0] | |
with Benchmarker(width=40, loop=1000000) as bm: | |
for _ in bm('map'): | |
map(str, items) | |
for _ in bm('list'): | |
[str(x) for x in items] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from benchmarker import Benchmarker | |
items = ['foo', 'bar', 'baz', 'hoge'] | |
import copy | |
with Benchmarker(width=40, loop=100000) as bm: | |
for _ in bm('list'): | |
x = list(items) | |
for _ in bm('slice'): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import argparse | |
import re | |
import sys | |
from collections import namedtuple | |
import git | |
match_serial = re.compile(r'^\+\s+(\d{10})\s*; serial$').match |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from benchmarker import Benchmarker | |
from itertools import ifilter | |
f = lambda x: x % 2 | |
with Benchmarker(width=40, loop=1000) as bm: | |
for _ in bm('filter'): | |
list(filter(f, xrange(10000))) | |
for _ in bm('ifilter'): | |
list(ifilter(f, xrange(10000))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from benchmarker import Benchmarker | |
import json | |
import ujson | |
imp_obj = { | |
'rectangle': {'tagid': '12345', 'banner': {'w': 300, 'h': 250}}, | |
'big_banner': {'tagid': '22222', 'banner': {'w': 728, 'h': 90}}, | |
'rectangle_with_inventory': {'tagid': '10000', 'banner': {'w': 300, 'h': 250}}, | |
'banned': {'tagid': '54321', 'banner': {'w': 300, 'h': 250}}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import sys | |
import time | |
p = subprocess.Popen( | |
('redis-server', '--port', '6379', '--bind', '127.0.0.1'), | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE) | |
WAIT = 0.001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!/bin/sh | |
ssh-agent | grep -v echo > "${HOME}/.ssh/agent-env" | |
. "${HOME}/.ssh/agent-env" | |
ssh-add | |
echo "please type:" | |
echo ". ~/.ssh/agent-env" |
OlderNewer