WebKit Bugzilla
Attachment 343658 Details for
Bug 186414
: Add benchmark for WebKit process launch times
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
plt.patch (text/plain), 11.19 KB, created by
Ben Richards
on 2018-06-26 16:29:59 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Ben Richards
Created:
2018-06-26 16:29:59 PDT
Size:
11.19 KB
patch
obsolete
>diff --git a/PerformanceTests/ChangeLog b/PerformanceTests/ChangeLog >index c053eea5590..21c8cbd5441 100644 >--- a/PerformanceTests/ChangeLog >+++ b/PerformanceTests/ChangeLog >@@ -1,3 +1,13 @@ >+2018-06-25 Ben Richards <benton_richards@apple.com> >+ >+ Added process launch time benchmarks for startup and new tab creation >+ https://bugs.webkit.org/show_bug.cgi?id=186414 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * LaunchTime/new_tab.py: Added. >+ * LaunchTime/startup.py: Added. >+ > 2018-06-25 Jon Lee <jonlee@apple.com> > > [MotionMark] Add support for version numbers >diff --git a/PerformanceTests/LaunchTime/new_tab.py b/PerformanceTests/LaunchTime/new_tab.py >new file mode 100755 >index 00000000000..b98c91ffc4e >--- /dev/null >+++ b/PerformanceTests/LaunchTime/new_tab.py >@@ -0,0 +1,198 @@ >+#! /usr/bin/env python >+ >+import argparse >+import time >+import sys >+import inspect >+import os >+import threading >+import subprocess >+from subprocess import call >+import SimpleHTTPServer >+import SocketServer >+ >+# pylint: disable=E1101 >+MISSING_NUMPY = False >+try: >+ import numpy as np >+except ImportError: >+ MISSING_NUMPY = True >+ >+start_time = None >+stop_time = None >+server_ready = threading.Semaphore(0) >+server_running = False >+NUM_ITERATIONS = 5 >+PORT = 8080 >+BROWSER_BUNDLE_PATH = '/Applications/Safari.app' >+TEST_PAGE = '''<!DOCTYPE html> >+ >+<html> >+ <head> >+ <title>New Tab Benchmark</title> >+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >+ <script type="text/javascript"> >+ function sendDone() { >+ var time = performance.timing.navigationStart / 1000 >+ var request = new XMLHttpRequest(); >+ request.open("POST", "done", false); >+ request.setRequestHeader('Content-Type', 'application/json'); >+ request.send(JSON.stringify(time)); >+ } >+ window.onload = sendDone; >+ </script> >+ </head> >+ <body> >+ <h1>New Tab Benchmark</h1> >+ </body> >+</html> >+''' >+ >+ >+def parse_args(): >+ global BROWSER_BUNDLE_PATH >+ global NUM_ITERATIONS >+ global TEST_PAGE >+ >+ parser = argparse.ArgumentParser(description='Benchmark time to open a new tab.') >+ parser.add_argument('-p', '--path', type=str, >+ help='path for browser application bundle (default: "/Applications/Safari.app")') >+ parser.add_argument('-n', '--iterations', type=int, >+ help='number of iterations to run benchmark (default: 5)') >+ args = parser.parse_args() >+ >+ if args.iterations: >+ NUM_ITERATIONS = args.iterations >+ if args.path: >+ BROWSER_BUNDLE_PATH = args.path >+ if not os.path.isdir(BROWSER_BUNDLE_PATH) or not BROWSER_BUNDLE_PATH.endswith('.app'): >+ print('Invalid app bundle path: "{}"'.format(BROWSER_BUNDLE_PATH)) >+ sys.exit(1) >+ >+ >+class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler): >+ def do_HEAD(self): >+ self.send_response(200) >+ self.send_header('Content-type', 'text/hetml') >+ self.end_headers() >+ >+ def do_GET(self): >+ self.send_response(200) >+ self.send_header('Content-type', 'text/html') >+ self.end_headers() >+ self.wfile.write(TEST_PAGE) >+ self.wfile.close() >+ >+ def do_POST(self): >+ global stop_time >+ self.send_response(200) >+ self.send_header('Content-type', 'text/html') >+ self.end_headers() >+ self.data_string = self.rfile.read(int(self.headers['Content-Length'])) >+ stop_time = float(self.data_string) >+ self.wfile.write('done') >+ self.wfile.close() >+ >+ def log_message(self, format, *args): >+ return >+ >+ >+def run_server(server): >+ server_ready.release() >+ server.serve_forever() >+ >+ >+open_count = 0 >+ >+ >+def open_tab(): >+ global open_count >+ call(['open', '-a', BROWSER_BUNDLE_PATH, >+ 'http://localhost:8080/%d' % open_count]) >+ open_count += 1 >+ >+ >+def launch_browser(): >+ call(['open', '-a', BROWSER_BUNDLE_PATH]) >+ >+ >+def quit_browser(): >+ call(['osascript', '-e', 'quit app "%s"' % BROWSER_BUNDLE_PATH]) >+ >+ >+def init(): >+ parse_args() >+ >+ # make sure application isn't already running >+ quit_browser() >+ >+ try: >+ server = SocketServer.TCPServer(('0.0.0.0', PORT), Handler) >+ except: >+ print 'Unable to start test server on localhost:%d. Double check that the port is not in use and try again.' % PORT >+ sys.exit(1) >+ >+ server_thread = threading.Thread(target=run_server, args=(server,)) >+ server_thread.start() >+ >+ server_ready.acquire() >+ >+ return server, server_thread >+ >+ >+def main(): >+ global start_time >+ global stop_time >+ global NUM_ITERATIONS >+ global BROWSER_BUNDLE_PATH >+ >+ server, server_thread = init() >+ >+ sys.stdout.write('Running tests') >+ sys.stdout.flush() >+ >+ launch_browser() >+ time.sleep(5) >+ >+ tests = [] >+ for i in range(NUM_ITERATIONS): >+ try: >+ sys.stdout.write('.') >+ sys.stdout.flush() >+ >+ start_time = time.time() >+ open_tab() >+ while stop_time is None: >+ time.sleep(0) >+ >+ tests.append(stop_time - start_time) >+ stop_time = None >+ time.sleep(1) >+ except: >+ sys.stdout.write('(Test %d failed)' % i) >+ sys.stdout.flush() >+ print 'done.' >+ >+ quit_browser() >+ server.shutdown() >+ server_thread.join() >+ >+ if len(tests) > 1: >+ tests = tests[1:] >+ results = np.array(tests) >+ >+ if len(tests) > 0: >+ print '\nRESULTS:' >+ mean = np.mean(results, dtype=np.float64) >+ dev = np.std(results, dtype=np.float64) >+ print 'mean: {} ms'.format(mean * 1000) >+ print 'std dev: {} ms ({}%)'.format(dev * 1000, dev / mean * 100) >+ else: >+ print 'No successful iterations. Unable to generate results.' >+ >+ >+if __name__ == '__main__': >+ if MISSING_NUMPY: >+ print "Missing numpy, install and try again" >+ else: >+ main() >diff --git a/PerformanceTests/LaunchTime/startup.py b/PerformanceTests/LaunchTime/startup.py >new file mode 100755 >index 00000000000..8b4567d7097 >--- /dev/null >+++ b/PerformanceTests/LaunchTime/startup.py >@@ -0,0 +1,193 @@ >+#! /usr/bin/env python >+ >+import argparse >+import time >+import sys >+import inspect >+import os >+import threading >+import subprocess >+from subprocess import call >+import numpy as np >+import SimpleHTTPServer >+import SocketServer >+ >+# pylint: disable=E1101 >+MISSING_NUMPY = False >+try: >+ import numpy as np >+except ImportError: >+ MISSING_NUMPY = True >+ >+start_time = None >+stop_time = None >+server_ready = threading.Semaphore(0) >+server_running = False >+NUM_ITERATIONS = 5 >+PORT = 8080 >+BROWSER_BUNDLE_PATH = '/Applications/Safari.app' >+TEST_PAGE = '''<!DOCTYPE html> >+ >+<html> >+ <head> >+ <title>Startup Benchmark</title> >+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >+ <script type="text/javascript"> >+ function sendDone() { >+ var time = +new Date() / 1000 >+ var request = new XMLHttpRequest(); >+ request.open("POST", "done", false); >+ request.setRequestHeader('Content-Type', 'application/json'); >+ request.send(JSON.stringify(time)); >+ } >+ window.onload = sendDone; >+ </script> >+ </head> >+ <body> >+ <h1>Startup Benchmark</h1> >+ </body> >+</html> >+''' >+ >+ >+def parse_args(): >+ global BROWSER_BUNDLE_PATH >+ global NUM_ITERATIONS >+ global TEST_PAGE >+ >+ parser = argparse.ArgumentParser(description='Benchmark time to launch browser processes and load a single webpage.') >+ parser.add_argument('-p', '--path', type=str, >+ help='path for browser application bundle (default: "/Applications/Safari.app")') >+ parser.add_argument('-n', '--iterations', type=int, >+ help='number of iterations to run benchmark (default: 5)') >+ args = parser.parse_args() >+ >+ if args.iterations: >+ NUM_ITERATIONS = args.iterations >+ if args.path: >+ BROWSER_BUNDLE_PATH = args.path >+ if not os.path.isdir(BROWSER_BUNDLE_PATH) or not BROWSER_BUNDLE_PATH.endswith('.app'): >+ print('Invalid app bundle path: "{}"'.format(BROWSER_BUNDLE_PATH)) >+ sys.exit(1) >+ >+ >+class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler): >+ def do_HEAD(self): >+ self.send_response(200) >+ self.send_header('Content-type', 'text/hetml') >+ self.end_headers() >+ >+ def do_GET(self): >+ self.send_response(200) >+ self.send_header('Content-type', 'text/html') >+ self.end_headers() >+ self.wfile.write(TEST_PAGE) >+ self.wfile.close() >+ >+ def do_POST(self): >+ global stop_time >+ self.send_response(200) >+ self.send_header('Content-type', 'text/html') >+ self.end_headers() >+ self.data_string = self.rfile.read(int(self.headers['Content-Length'])) >+ stop_time = float(self.data_string) >+ self.wfile.write('done') >+ self.wfile.close() >+ >+ def log_message(self, format, *args): >+ return >+ >+ >+def run_server(server): >+ server_ready.release() >+ server.serve_forever() >+ >+ >+open_count = 0 >+ >+ >+def launch_browser(): >+ global open_count >+ call(['open', '-a', BROWSER_BUNDLE_PATH, >+ 'http://localhost:8080/%d' % open_count]) >+ open_count += 1 >+ >+ >+def quit_browser(): >+ call(['osascript', '-e', 'quit app "%s"' % BROWSER_BUNDLE_PATH]) >+ >+ >+def init(): >+ parse_args() >+ >+ # make sure application isn't already running >+ quit_browser() >+ >+ try: >+ server = SocketServer.TCPServer(('0.0.0.0', PORT), Handler) >+ except: >+ print 'Unable to start test server on localhost:%d. Double check that the port is not in use and try again.' % PORT >+ sys.exit(1) >+ >+ server_thread = threading.Thread(target=run_server, args=(server,)) >+ server_thread.start() >+ >+ server_ready.acquire() >+ >+ return server, server_thread >+ >+ >+def main(): >+ global start_time >+ global stop_time >+ global NUM_ITERATIONS >+ global BROWSER_BUNDLE_PATH >+ >+ server, server_thread = init() >+ >+ sys.stdout.write('Running tests') >+ sys.stdout.flush() >+ >+ tests = [] >+ for i in range(NUM_ITERATIONS): >+ try: >+ sys.stdout.write('.') >+ sys.stdout.flush() >+ >+ start_time = time.time() >+ launch_browser() >+ while stop_time is None: >+ time.sleep(0) >+ quit_browser() >+ for i in range(1000000): >+ sys.stdout.write('') # spin to let browser finish closing >+ >+ tests.append(stop_time - start_time) >+ stop_time = None >+ except: >+ sys.stdout.write('(Test %d failed)' % i) >+ sys.stdout.flush() >+ print 'done.' >+ >+ server.shutdown() >+ server_thread.join() >+ >+ if len(tests) > 1: >+ tests = tests[1:] >+ results = np.array(tests) >+ >+ if len(tests) > 0: >+ print '\nRESULTS:' >+ mean = np.mean(results, dtype=np.float64) >+ dev = np.std(results, dtype=np.float64) >+ print 'mean:', mean, 'sec' >+ print 'std dev:', dev, 'sec', '(%f%%)' % (dev / mean * 100) >+ else: >+ print 'No successful iterations. Unable to generate results.' >+ >+ >+if __name__ == '__main__': >+ if MISSING_NUMPY: >+ print "Missing numpy, install and try again" >+ else: >+ main()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186414
:
342371
|
342479
|
342617
|
343358
|
343420
|
343658
|
343968
|
343992
|
344248
|
344801
|
344808
|
345051
|
345120
|
345198
|
345215
|
345306
|
345322
|
345336
|
345378
|
345381