Skip to content

Instantly share code, notes, and snippets.

View methane's full-sized avatar

Inada Naoki methane

  • KLab Inc,
  • Japan
  • 10:00 (UTC +09:00)
  • X @methane
View GitHub Profile
import io
from msgpack import fallback, packb
try:
from msgpack import _unpacker, _packer
has_ext = True
except ImportError:
has_ext = False
import timeit
"""
Compress FileHandler output with subprocess gzip.
"""
import subprocess
import logbook
from logbook.helpers import is_unicode
class GZFileHandler(logbook.FileHandler):
CREATE TABLE `TEST` (
`id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO TEST (id) VALUES (1) (2) (3);
from __future__ import print_function
import json
bdata = b'{"foo0": "bar0","foo1": "bar1","foo2": "bar2","foo3": "bar3","foo4": "bar4","foo5": "bar5","foo6": "bar6"}'
udata = u'{"foo0": "bar0","foo1": "bar1","foo2": "bar2","foo3": "bar3","foo4": "bar4","foo5": "bar5","foo6": "bar6"}'
def decode_b():
json.loads(bdata)
import signal
import socket
import threading
import time
try:
import socketserver
except ImportError:
import SocketServer as socketserver

bench

$ numactl -C 16-35 memtier_benchmark -p 2222 -P memcache_binary -n 20000 -t 20 -c 10

go 1.5 / GOMAXPROCS=15

20        Threads
10        Connections per thread
20000     Requests per thread
$ go test -bench=. -benchmem
PASS
BenchmarkAnswer3 1000000 1248 ns/op 344 B/op 6 allocs/op
BenchmarkAnswer4 2000000 836 ns/op 128 B/op 1 allocs/op
import cProfile
import requests
import time
import pycohttpp.monkeypatch
def run_with_profile():
prof = cProfile.Profile()
prof.enable()
run()
prof.disable()
diff --git a/packets.go b/packets.go
index f39d65c..290a388 100644
--- a/packets.go
+++ b/packets.go
@@ -603,8 +603,13 @@ func (rows *textRows) readRow(dest []driver.Value) error {
// EOF Packet
if data[0] == iEOF && len(data) == 5 {
+ rows.mc = nil
return io.EOF
diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go
index 1ce679d..2ccf7b3 100644
--- a/src/database/sql/sql.go
+++ b/src/database/sql/sql.go
@@ -21,6 +21,7 @@ import (
"sort"
"sync"
"sync/atomic"
+ "time"
)