@@ -246,6 +246,7 @@ def list
246246 option :output_dir , type : :string , aliases : :o , desc : 'The output directory for profiles' , default : './tmp/profiles'
247247 option :line , type : :numeric , aliases : :l , desc : 'Line number (0-based)' , default : 4
248248 option :column , type : :numeric , aliases : :c , desc : 'Column number' , default : 10
249+ option :memory , type : :boolean , aliases : :m , desc : 'Include memory usage counter' , default : true
249250 # @param file [String, nil]
250251 # @return [void]
251252 def profile ( file = nil ) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
@@ -256,6 +257,9 @@ def profile(file = nil) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
256257 return
257258 end
258259
260+ hooks = [ ]
261+ hooks << :memory_usage if options [ :memory ]
262+
259263 directory = File . realpath ( options [ :directory ] )
260264 FileUtils . mkdir_p ( options [ :output_dir ] )
261265
@@ -267,7 +271,7 @@ def host.send_notification method, params
267271
268272 puts "Parsing and mapping source files..."
269273 prepare_start = Time . now
270- Vernier . profile ( out : "#{ options [ :output_dir ] } /parse_benchmark.json.gz" ) do
274+ Vernier . profile ( out : "#{ options [ :output_dir ] } /parse_benchmark.json.gz" , hooks : hooks ) do
271275 puts "Mapping libraries"
272276 host . prepare ( directory )
273277 sleep 0.2 until host . libraries . all? ( &:mapped? )
@@ -276,7 +280,7 @@ def host.send_notification method, params
276280
277281 puts "Building the catalog..."
278282 catalog_start = Time . now
279- Vernier . profile ( out : "#{ options [ :output_dir ] } /catalog_benchmark.json.gz" ) do
283+ Vernier . profile ( out : "#{ options [ :output_dir ] } /catalog_benchmark.json.gz" , hooks : hooks ) do
280284 host . catalog
281285 end
282286 catalog_time = Time . now - catalog_start
@@ -303,7 +307,7 @@ def host.send_notification method, params
303307 puts "Position: line #{ options [ :line ] } , column #{ options [ :column ] } "
304308
305309 definition_start = Time . now
306- Vernier . profile ( out : "#{ options [ :output_dir ] } /definition_benchmark.json.gz" ) do
310+ Vernier . profile ( out : "#{ options [ :output_dir ] } /definition_benchmark.json.gz" , hooks : hooks ) do
307311 message = Solargraph ::LanguageServer ::Message ::TextDocument ::Definition . new (
308312 host , {
309313 'params' => {
0 commit comments