Sublime Forum

Goto Symbol performance issue

#1

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]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[/code]

And this the result on a very large Pascal file:

>>> 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 ?

0 Likes

Sorting CTRL-R
#2

Yeah, there’s a some performance issue with get_symbols that I haven’t had a chance to look at yet

0 Likes