Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@multani
Created January 20, 2014 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save multani/8513651 to your computer and use it in GitHub Desktop.
Save multani/8513651 to your computer and use it in GitHub Desktop.
Sonata Speed To be run from the Sonata directory at https://github.com/multani/sonata
import gettext
gettext.install('sonata')
import cProfile
import time
from gi.repository import Gtk
import mpd
from sonata import mpdhelper
class Timer:
def __init__(self):
self.t = time.time()
def mark(self, message):
t = time.time()
print("{}: {}".format(message, t - self.t))
self.t = t
profiler = cProfile.Profile()
t = Timer()
#profiler.enable()
store = Gtk.ListStore(mpdhelper.MPDSong)
m = mpd.MPDClient()
m.connect('localhost', 6600)
t.mark("Connect")
songs = m.plchanges(0)
t.mark("Fetch")
songs = [mpdhelper.MPDSong(s) for s in songs]
t.mark("Convert")
for song in songs:
store.insert_with_valuesv(-1, [0], [song])
t.mark("Insert")
#profiler.disable()
#profiler.dump_stats("profile.profile")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment