Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / benchmarks / expression / TestExpressionCmd.py
blob9b512305d626bd3a450084c7c7b1640a39cd909f
1 """Test lldb's expression evaluations and collect statistics."""
3 import sys
4 import lldb
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbbench import *
7 from lldbsuite.test.lldbtest import *
8 from lldbsuite.test import configuration
9 from lldbsuite.test import lldbutil
12 class ExpressionEvaluationCase(BenchBase):
13 def setUp(self):
14 BenchBase.setUp(self)
15 self.source = "main.cpp"
16 self.line_to_break = line_number(self.source, "// Set breakpoint here.")
17 self.count = 25
19 @benchmarks_test
20 @expectedFailureAll(
21 oslist=["windows"],
22 bugnumber="llvm.org/pr22274: need a pexpect replacement for windows",
24 def test_expr_cmd(self):
25 """Test lldb's expression commands and collect statistics."""
26 self.build()
27 self.exe_name = "a.out"
29 print()
30 self.run_lldb_repeated_exprs(self.exe_name, self.count)
31 print("lldb expr cmd benchmark:", self.stopwatch)
33 def run_lldb_repeated_exprs(self, exe_name, count):
34 import pexpect
36 exe = self.getBuildArtifact(exe_name)
38 # Set self.child_prompt, which is "(lldb) ".
39 self.child_prompt = "(lldb) "
40 prompt = self.child_prompt
42 # Reset the stopwatch now.
43 self.stopwatch.reset()
44 for i in range(count):
45 # So that the child gets torn down after the test.
46 self.child = pexpect.spawn(
47 "%s %s %s" % (lldbtest_config.lldbExec, self.lldbOption, exe)
49 child = self.child
51 # Turn on logging for what the child sends back.
52 if self.TraceOn():
53 child.logfile_read = sys.stdout
55 child.expect_exact(prompt)
56 child.sendline(
57 "breakpoint set -f %s -l %d" % (self.source, self.line_to_break)
59 child.expect_exact(prompt)
60 child.sendline("run")
61 child.expect_exact(prompt)
62 expr_cmd1 = "expr ptr[j]->point.x"
63 expr_cmd2 = "expr ptr[j]->point.y"
65 with self.stopwatch:
66 child.sendline(expr_cmd1)
67 child.expect_exact(prompt)
68 child.sendline(expr_cmd2)
69 child.expect_exact(prompt)
71 child.sendline("quit")
72 try:
73 self.child.expect(pexpect.EOF)
74 except:
75 pass
77 self.child = None