Home Download Buy Blog Forum Support

Goto Symbol performance issue

Goto Symbol performance issue

Postby bizoo on Mon Sep 26, 2011 7:18 am

Updating my plugins to use the new view.find_by_selector method, I found something interesting:
Before my plugin used view.get_symbols and was slow with some very big source (and 'Goto Symbol' function also).
So I changed it to use self.view.find_by_selector with the same searching scope and the result is beyond my expectation.
Code: Select all
import sublime, sublime_plugin
import time

class TestSymbolListCommand(sublime_plugin.TextCommand):
   def run(self, edit):
      print "*view.find_by_selector:"
      # mimic view.get_symbols()
      btime = time.time()
      self.classlist1 = [(pos, self.view.substr(pos)) for pos in self.view.find_by_selector('source.pascal meta.function.pascal, source.pascal meta.class.pascal entity.name.class.pascal')]
      print time.time() - btime
      print len(self.classlist1)

      print "*view.get_symbols:"
      btime = time.time()
      self.classlist2 = self.view.get_symbols()
      print time.time() - btime
      print len(self.classlist2)
      print "*compare result:"
      print self.classlist1 == self.classlist2

And this the result on a very large Pascal file:
Code: Select all
>>> view.run_command('test_symbol_list')
*view.find_by_selector:
0.0929999351501
17548
*view.get_symbols:
4.77500009537
17548
*compare result:
True

So the view.get_symbols is near 5 seconds and view.find_by_selector is 0.1 second.
It must be something wrong with view.get_symbols, what do you think Jon ?
bizoo
 
Posts: 886
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Goto Symbol performance issue

Postby jps on Mon Sep 26, 2011 10:15 am

Yeah, there's a some performance issue with get_symbols that I haven't had a chance to look at yet
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm


Return to General Discussion

Who is online

Users browsing this forum: ChogyDan, Yahoo [Bot] and 29 guests