Skip to content

Instantly share code, notes, and snippets.

@cosven
Last active February 10, 2020 07:53
Show Gist options
  • Save cosven/d1880e0d4c933f22636d1c86a1f87df7 to your computer and use it in GitHub Desktop.
Save cosven/d1880e0d4c933f22636d1c86a1f87df7 to your computer and use it in GitHub Desktop.
profiling playlist_add fuocore.SongModel
import cProfile
from fuocore.models import SongModel
songs_10k = [SongModel(identifier=i) for i in range(0, 4000)]
songs = []
def playlist_add(song):
if song not in songs:
songs.append(song)
def t():
for song in songs_10k:
playlist_add(song)
cProfile.run('t()')
"""
55994004 function calls in 34.375 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 34.375 34.375 <string>:1(<module>)
31992000 20.231 0.000 20.231 0.000 __init__.py:298(__getattribute__)
7998000 10.806 0.000 32.691 0.000 __init__.py:530(__eq__)
1 0.002 0.002 34.375 34.375 t.py:19(t)
4000 1.681 0.000 34.373 0.009 t.py:8(playlist_add)
7998000 0.970 0.000 0.970 0.000 {built-in method builtins.all}
1 0.000 0.000 34.375 34.375 {built-in method builtins.exec}
7998000 0.684 0.000 0.684 0.000 {built-in method builtins.isinstance}
4000 0.001 0.000 0.001 0.000 {method 'append' of 'list' objects}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment