Title: [124661] trunk/Tools
Revision
124661
Author
[email protected]
Date
2012-08-03 15:06:54 -0700 (Fri, 03 Aug 2012)

Log Message

run-perf-tests should generate JSON output and results page by default
https://bugs.webkit.org/show_bug.cgi?id=93042

Reviewed by Eric Seidel.

Generate results JSON and page named PerfTestResults.json and PerfTestResults.html by default.

* Scripts/webkitpy/layout_tests/port/base.py:
(Port.perf_results_directory): Added.
* Scripts/webkitpy/performance_tests/perftestsrunner.py:
(PerfTestsRunner): Added _DEFAULT_JSON_FILENAME.
(PerfTestsRunner._parse_args): Added --no-results option in the case a user doens't want to generate
results JSON or results page.
(PerfTestsRunner.run):
(PerfTestsRunner._generate_and_show_results): Extracted from run. Set the default json file path using
port's perf_results_directory and call show_results_html_file at the end if the results page is generated.
(PerfTestsRunner._generate_results_dict): Renamed from _generate_output to disambiguate it from
_generate_and_show_results.
(PerfTestsRunner._generate_output_files): Takes results page's path instead of a boolean indicating
whether results page should be generated or not.
* Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py:
(create_runner_and_setup_results_template):
(test_run_respects_results_output): Added.
(test_run_generates_json_by_default): Added.
(test_run_generates_and_show_results_page): Added a check to ensure show_results_html_file is called.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (124660 => 124661)


--- trunk/Tools/ChangeLog	2012-08-03 22:04:04 UTC (rev 124660)
+++ trunk/Tools/ChangeLog	2012-08-03 22:06:54 UTC (rev 124661)
@@ -1,3 +1,31 @@
+2012-08-03  Ryosuke Niwa  <[email protected]>
+
+        run-perf-tests should generate JSON output and results page by default
+        https://bugs.webkit.org/show_bug.cgi?id=93042
+
+        Reviewed by Eric Seidel.
+
+        Generate results JSON and page named PerfTestResults.json and PerfTestResults.html by default.
+
+        * Scripts/webkitpy/layout_tests/port/base.py:
+        (Port.perf_results_directory): Added.
+        * Scripts/webkitpy/performance_tests/perftestsrunner.py:
+        (PerfTestsRunner): Added _DEFAULT_JSON_FILENAME.
+        (PerfTestsRunner._parse_args): Added --no-results option in the case a user doens't want to generate
+        results JSON or results page.
+        (PerfTestsRunner.run):
+        (PerfTestsRunner._generate_and_show_results): Extracted from run. Set the default json file path using
+        port's perf_results_directory and call show_results_html_file at the end if the results page is generated.
+        (PerfTestsRunner._generate_results_dict): Renamed from _generate_output to disambiguate it from
+        _generate_and_show_results.
+        (PerfTestsRunner._generate_output_files): Takes results page's path instead of a boolean indicating
+        whether results page should be generated or not.
+        * Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py:
+        (create_runner_and_setup_results_template):
+        (test_run_respects_results_output): Added.
+        (test_run_generates_json_by_default): Added.
+        (test_run_generates_and_show_results_page): Added a check to ensure show_results_html_file is called.
+
 2012-08-03  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r124628.

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py (124660 => 124661)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py	2012-08-03 22:04:04 UTC (rev 124660)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py	2012-08-03 22:06:54 UTC (rev 124661)
@@ -788,6 +788,9 @@
             self._results_directory = self._filesystem.abspath(option_val)
         return self._results_directory
 
+    def perf_results_directory(self):
+        return self._build_path()
+
     def default_results_directory(self):
         """Absolute path to the default place to store the test results."""
         # Results are store relative to the built products to make it easy

Modified: trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py (124660 => 124661)


--- trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py	2012-08-03 22:04:04 UTC (rev 124660)
+++ trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner.py	2012-08-03 22:06:54 UTC (rev 124661)
@@ -55,6 +55,8 @@
     EXIT_CODE_FAILED_UPLOADING = -4
     EXIT_CODE_BAD_PREPARATION = -5
 
+    _DEFAULT_JSON_FILENAME = 'PerformanceTestsResults.json'
+
     def __init__(self, args=None, port=None):
         self._options, self._args = PerfTestsRunner._parse_args(args)
         if port:
@@ -94,6 +96,8 @@
                 help="Set the timeout for each test"),
             optparse.make_option("--pause-before-testing", dest="pause_before_testing", action="" default=False,
                 help="Pause before running the tests to let user attach a performance monitor."),
+            optparse.make_option("--no-results", action="" default=False,
+                help="Do no generate results JSON and results page."),
             optparse.make_option("--output-json-path",
                 help="Filename of the JSON file that summaries the results."),
             optparse.make_option("--source-json-path",
@@ -153,36 +157,48 @@
                 return self.EXIT_CODE_BAD_PREPARATION
 
         unexpected = self._run_tests_set(sorted(list(tests), key=lambda test: test.test_name()), self._port)
+        if not self._options.no_results:
+            exit_code = self._generate_and_show_results()
+            if exit_code:
+                return exit_code
 
+        return unexpected
+
+    def _generate_and_show_results(self):
         options = self._options
-        if self._options.output_json_path:
-            # FIXME: Add --branch or auto-detect the branch we're in
-            test_results_server = options.test_results_server
+        output_json_path = options.output_json_path
+        if not output_json_path:
+            output_json_path = self._host.filesystem.join(self._port.perf_results_directory(), self._DEFAULT_JSON_FILENAME)
 
-            output = self._generate_output(self._timestamp, options.platform, options.builder_name, options.build_number)
+        output = self._generate_results_dict(self._timestamp, options.platform, options.builder_name, options.build_number)
 
-            if options.source_json_path:
-                output = self._merge_source_json(options.source_json_path, output)
-                if not output:
-                    return self.EXIT_CODE_BAD_SOURCE_JSON
+        if options.source_json_path:
+            output = self._merge_source_json(options.source_json_path, output)
+            if not output:
+                return self.EXIT_CODE_BAD_SOURCE_JSON
 
-            if not test_results_server:
-                output = self._merge_outputs(self._options.output_json_path, output)
-                if not output:
-                    return self.EXIT_CODE_BAD_MERGE
+        test_results_server = options.test_results_server
+        results_page_path = None
+        if not test_results_server:
+            output = self._merge_outputs(output_json_path, output)
+            if not output:
+                return self.EXIT_CODE_BAD_MERGE
+            results_page_path = self._host.filesystem.splitext(output_json_path)[0] + '.html'
 
-            self._generate_output_files(self._options.output_json_path, output, not test_results_server)
+        self._generate_output_files(output_json_path, results_page_path, output)
 
-            if test_results_server and not self._upload_json(test_results_server, options.output_json_path):
+        if test_results_server:
+            if not self._upload_json(test_results_server, output_json_path):
                 return self.EXIT_CODE_FAILED_UPLOADING
+        else:
+            self._port.show_results_html_file(results_page_path)
 
-        return unexpected
-
-    def _generate_output(self, timestamp, platform, builder_name, build_number):
+    def _generate_results_dict(self, timestamp, platform, builder_name, build_number):
         contents = {'results': self._results}
         for (name, path) in self._port.repository_paths():
             contents[name + '-revision'] = self._host.scm().svn_revision(path)
 
+        # FIXME: Add --branch or auto-detect the branch we're in
         for key, value in {'timestamp': int(timestamp), 'branch': self._default_branch, 'platform': platform,
             'builder-name': builder_name, 'build-number': int(build_number) if build_number else None}.items():
             if value:
@@ -209,13 +225,13 @@
             _log.error("Failed to merge output JSON file %s: %s" % (output_json_path, error))
         return None
 
-    def _generate_output_files(self, output_json_path, output, should_generate_results_page):
+    def _generate_output_files(self, output_json_path, results_page_path, output):
         filesystem = self._host.filesystem
 
         json_output = json.dumps(output)
         filesystem.write_text_file(output_json_path, json_output)
 
-        if should_generate_results_page:
+        if results_page_path:
             jquery_path = filesystem.join(self._port.perf_tests_dir(), 'Dromaeo/resources/dromaeo/web/lib/jquery-1.6.4.js')
             jquery = filesystem.read_text_file(jquery_path)
 
@@ -225,7 +241,7 @@
             results_page = template.replace('<?WebKitPerfTestRunnerInsertionPoint?>',
                 '<script>%s</script><script id="json">%s</script>' % (jquery, json_output))
 
-            filesystem.write_text_file(filesystem.splitext(output_json_path)[0] + '.html', results_page)
+            filesystem.write_text_file(results_page_path, results_page)
 
     def _upload_json(self, test_results_server, json_path, file_uploader=FileUploader):
         uploader = file_uploader("https://%s/api/test/report" % test_results_server, 120)

Modified: trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py (124660 => 124661)


--- trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py	2012-08-03 22:04:04 UTC (rev 124660)
+++ trunk/Tools/Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py	2012-08-03 22:06:54 UTC (rev 124661)
@@ -270,15 +270,43 @@
             "inspector/pass.html:group_name:test_name": 42},
             "webkit-revision": 5678, "branch": "webkit-trunk"})
 
-    def create_runner_and_setup_results_template(self, args):
+    def create_runner_and_setup_results_template(self, args=[]):
         runner, port = self.create_runner(args)
         filesystem = port.host.filesystem
         filesystem.write_text_file(runner._base_path + '/resources/results-template.html', 'BEGIN<?WebKitPerfTestRunnerInsertionPoint?>END')
         filesystem.write_text_file(runner._base_path + '/Dromaeo/resources/dromaeo/web/lib/jquery-1.6.4.js', 'jquery content')
         return runner, port
 
-    def test_run_generates_results_page(self):
+    def test_run_respects_no_results(self):
+        runner, port = self.create_runner(args=['--output-json-path=/mock-checkout/output.json',
+            '--test-results-server=some.host', '--no-results'])
+        self.assertFalse(self._test_run_with_json_output(runner, port.host.filesystem))
+        self.assertFalse(port.host.filesystem.isfile('/mock-checkout/output.json'))
+
+    def test_run_generates_json_by_default(self):
+        runner, port = self.create_runner_and_setup_results_template()
+        filesystem = port.host.filesystem
+        output_json_path = filesystem.join(port.perf_results_directory(), runner._DEFAULT_JSON_FILENAME)
+        results_page_path = filesystem.splitext(output_json_path)[0] + '.html'
+
+        self.assertFalse(filesystem.isfile(output_json_path))
+        self.assertFalse(filesystem.isfile(results_page_path))
+
+        self._test_run_with_json_output(runner, port.host.filesystem)
+
+        self.assertEqual(json.loads(port.host.filesystem.read_text_file(output_json_path)), [{
+            "timestamp": 123456789, "results":
+            {"Bindings/event-target-wrapper": {"max": 1510, "avg": 1489.05, "median": 1487, "min": 1471, "stdev": 14.46, "unit": "ms"},
+            "inspector/pass.html:group_name:test_name": 42},
+            "webkit-revision": 5678, "branch": "webkit-trunk"}])
+
+        self.assertTrue(filesystem.isfile(output_json_path))
+        self.assertTrue(filesystem.isfile(results_page_path))
+
+    def test_run_generates_and_show_results_page(self):
         runner, port = self.create_runner_and_setup_results_template(args=['--output-json-path=/mock-checkout/output.json'])
+        page_shown = []
+        port.show_results_html_file = lambda path: page_shown.append(path)
         filesystem = port.host.filesystem
         self._test_run_with_json_output(runner, filesystem)
 
@@ -291,6 +319,7 @@
         self.assertEqual(json.loads(json_output), [expected_entry])
         self.assertEqual(filesystem.read_text_file('/mock-checkout/output.html'),
             'BEGIN<script>jquery content</script><script id="json">' + json_output + '</script>END')
+        self.assertEqual(page_shown[0], '/mock-checkout/output.html')
 
         self._test_run_with_json_output(runner, filesystem)
         json_output = port.host.filesystem.read_text_file('/mock-checkout/output.json')
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to