Created
January 21, 2015 01:31
-
-
Save bmcfee/a53223288773538826e8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:6fea87d57fe429b6b81d47499fec517e45529329191357befb93c452cff2046d" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import librosa\n", | |
"import numpy as np\n", | |
"import matplotlib.pyplot as plt\n", | |
"import seaborn\n", | |
"seaborn.set(style='dark')\n", | |
"%matplotlib inline" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"y, sr = librosa.load(librosa.util.example_audio_file())" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"for n_fft in [512, 1024, 2048]:\n", | |
" for hop_length in [n_fft / 2, n_fft / 4, n_fft / 16]:\n", | |
" print 'n_fft={:4d}, hop={:4d}\\n'.format(n_fft, hop_length), \n", | |
" for MEM_BLOCK in 2**(20 + np.arange(-4, 5)):\n", | |
" librosa.util.MAX_MEM_BLOCK = MEM_BLOCK\n", | |
" print '\\tMEM BLOCK ={mb:>8.2f}MB | \\t'.format(mb=2**(np.log2(librosa.util.MAX_MEM_BLOCK) - 20)),\n", | |
" %timeit librosa.stft(y, n_fft=n_fft, hop_length=hop_length)\n", | |
" print" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"n_fft= 512, hop= 256\n", | |
"\tMEM BLOCK = 0.06MB | \t10 loops, best of 3: 32.7 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.12MB | \t10 loops, best of 3: 31.8 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.25MB | \t10 loops, best of 3: 31.4 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.50MB | \t10 loops, best of 3: 33.3 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 1.00MB | \t10 loops, best of 3: 34.9 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 2.00MB | \t10 loops, best of 3: 37.6 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 4.00MB | \t10 loops, best of 3: 38.3 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 8.00MB | \t10 loops, best of 3: 40 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 16.00MB | \t10 loops, best of 3: 40.2 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\n", | |
"n_fft= 512, hop= 128\n", | |
"\tMEM BLOCK = 0.06MB | \t10 loops, best of 3: 60.1 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.12MB | \t10 loops, best of 3: 59.3 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.25MB | \t10 loops, best of 3: 58.2 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.50MB | \t10 loops, best of 3: 61.2 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 1.00MB | \t10 loops, best of 3: 65.1 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 2.00MB | \t10 loops, best of 3: 70.5 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 4.00MB | \t10 loops, best of 3: 76.8 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 8.00MB | \t10 loops, best of 3: 87 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 16.00MB | \t10 loops, best of 3: 76.4 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\n", | |
"n_fft= 512, hop= 32\n", | |
"\tMEM BLOCK = 0.06MB | \t1 loops, best of 3: 235 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.12MB | \t1 loops, best of 3: 233 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.25MB | \t1 loops, best of 3: 374 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.50MB | \t1 loops, best of 3: 256 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 1.00MB | \t1 loops, best of 3: 273 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 2.00MB | \t1 loops, best of 3: 278 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 4.00MB | \t1 loops, best of 3: 288 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 8.00MB | \t1 loops, best of 3: 323 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 16.00MB | \t1 loops, best of 3: 309 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\n", | |
"n_fft=1024, hop= 512\n", | |
"\tMEM BLOCK = 0.06MB | \t10 loops, best of 3: 33.9 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.12MB | \t10 loops, best of 3: 33.4 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.25MB | \t10 loops, best of 3: 33.8 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.50MB | \t10 loops, best of 3: 34.3 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 1.00MB | \t10 loops, best of 3: 37 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 2.00MB | \t10 loops, best of 3: 38.1 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 4.00MB | \t10 loops, best of 3: 39.1 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 8.00MB | \t10 loops, best of 3: 39.8 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 16.00MB | \t10 loops, best of 3: 43.2 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\n", | |
"n_fft=1024, hop= 256\n", | |
"\tMEM BLOCK = 0.06MB | \t10 loops, best of 3: 66.5 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.12MB | \t10 loops, best of 3: 62.2 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.25MB | \t10 loops, best of 3: 62.5 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.50MB | \t10 loops, best of 3: 62 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 1.00MB | \t10 loops, best of 3: 70.1 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 2.00MB | \t10 loops, best of 3: 71.7 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 4.00MB | \t10 loops, best of 3: 73.3 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 8.00MB | \t10 loops, best of 3: 76.1 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 16.00MB | \t10 loops, best of 3: 76.3 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\n", | |
"n_fft=1024, hop= 64\n", | |
"\tMEM BLOCK = 0.06MB | \t1 loops, best of 3: 247 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.12MB | \t1 loops, best of 3: 244 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.25MB | \t1 loops, best of 3: 234 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.50MB | \t1 loops, best of 3: 237 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 1.00MB | \t1 loops, best of 3: 271 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 2.00MB | \t1 loops, best of 3: 278 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 4.00MB | \t1 loops, best of 3: 283 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 8.00MB | \t1 loops, best of 3: 280 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 16.00MB | \t1 loops, best of 3: 297 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\n", | |
"n_fft=2048, hop=1024\n", | |
"\tMEM BLOCK = 0.06MB | \t10 loops, best of 3: 36.8 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.12MB | \t10 loops, best of 3: 36.5 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.25MB | \t10 loops, best of 3: 35.3 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.50MB | \t10 loops, best of 3: 35.5 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 1.00MB | \t10 loops, best of 3: 39.4 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 2.00MB | \t10 loops, best of 3: 42.1 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 4.00MB | \t10 loops, best of 3: 41 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 8.00MB | \t10 loops, best of 3: 41 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 16.00MB | \t10 loops, best of 3: 44 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\n", | |
"n_fft=2048, hop= 512\n", | |
"\tMEM BLOCK = 0.06MB | \t10 loops, best of 3: 67.3 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.12MB | \t10 loops, best of 3: 66 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.25MB | \t10 loops, best of 3: 65 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.50MB | \t10 loops, best of 3: 65.7 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 1.00MB | \t10 loops, best of 3: 75 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 2.00MB | \t10 loops, best of 3: 77.4 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 4.00MB | \t10 loops, best of 3: 77 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 8.00MB | \t10 loops, best of 3: 80.3 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 16.00MB | \t10 loops, best of 3: 80.6 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\n", | |
"n_fft=2048, hop= 128\n", | |
"\tMEM BLOCK = 0.06MB | \t1 loops, best of 3: 263 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.12MB | \t1 loops, best of 3: 255 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.25MB | \t1 loops, best of 3: 251 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 0.50MB | \t1 loops, best of 3: 255 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 1.00MB | \t1 loops, best of 3: 289 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 2.00MB | \t1 loops, best of 3: 300 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 4.00MB | \t1 loops, best of 3: 299 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 8.00MB | \t1 loops, best of 3: 302 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\tMEM BLOCK = 16.00MB | \t1 loops, best of 3: 312 ms per loop" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"\n", | |
"\n" | |
] | |
} | |
], | |
"prompt_number": 47 | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment