Skip to content

Instantly share code, notes, and snippets.

package main
import "testing"
var allowList = []string{
"create",
"cancel",
"update",
}
package main
import (
"testing"
"strconv"
"sync"
)
func BenchmarkCreateGoroutine(b *testing.B) {
nums := []int {
package main
import (
"context"
"fmt"
_ "net/http/pprof"
"time"
"github.com/pingcap/log"
"go.etcd.io/etcd/clientv3"
@amyangfei
amyangfei / cdc_stability_test_cases.md
Last active March 12, 2020 03:25
cdc stability test cases

sysbench insert

  • run sysbench insert for at least 12 hours
  • status: ✅

sysbench insert with multiple regions Pass

  • pre split regions
@amyangfei
amyangfei / redis_key_sizes.sh
Last active December 7, 2015 09:23
A simple script to print the size of Redis keys via scan
#!/bin/bash
# This script prints out all of your Redis keys and their size in a human readable format
# Inspired by https://gist.github.com/epicserve/5699837
# Copyright 2015 amyangfei
# License: http://www.apache.org/licenses/LICENSE-2.0
human_size() {
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print sum,"bytes"; } '
}
@amyangfei
amyangfei / dictobject.c
Last active August 29, 2015 14:13
python source learn
/* Dictionary reuse scheme to save calls to malloc, free, and memset */
// Dict对象缓冲池
#ifndef PyDict_MAXFREELIST
#define PyDict_MAXFREELIST 80
#endif
static PyDictObject *free_list[PyDict_MAXFREELIST];
static int numfree = 0;
PyObject *
PyDict_New(void)
from wsgiref.simple_server import make_server
class AppClass:
def __call__(self,environ, start_response):
status = '200 OK'
response_headers = [('Content-type', 'text/plain')]
start_response(status, response_headers)
return ["hello world!"]
import io, cStringIO, StringIO
import time
import functools
from memory_profiler import memory_usage
def data_gen():
return 'datadata' * 100
times = 1000000
dflt_interval = 0.5
#!/usr/bin/env python
# coding: utf-8
import json
import sys
import re
from tornado.httputil import url_concat
from tornado.httpclient import AsyncHTTPClient
from tornado.ioloop import IOLoop
@amyangfei
amyangfei / chksum.py
Last active August 29, 2015 14:10
memory profile for calculating md5 checksum with two methods(separating chunks reading and all in memory)
#!/usr/bin/env python
# coding: utf-8
import hashlib
import time
import functools
from memory_profiler import memory_usage
def print_timing(func):