[Lldb-commits] [lldb] r143075 - in /lldb/trunk/test: bench-history bench.py benchmarks/disassembly/TestDoAttachThenDisassembly.py benchmarks/startup/TestStartupDelays.py benchmarks/stepping/TestSteppingSpeed.py

Johnny Chen johnny.chen at apple.com
Wed Oct 26 15:58:02 PDT 2011


Author: johnny
Date: Wed Oct 26 17:58:02 2011
New Revision: 143075

URL: http://llvm.org/viewvc/llvm-project?rev=143075&view=rev
Log:
Establish a baseline for bench.py score by using a fixed lldb executable as the
inferior program for the lldb debugger to operate on.  The fixed lldb executable
corresponds to r142902.

Plus some minor modifications to the test benchmark to conform to way bench.py
is meant to be invoked.

Modified:
    lldb/trunk/test/bench-history
    lldb/trunk/test/bench.py
    lldb/trunk/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py
    lldb/trunk/test/benchmarks/startup/TestStartupDelays.py
    lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py

Modified: lldb/trunk/test/bench-history
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bench-history?rev=143075&r1=143074&r2=143075&view=diff
==============================================================================
--- lldb/trunk/test/bench-history (original)
+++ lldb/trunk/test/bench-history Wed Oct 26 17:58:02 2011
@@ -27,3 +27,15 @@
 lldb expr cmd benchmark: Avg: 0.207095 (Laps: 25, Total Elapsed Time: 5.177363)
 lldb disassembly benchmark: Avg: 0.001531 (Laps: 10, Total Elapsed Time: 0.015311)
 
+r143065 (Oct 26, 2011):
+# Establish a baseline by using a fixed lldb executable as the inferior program
+# for the lldb debugger to operate on.  The fixed lldb executable corresponds to
+# r142902.
+[15:50:34] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:'
+lldb startup delay (create fresh target) benchmark: Avg: 0.103774 (Laps: 30, Total Elapsed Time: 3.113226)
+lldb startup delay (set first breakpoint) benchmark: Avg: 0.102230 (Laps: 30, Total Elapsed Time: 3.066896)
+lldb startup delay (run to breakpoint) benchmark: Avg: 0.448635 (Laps: 30, Total Elapsed Time: 13.459048)
+lldb frame variable benchmark: Avg: 1.615647 (Laps: 20, Total Elapsed Time: 32.312934)
+lldb stepping benchmark: Avg: 0.138386 (Laps: 50, Total Elapsed Time: 6.919313)
+lldb expr cmd benchmark: Avg: 0.218967 (Laps: 25, Total Elapsed Time: 5.474171)
+lldb disassembly benchmark: Avg: 0.092677 (Laps: 10, Total Elapsed Time: 0.926766)

Modified: lldb/trunk/test/bench.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bench.py?rev=143075&r1=143074&r2=143075&view=diff
==============================================================================
--- lldb/trunk/test/bench.py (original)
+++ lldb/trunk/test/bench.py Wed Oct 26 17:58:02 2011
@@ -9,36 +9,59 @@
 
 Use the following to get only the benchmark results in your terminal output:
 
-    ./bench.py 2>&1 | grep -P '^lldb.*benchmark:'
+    ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:'
+
+See also bench-history.
 """
 
 import os, sys
 import re
+from optparse import OptionParser
 
 # dotest.py invocation with no '-e exe-path' uses lldb as the inferior program,
 # unless there is a mentioning of custom executable program.
 benches = [
-    # Measure startup delays creating a target and setting a breakpoint at main.
-    './dotest.py -v +b -n -p TestStartupDelays.py',
+    # Measure startup delays creating a target, setting a breakpoint, and run to breakpoint stop.
+    './dotest.py -v +b %E %X -n -p TestStartupDelays.py',
 
-    # Measure 'frame variable' response after stopping at Driver::MainLoop().
-    './dotest.py -v +b -x "-F Driver::MainLoop()" -n -p TestFrameVariableResponse.py',
+    # Measure 'frame variable' response after stopping at a breakpoint.
+    './dotest.py -v +b %E %X -n -p TestFrameVariableResponse.py',
 
-    # Measure stepping speed after stopping at Driver::MainLoop().
-    './dotest.py -v +b -x "-F Driver::MainLoop()" -n -p TestSteppingSpeed.py',
+    # Measure stepping speed after stopping at a breakpoint.
+    './dotest.py -v +b %E %X -n -p TestSteppingSpeed.py',
 
     # Measure expression cmd response with a simple custom executable program.
     './dotest.py +b -n -p TestExpressionCmd.py',
 
-    # Attach to a spawned lldb process then run disassembly benchmarks.
-    './dotest.py -v +b -n -p TestDoAttachThenDisassembly.py'
+    # Attach to a spawned process then run disassembly benchmarks.
+    './dotest.py -v +b -n %E -p TestDoAttachThenDisassembly.py'
 ]
 
 def main():
     """Read the items from 'benches' and run the command line one by one."""
+    parser = OptionParser(usage="""\
+%prog [options]
+Run the standard benchmarks defined in the list named 'benches'.\
+""")
+    parser.add_option('-e', '--executable',
+                      type='string', action='store',
+                      dest='exe',
+                      help='The target program launched by lldb.')
+    parser.add_option('-x', '--breakpoint-spec',
+                      type='string', action='store',
+                      dest='break_spec',
+                      help='The lldb breakpoint spec for the target program.')
+
+    # Parses the options, if any.
+    opts, args = parser.parse_args()
+                          
     print "Starting bench runner...."
 
-    for command in benches:
+    for item in benches:
+        command = item.replace('%E',
+                               '-e "%s"' % opts.exe if opts.exe else '')
+        command = command.replace('%X',
+                               '-x "%s"' % opts.break_spec if opts.break_spec else '')
         print "Running %s" % (command)
         os.system(command)
 

Modified: lldb/trunk/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py?rev=143075&r1=143074&r2=143075&view=diff
==============================================================================
--- lldb/trunk/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py (original)
+++ lldb/trunk/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py Wed Oct 26 17:58:02 2011
@@ -1,4 +1,6 @@
-"""Test lldb's disassemblt speed."""
+"""Test lldb's disassemblt speed.  This bench deliberately attaches to an lldb
+inferior and traverses the stack for thread0 to arrive at frame with function
+'MainLoop'.  It is important to specify an lldb executable as the inferior."""
 
 import os, sys
 import unittest2
@@ -12,20 +14,27 @@
 
     def setUp(self):
         BenchBase.setUp(self)
+        if lldb.bmExecutable:
+            self.exe = lldb.bmExecutable
+        else:
+            self.exe = self.lldbHere
+        self.count = lldb.bmIterationCount
+        if self.count <= 0:
+            self.count = 10
 
     @benchmarks_test
     def test_attach_then_disassembly(self):
         """Attach to a spawned lldb process then run disassembly benchmarks."""
         print
-        self.run_lldb_attach_then_disassembly(10)
+        self.run_lldb_attach_then_disassembly(self.exe, self.count)
         print "lldb disassembly benchmark:", self.stopwatch
 
-    def run_lldb_attach_then_disassembly(self, count):
-        target = self.dbg.CreateTarget(self.lldbHere)
+    def run_lldb_attach_then_disassembly(self, exe, count):
+        target = self.dbg.CreateTarget(exe)
 
         # Spawn a new process and don't display the stdout if not in TraceOn() mode.
         import subprocess
-        popen = subprocess.Popen([self.lldbHere, self.lldbOption],
+        popen = subprocess.Popen([exe, self.lldbOption],
                                  stdout = open(os.devnull, 'w') if not self.TraceOn() else None)
         if self.TraceOn():
             print "pid of spawned process: %d" % popen.pid

Modified: lldb/trunk/test/benchmarks/startup/TestStartupDelays.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/startup/TestStartupDelays.py?rev=143075&r1=143074&r2=143075&view=diff
==============================================================================
--- lldb/trunk/test/benchmarks/startup/TestStartupDelays.py (original)
+++ lldb/trunk/test/benchmarks/startup/TestStartupDelays.py Wed Oct 26 17:58:02 2011
@@ -1,4 +1,4 @@
-"""Test lldb's startup delays creating a target and setting a breakpoint."""
+"""Test lldb's startup delays creating a target, setting a breakpoint, and run to breakpoint stop."""
 
 import os, sys
 import unittest2
@@ -32,7 +32,7 @@
 
     @benchmarks_test
     def test_startup_delay(self):
-        """Test start up delays creating a target and setting a breakpoint."""
+        """Test start up delays creating a target, setting a breakpoint, and run to breakpoint stop."""
         print
         self.run_startup_delays_bench(self.exe, self.break_spec, self.count)
         print "lldb startup delay (create fresh target) benchmark:", self.stopwatch

Modified: lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py?rev=143075&r1=143074&r2=143075&view=diff
==============================================================================
--- lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py (original)
+++ lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py Wed Oct 26 17:58:02 2011
@@ -14,17 +14,12 @@
         BenchBase.setUp(self)
         if lldb.bmExecutable:
             self.exe = lldb.bmExecutable
-            bmExecutableDefauled = False
         else:
             self.exe = self.lldbHere
-            bmExecutableDefauled = True
         if lldb.bmBreakpointSpec:
             self.break_spec = lldb.bmBreakpointSpec
         else:
-            if bmExecutableDefauled:
-                self.break_spec = '-F Driver::MainLoop()'
-            else:
-                self.break_spec = '-n main'
+            self.break_spec = '-n main'
 
         self.count = lldb.bmIterationCount
         if self.count <= 0:





More information about the lldb-commits mailing list