Created
January 20, 2014 01:48
-
-
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
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
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