WebKit Bugzilla
Attachment 342479 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
bug-186414-20180611162955.patch (text/plain), 13.27 KB, created by
Ben Richards
on 2018-06-11 16:29:56 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Ben Richards
Created:
2018-06-11 16:29:56 PDT
Size:
13.27 KB
patch
obsolete
>Subversion Revision: 232546 >diff --git a/PerformanceTests/ChangeLog b/PerformanceTests/ChangeLog >index e397ecb3d416394e32014eaf6984b4b3e0b39a39..f23d1a0d46746a580d99de34c9b08d71ae600362 100644 >--- a/PerformanceTests/ChangeLog >+++ b/PerformanceTests/ChangeLog >@@ -1,3 +1,13 @@ >+2018-06-11 Ben Richards <benton_richards@apple.com> >+ >+ Add benchmark for launching startup processes and new tab processes >+ https://bugs.webkit.org/show_bug.cgi?id=186414 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * LaunchTime/new_tab.py: Added. >+ * LaunchTime/startup.py: Added. >+ > 2018-06-04 Jon Lee <jonlee@apple.com> > > Remove unnecessary MotionMark controllers >diff --git a/PerformanceTests/LaunchTime/new_tab.py b/PerformanceTests/LaunchTime/new_tab.py >new file mode 100755 >index 0000000000000000000000000000000000000000..0c6610980a27869e3abb73e42167ba245c9f6e02 >--- /dev/null >+++ b/PerformanceTests/LaunchTime/new_tab.py >@@ -0,0 +1,250 @@ >+#! /usr/bin/env python >+ >+import argparse >+import time >+import sys >+import inspect >+import os >+import threading >+import subprocess >+from subprocess import call, check_output >+import numpy as np >+ >+ >+NUM_ITERATIONS = 5 >+BROWSER_BUNDLE_PATH = '/Applications/Safari.app' >+BENCH_SCRIPT = ''' >+ tell application "%s" >+ set numRetry to 3 >+ repeat >+ try >+ set startTime to (do JavaScript "+new Date()" in document 1) >+ open location "about:blank" >+ exit repeat >+ on error >+ set numRetry to numRetry - 1 >+ if (numRetry <= 0) then >+ error -1 >+ end if >+ end try >+ end repeat >+ set numRetry to 3 >+ repeat >+ try >+ set stopTime to (do JavaScript "performance.timing.navigationStart" in document 1) >+ exit repeat >+ on error >+ set numRetry to numRetry - 1 >+ if (numRetry <= 1) then >+ error -1 >+ end if >+ end try >+ end repeat >+ set numRetry to 3 >+ repeat >+ try >+ item 2 of tabs of item 1 of windows close >+ exit repeat >+ on error >+ set numRetry to numRetry - 1 >+ if (numRetry <= 1) then >+ error -1 >+ end if >+ end try >+ end repeat >+ do shell script "echo " & startTime & "-" & stopTime >+ end tell >+'''.strip() >+CHROME_BENCH_SCRIPT = ''' >+ tell application "%s" >+ set numRetry to 3 >+ repeat >+ try >+ set tab_one to item 1 of tabs of item 1 of windows >+ set startTime to (execute tab_one javascript "+new Date()") >+ open location "about:blank" >+ exit repeat >+ on error >+ set numRetry to numRetry - 1 >+ if (numRetry <= 0) then >+ error -1 >+ end if >+ end try >+ end repeat >+ set numRetry to 3 >+ repeat >+ try >+ set tab_two to item 2 of tabs of item 1 of windows >+ set stopTime to (execute tab_two javascript "performance.timing.navigationStart") >+ exit repeat >+ on error >+ set numRetry to numRetry - 1 >+ if (numRetry <= 1) then >+ error -1 >+ end if >+ end try >+ end repeat >+ set numRetry to 3 >+ repeat >+ try >+ tab_two close >+ exit repeat >+ on error >+ set numRetry to numRetry - 1 >+ if (numRetry <= 1) then >+ error -1 >+ end if >+ end try >+ end repeat >+ do shell script "echo " & startTime & "-" & stopTime >+ end tell >+''' >+ENABLE_DO_JAVASCRIPT_SAFARI = ''' >+tell application "System Events" >+ set numRetry to 3 >+ repeat >+ try >+ tell application "/Applications/Safari.app" to activate >+ set v to (get value of attribute "AXMenuItemMarkChar" of menu item "Allow JavaScript from Apple Events" of ((process "Safari")'s (menu bar 1)'s (menu bar item "Develop")'s (menu "Develop"))) >+ if (v = missing value) then >+ click menu item "Allow JavaScript from Apple Events" of ((process "Safari")'s (menu bar 1)'s (menu bar item "Develop")'s (menu "Develop")) >+ repeat until exists (window 2 of process "Safari") >+ delay 1 >+ end repeat >+ repeat until not (exists (window 2 of process "Safari")) >+ delay 1 >+ end repeat >+ end if >+ exit repeat >+ on error >+ set numRetry to numRetry - 1 >+ if (numRetry <= 1) then >+ error -1 >+ end if >+ end try >+ end repeat >+end tell >+'''.strip() >+ >+ >+def parse_args(): >+ global NUM_ITERATIONS >+ global BROWSER_BUNDLE_PATH >+ >+ parser = argparse.ArgumentParser(description='Benchmark new tab launch time for a specified browser.') >+ 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 >+ >+ >+def launch_browser(webpage): >+ if webpage: >+ call(['open', '-a', BROWSER_BUNDLE_PATH, webpage, '-F']) >+ else: >+ call(['open', '-a', BROWSER_BUNDLE_PATH, '-F']) >+ >+ >+def run_applescript(script): >+ runnable = ['osascript', ] >+ for line in script.splitlines(): >+ runnable.append('-e') >+ runnable.append(line.strip()) >+ return check_output(runnable) >+ >+ >+def run_open_tab_test(): >+ out = run_applescript(BENCH_SCRIPT).strip() >+ start, stop = out.split('-') >+ plus_index = start.find('+') >+ start = float(start[:plus_index - 1]) * (10 ** int(start[plus_index + 1:])) >+ plus_index = stop.find('+') >+ stop = float(stop[:plus_index - 1]) * (10 ** int(stop[plus_index + 1:])) >+ return start, stop >+ >+ >+def quit_browser(): >+ call(['osascript', '-e', 'quit app "%s"' % BROWSER_BUNDLE_PATH]) >+ >+ >+def init(): >+ global BROWSER_BUNDLE_PATH >+ global BENCH_SCRIPT >+ global ENABLE_DO_JAVASCRIPT_SAFARI >+ >+ # close app if it's already running >+ quit_browser() >+ >+ # get command line arguments >+ parse_args() >+ >+ # perform browser specific initialization >+ if 'Chrome' in BROWSER_BUNDLE_PATH: >+ BENCH_SCRIPT = CHROME_BENCH_SCRIPT >+ launch_browser('http://localhost:0') >+ elif 'Safari' in BROWSER_BUNDLE_PATH: >+ # Safari requires JavaScript injection to be enabled >+ launch_browser('http://localhost:0') >+ try: >+ run_applescript(ENABLE_DO_JAVASCRIPT_SAFARI) >+ except: >+ print 'Enabling JavaScript from Apple Events failed. Please try script again.' >+ sys.exit(1) >+ >+ # format script for browser path >+ BENCH_SCRIPT = (BENCH_SCRIPT % BROWSER_BUNDLE_PATH).strip() >+ >+ >+def main(): >+ global NUM_ITERATIONS >+ global BROWSER_BUNDLE_PATH >+ >+ init() >+ >+ # spin to warm up processor >+ # sys.stdout.write('Warming up processor') >+ # for i in range(10000000): >+ # if i % 1000000 == 0: >+ # sys.stdout.write('.') >+ # sys.stdout.flush() >+ # print 'done.' >+ >+ sys.stdout.write('Running tests') >+ sys.stdout.flush() >+ >+ tests = [] >+ for i in range(NUM_ITERATIONS): >+ try: >+ sys.stdout.write('.') >+ sys.stdout.flush() >+ >+ start_time, stop_time = run_open_tab_test() >+ tests.append(stop_time - start_time) >+ except: >+ sys.stdout.write('(Test %d failed)' % i) >+ sys.stdout.flush() >+ continue >+ >+ quit_browser() >+ print 'done.' >+ >+ # Disregard first test allowing system to warm up >+ if len(tests) > 1: >+ tests = tests[1:] >+ results = np.array(tests) >+ >+ print '\nRESULTS:' >+ mean = np.mean(results, dtype=np.float64) >+ dev = np.std(results, dtype=np.float64) >+ print 'mean:', mean, 'msec' >+ print 'std dev:', dev, 'msec', '(%f%%)' % (dev / mean * 100) >+ >+ >+if __name__ == '__main__': >+ main() >diff --git a/PerformanceTests/LaunchTime/startup.py b/PerformanceTests/LaunchTime/startup.py >new file mode 100755 >index 0000000000000000000000000000000000000000..8140f8119a473baf47822cccf161b696385d9253 >--- /dev/null >+++ b/PerformanceTests/LaunchTime/startup.py >@@ -0,0 +1,177 @@ >+#! /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 >+ >+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 >+ >+ >+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) >+ >+ 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) >+ >+ >+if __name__ == '__main__': >+ 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
Flags:
ews-watchlist
:
commit-queue-
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