Skip to content

Instantly share code, notes, and snippets.

@antocuni
antocuni / bm_telco.py
Last active April 14, 2017 13:06
pypy telco benchmark
# coding: UTF-8
""" Telco Benchmark for measuring the performance of decimal calculations
http://www2.hursley.ibm.com/decimal/telco.html
http://www2.hursley.ibm.com/decimal/telcoSpec.html
A call type indicator, c, is set from the bottom (least significant) bit of the duration (hence c is 0 or 1).
A r, r, is determined from the call type. Those calls with c=0 have a low r: 0.0013; the remainder (‘distance calls’) have a ‘premium’ r: 0.00894. (The rates are, very roughly, in Euros or dollarates per second.)
A price, p, for the call is then calculated (p=r*n). This is rounded to exactly 2 fractional digits using round-half-even (Banker’s round to nearest).
A basic tax, b, is calculated: b=p*0.0675 (6.75%). This is truncated to exactly 2 fractional digits (round-down), and the total basic tax variable is then incremented (sumB=sumB+b).
@antocuni
antocuni / pandasleak.py
Created March 2, 2017 14:10
pandas leak on pypy
import sys
import pandas as pd
import numpy as np
from plotmem import Plotmem
import gc
def leak1():
for i in Plotmem(100):
df = pd.DataFrame(
{'A': ['foo', 'bar'],
@antocuni
antocuni / bench.cpp
Last active November 16, 2016 13:44
branch prediction
#include <algorithm>
#include <ctime>
#include <iostream>
int main(int argc, char** argv)
{
// Generate data
const unsigned arraySize = 32768;
int data[arraySize];