Move line profiling from experimental plugin to profiler module; fix NPE
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Tue, 18 Oct 2016 10:01:56 +0000 (12:01 +0200)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Tue, 18 Oct 2016 10:01:56 +0000 (12:01 +0200)
python/helpers/profiler/vmprof_profiler.py

index e941abdcab1566be05d909266439866c9554cdf2..2157055a1d7dc9b67b09714d2bf73e69eccce4ae 100644 (file)
@@ -1,10 +1,10 @@
+import os
+import shutil
+import tempfile
 import vmprof
 
-import os
 import six
 from _prof_imports import TreeStats, CallTreeStat
-import tempfile
-import shutil
 
 
 class VmProfProfile(object):
@@ -30,7 +30,10 @@ class VmProfProfile(object):
             if not os.path.exists(self.basepath):
                 os.makedirs(self.basepath)
             self.file = tempfile.NamedTemporaryFile(delete=False, dir=self.basepath)
-            vmprof.enable(self.file.fileno())
+            try:
+                vmprof.enable(self.file.fileno(), lines=True)
+            except:
+                vmprof.enable(self.file.fileno())
             self.is_enabled = True
 
     def disable(self):