Skip to content

Instantly share code, notes, and snippets.

@pv
pv / gist:8760183
Created February 1, 2014 22:46
Benchmark for PR-2754
$ python runtests.py --bench -t scipy/linalg/benchmarks/bench_levinson_durbin.py
Building, see build.log...
Build OK
Running benchmarks for scipy
NumPy version 1.7.1
NumPy is installed in /usr/lib/python2.7/dist-packages/numpy
SciPy version 0.14.0.dev-649d452
SciPy is installed in /home/pauli/prj/scipy/scipy/build/testenv/lib/python2.7/site-packages/scipy
Python version 2.7.5+ (default, Sep 19 2013, 13:48:49) [GCC 4.8.1]
nose version 1.3.0
from scipy.sparse import lil_matrix
from numpy import where, zeros, prod, vstack, ones
from time import time
n, m = 1000, 20000
M = vstack((zeros((n, m)), ones((25, m)))) # this changes time for lil very sufficiently
I, J = where(M)
# 1: time for sparse
M = lil_matrix(M)
Function "fpinst" not defined.
Breakpoint 1 (fpinst) pending.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, fpinst (iopt=0, t=..., n=104, c=..., k=3, x=0,5, l=81, tt=..., nn=0, cc=..., nest=106) at scipy/interpolate/fitpack/fpinst.f:1
1 subroutine fpinst(iopt,t,n,c,k,x,l,tt,nn,cc,nest)
#0 fpinst (iopt=0, t=..., n=104, c=..., k=3, x=0,5, l=81, tt=..., nn=0, cc=..., nest=106) at scipy/interpolate/fitpack/fpinst.f:1
#1 0x00007fffeec867cc in insert (iopt=0, t=..., n=104, c=..., k=3, x=0,5, tt=..., nn=0, cc=..., nest=106, ier=0) at scipy/interpolate/fitpack/insert.f:100
#2 0x00007fffeec78742 in fitpack_insert (dummy=0x0, args=0x15afef0) at scipy/interpolate/src/__fitpack.h:827
@pv
pv / gist:9102868
Last active August 29, 2015 13:56
$ python runtests.py --bench \
-t scipy/sparse/benchmarks/bench_sparse.py:BenchmarkSparse.bench_setitem \
-t scipy/sparse/benchmarks/bench_sparse.py:BenchmarkSparse.bench_getitem
BEFORE (32cd96d98b040) AFTER (c5e3ae442639b98)
Sparse Matrix fancy __setitem__ Sparse Matrix fancy __setitem__
========================================================== ==========================================================
N | s.patt. | csr | csc | lil | dok | N | s.patt. | csr | csc | lil | dok |
@pv
pv / counter.py
Last active August 29, 2015 13:57
#!/usr/bin/env python
"""
counter.py
Count the number of elementwise and matrix multiplication call sites,
by running code and intercepting calls.
"""
import os
import sys
import argparse
@pv
pv / bug.c
Last active August 29, 2015 14:04
Apparently a gfortran bug on OSX
#include <locale.h>
#include <stdio.h>
int badcall_();
int main()
{
FILE *f;
f = fopen("bug.dat", "w");
fprintf(f, "1.2345\n");
fclose(f);
@pv
pv / out.dat
Created September 10, 2014 18:46
qvoronoi strangeness
30
5 1 10 0 2 1
5 1 4 0 2 1
5 3 12 0 3 1
5 3 4 0 3 1
5 4 7 0 3 4
5 4 5 0 2 4
6 4 13 1 2 4 3
5 5 14 0 4 2
5 7 16 3 4 0
import numpy as np
from scipy import sparse
import time
import pysparse
def main():
print "%-6s %15s %15s " % ("% N", "scipy.sparse", "pysparse")
for N in xrange(5, 16):
N = 2**N
Levinson-Durbin vs. generic solver
T x = y; T.shape == (n, n); y.shape == (n, m)
==============================================================
n | m | dtype | L-D time | generic time
| | | (seconds) |
--------------------------------------------------------------
100 | 1 | float64 | 0.00122 | 0.00189
100 | 10 | float64 | 0.00727 | 0.0019
100 | 100 | float64 | 0.0666 | 0.00459
100 | 1000 | float64 | 0.614 | 0.0171
Levinson-Durbin [Cython version from pr-4302] vs. generic solver
T x = y; T.shape == (n, n); y.shape == (n, m)
==============================================================
n | m | dtype | L-D time | generic time
| | | (seconds) |
--------------------------------------------------------------
100 | 1 | float64 | 0.000103 | 0.000162
100 | 10 | float64 | 0.000561 | 0.000167
300 | 1 | float64 | 0.000258 | 0.00136