gnome-prototypes-team / gnome-music

Gnome Music
https://live.gnome.org/Music
Other
5 stars 13 forks source link

songs view: cache renders #107

Closed vrutkovs closed 10 years ago

vrutkovs commented 11 years ago
File: ./gnomemusic/view.py
Function: _on_list_widget_title_render at line 364
Total time: 0.163558 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   364                                               @profile
   365                                               def _on_list_widget_title_render(self, col, cell, model, itr, data):
   366      2160        25808     11.9     15.8          item = model.get_value(itr, 5)
   367      2160        18841      8.7     11.5          cell.set_property("xalign", 0.0)
   368      2160        16536      7.7     10.1          cell.set_property("yalign", 0.5)
   369      2160        12776      5.9      7.8          cell.set_property("height", 48)
   370      2160        35826     16.6     21.9          cell.set_property("ellipsize", Pango.EllipsizeMode.END)
   371      2160        53771     24.9     32.9          cell.set_property("text", albumArtCache.get_media_title(item))

File: ./gnomemusic/view.py
Function: _on_list_widget_star_render at line 373
Total time: 0.045659 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   373                                               @profile
   374                                               def _on_list_widget_star_render(self, col, cell, model, itr, data):
   375      2160        23310     10.8     51.1          showstar = model.get_value(itr, 9)
   376      2160         2392      1.1      5.2          if(showstar):
   377                                                       cell.set_property("icon_name", self.starIconName)
   378                                                   else:
   379      2160        19957      9.2     43.7              cell.set_property("pixbuf", None)

File: ./gnomemusic/view.py
Function: _on_list_widget_duration_render at line 381
Total time: 0.108221 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   381                                               @profile
   382                                               def _on_list_widget_duration_render(self, col, cell, model, itr, data):
   383      2160        26597     12.3     24.6          item = model.get_value(itr, 5)
   384      2160         2669      1.2      2.5          if item:
   385      2160        16396      7.6     15.2              seconds = item.get_duration()
   386      2160         3713      1.7      3.4              minutes = seconds // 60
   387      2160         2645      1.2      2.4              seconds %= 60
   388      2160        19921      9.2     18.4              cell.set_property("xalign", 1.0)
   389      2160        36280     16.8     33.5              cell.set_property("text", "%i:%02i" % (minutes, seconds))

File: ./gnomemusic/view.py
Function: _on_list_widget_artist_render at line 391
Total time: 0.14692 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   391                                               @profile
   392                                               def _on_list_widget_artist_render(self, col, cell, model, itr, data):
   393      2160        30241     14.0     20.6          item = model.get_value(itr, 5)
   394      2160         2607      1.2      1.8          if item:
   395      2160        45253     21.0     30.8              cell.set_property("ellipsize", Pango.EllipsizeMode.END)
   396      2160        68819     31.9     46.8              cell.set_property("text", item.get_string(Grl.METADATA_KEY_ARTIST))

File: ./gnomemusic/view.py
Function: _on_list_widget_type_render at line 398
Total time: 0.12605 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   398                                               @profile
   399                                               def _on_list_widget_type_render(self, coll, cell, model, itr, data):
   400      2160        23451     10.9     18.6          item = model.get_value(itr, 5)
   401      2160         2379      1.1      1.9          if item:
   402      2160        37408     17.3     29.7              cell.set_property("ellipsize", Pango.EllipsizeMode.END)
   403      2160        62812     29.1     49.8              cell.set_property("text", item.get_string(Grl.METADATA_KEY_ALBUM))
kyoushuu commented 11 years ago

Instead of caching, we could just set the properties during construction or map them to their list store columns.

kyoushuu commented 11 years ago

The pull request is now merged. It could be further improved though, we could do the same thing on album title as what I've done on song title renderer and artist name renderer. Though I think it's better to separate the list store to each view instead of having it in ViewContainer - doing the fix for the album title requires a new column to the list store but it will be unused in other views. That would eat up some memory instead, especially if we have many songs.

If what is done is already enough, please close the issue. :D