Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: tools/unittests/run_perf_test.py

Issue 569213002: Make timeout configurable in performance test runner. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Formatting Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/run_perf.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 the V8 project authors. All rights reserved. 2 # Copyright 2014 the V8 project authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 from collections import namedtuple 6 from collections import namedtuple
7 import coverage 7 import coverage
8 import json 8 import json
9 from mock import DEFAULT 9 from mock import DEFAULT
10 from mock import MagicMock 10 from mock import MagicMock
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 V8_GENERIC_JSON = { 71 V8_GENERIC_JSON = {
72 "path": ["."], 72 "path": ["."],
73 "binary": "cc", 73 "binary": "cc",
74 "flags": ["--flag"], 74 "flags": ["--flag"],
75 "generic": True, 75 "generic": True,
76 "run_count": 1, 76 "run_count": 1,
77 "units": "ms", 77 "units": "ms",
78 } 78 }
79 79
80 Output = namedtuple("Output", "stdout, stderr") 80 Output = namedtuple("Output", "stdout, stderr, timed_out")
81 81
82 class PerfTest(unittest.TestCase): 82 class PerfTest(unittest.TestCase):
83 @classmethod 83 @classmethod
84 def setUpClass(cls): 84 def setUpClass(cls):
85 cls.base = path.dirname(path.dirname(path.abspath(__file__))) 85 cls.base = path.dirname(path.dirname(path.abspath(__file__)))
86 sys.path.append(cls.base) 86 sys.path.append(cls.base)
87 cls._cov = coverage.coverage( 87 cls._cov = coverage.coverage(
88 include=([os.path.join(cls.base, "run_perf.py")])) 88 include=([os.path.join(cls.base, "run_perf.py")]))
89 cls._cov.start() 89 cls._cov.start()
90 import run_perf 90 import run_perf
(...skipping 15 matching lines...) Expand all
106 106
107 def tearDown(self): 107 def tearDown(self):
108 if path.exists(TEST_WORKSPACE): 108 if path.exists(TEST_WORKSPACE):
109 shutil.rmtree(TEST_WORKSPACE) 109 shutil.rmtree(TEST_WORKSPACE)
110 110
111 def _WriteTestInput(self, json_content): 111 def _WriteTestInput(self, json_content):
112 self._test_input = path.join(TEST_WORKSPACE, "test.json") 112 self._test_input = path.join(TEST_WORKSPACE, "test.json")
113 with open(self._test_input, "w") as f: 113 with open(self._test_input, "w") as f:
114 f.write(json.dumps(json_content)) 114 f.write(json.dumps(json_content))
115 115
116 def _MockCommand(self, *args): 116 def _MockCommand(self, *args, **kwargs):
117 # Fake output for each test run. 117 # Fake output for each test run.
118 test_outputs = [Output(stdout=arg, stderr=None) for arg in args[1]] 118 test_outputs = [Output(stdout=arg,
119 stderr=None,
120 timed_out=kwargs.get("timed_out", False))
121 for arg in args[1]]
119 def execute(*args, **kwargs): 122 def execute(*args, **kwargs):
120 return test_outputs.pop() 123 return test_outputs.pop()
121 commands.Execute = MagicMock(side_effect=execute) 124 commands.Execute = MagicMock(side_effect=execute)
122 125
123 # Check that d8 is called from the correct cwd for each test run. 126 # Check that d8 is called from the correct cwd for each test run.
124 dirs = [path.join(TEST_WORKSPACE, arg) for arg in args[0]] 127 dirs = [path.join(TEST_WORKSPACE, arg) for arg in args[0]]
125 def chdir(*args, **kwargs): 128 def chdir(*args, **kwargs):
126 self.assertEquals(dirs.pop(), args[0]) 129 self.assertEquals(dirs.pop(), args[0])
127 os.chdir = MagicMock(side_effect=chdir) 130 os.chdir = MagicMock(side_effect=chdir)
128 131
(...skipping 15 matching lines...) Expand all
144 self.assertEquals([ 147 self.assertEquals([
145 {"units": units, 148 {"units": units,
146 "graphs": [suite, trace["name"]], 149 "graphs": [suite, trace["name"]],
147 "results": trace["results"], 150 "results": trace["results"],
148 "stddev": trace["stddev"]} for trace in traces], 151 "stddev": trace["stddev"]} for trace in traces],
149 self._LoadResults()["traces"]) 152 self._LoadResults()["traces"])
150 153
151 def _VerifyErrors(self, errors): 154 def _VerifyErrors(self, errors):
152 self.assertEquals(errors, self._LoadResults()["errors"]) 155 self.assertEquals(errors, self._LoadResults()["errors"])
153 156
154 def _VerifyMock(self, binary, *args): 157 def _VerifyMock(self, binary, *args, **kwargs):
155 arg = [path.join(path.dirname(self.base), binary)] 158 arg = [path.join(path.dirname(self.base), binary)]
156 arg += args 159 arg += args
157 commands.Execute.assert_called_with(arg, timeout=60) 160 commands.Execute.assert_called_with(
161 arg, timeout=kwargs.get("timeout", 60))
158 162
159 def _VerifyMockMultiple(self, *args): 163 def _VerifyMockMultiple(self, *args, **kwargs):
160 expected = [] 164 expected = []
161 for arg in args: 165 for arg in args:
162 a = [path.join(path.dirname(self.base), arg[0])] 166 a = [path.join(path.dirname(self.base), arg[0])]
163 a += arg[1:] 167 a += arg[1:]
164 expected.append(((a,), {"timeout": 60})) 168 expected.append(((a,), {"timeout": kwargs.get("timeout", 60)}))
165 self.assertEquals(expected, commands.Execute.call_args_list) 169 self.assertEquals(expected, commands.Execute.call_args_list)
166 170
167 def testOneRun(self): 171 def testOneRun(self):
168 self._WriteTestInput(V8_JSON) 172 self._WriteTestInput(V8_JSON)
169 self._MockCommand(["."], ["x\nRichards: 1.234\nDeltaBlue: 10657567\ny\n"]) 173 self._MockCommand(["."], ["x\nRichards: 1.234\nDeltaBlue: 10657567\ny\n"])
170 self.assertEquals(0, self._CallMain()) 174 self.assertEquals(0, self._CallMain())
171 self._VerifyResults("test", "score", [ 175 self._VerifyResults("test", "score", [
172 {"name": "Richards", "results": ["1.234"], "stddev": ""}, 176 {"name": "Richards", "results": ["1.234"], "stddev": ""},
173 {"name": "DeltaBlue", "results": ["10657567"], "stddev": ""}, 177 {"name": "DeltaBlue", "results": ["10657567"], "stddev": ""},
174 ]) 178 ])
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 self._MockCommand(["."], [ 344 self._MockCommand(["."], [
341 "Trace(Test1), Result(1.234), StdDev(0.23)\n" 345 "Trace(Test1), Result(1.234), StdDev(0.23)\n"
342 "Trace(Test2), Result(10657567), StdDev(106)\n"]) 346 "Trace(Test2), Result(10657567), StdDev(106)\n"])
343 self.assertEquals(0, self._CallMain()) 347 self.assertEquals(0, self._CallMain())
344 self._VerifyResults("test", "ms", [ 348 self._VerifyResults("test", "ms", [
345 {"name": "Test1", "results": ["1.234"], "stddev": "0.23"}, 349 {"name": "Test1", "results": ["1.234"], "stddev": "0.23"},
346 {"name": "Test2", "results": ["10657567"], "stddev": "106"}, 350 {"name": "Test2", "results": ["10657567"], "stddev": "106"},
347 ]) 351 ])
348 self._VerifyErrors([]) 352 self._VerifyErrors([])
349 self._VerifyMock(path.join("out", "x64.release", "cc"), "--flag", "") 353 self._VerifyMock(path.join("out", "x64.release", "cc"), "--flag", "")
354
355 def testOneRunTimingOut(self):
356 test_input = dict(V8_JSON)
357 test_input["timeout"] = 70
358 self._WriteTestInput(test_input)
359 self._MockCommand(["."], [""], timed_out=True)
360 self.assertEquals(1, self._CallMain())
361 self._VerifyResults("test", "score", [
362 {"name": "Richards", "results": [], "stddev": ""},
363 {"name": "DeltaBlue", "results": [], "stddev": ""},
364 ])
365 self._VerifyErrors([
366 "Regexp \"^Richards: (.+)$\" didn't match for test Richards.",
367 "Regexp \"^DeltaBlue: (.+)$\" didn't match for test DeltaBlue.",
368 ])
369 self._VerifyMock(
370 path.join("out", "x64.release", "d7"), "--flag", "run.js", timeout=70)
OLDNEW
« no previous file with comments | « tools/run_perf.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698