WebKit Bugzilla
Attachment 342371 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-20180609151024.patch (text/plain), 10.30 KB, created by
Ben Richards
on 2018-06-09 15:10:25 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Ben Richards
Created:
2018-06-09 15:10:25 PDT
Size:
10.30 KB
patch
obsolete
>Subversion Revision: 232546 >diff --git a/PerformanceTests/ChangeLog b/PerformanceTests/ChangeLog >index e397ecb3d416394e32014eaf6984b4b3e0b39a39..9a0eeb518630b7bd1072acbe43692d6d98734a01 100644 >--- a/PerformanceTests/ChangeLog >+++ b/PerformanceTests/ChangeLog >@@ -1,3 +1,13 @@ >+2018-06-09 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!). >+ >+ * LaunchBench/new_tab.py: Added. >+ * LaunchBench/startup.py: Added. >+ > 2018-06-04 Jon Lee <jonlee@apple.com> > > Remove unnecessary MotionMark controllers >diff --git a/PerformanceTests/LaunchBench/new_tab.py b/PerformanceTests/LaunchBench/new_tab.py >new file mode 100644 >index 0000000000000000000000000000000000000000..1893b6ae2f4a92b25160a9bef371e2f19c133b3e >--- /dev/null >+++ b/PerformanceTests/LaunchBench/new_tab.py >@@ -0,0 +1,151 @@ >+#! /usr/bin/env python >+ >+import time >+import sys >+import inspect >+import os >+import threading >+import subprocess >+from subprocess import call, check_output >+import numpy as np >+ >+ >+NUM_TESTS = 5 >+BROWSER_BUNDLE_PATH = '/Applications/Safari.app' >+BENCH_SCRIPT = ''' >+ tell application "%s" >+ set startTime to (do JavaScript "+new Date()" in document 1) >+ open location "about:blank" >+ set stopTime to (do JavaScript "performance.timing.navigationStart" in document 1) >+ item 2 of tabs of item 1 of windows close >+ do shell script "echo " & startTime & "-" & stopTime >+ end tell >+''' >+ >+ >+def parse_args(): >+ global NUM_TESTS >+ global BROWSER_BUNDLE_PATH >+ global BENCH_SCRIPT >+ >+ used = {} >+ i = 1 >+ while True: >+ if i >= len(sys.argv): >+ break >+ arg = sys.argv[i] >+ >+ if arg == '-p': >+ if arg in used: >+ print '-p used more than once' >+ sys.exit(1) >+ i += 1 >+ if i >= len(sys.argv): >+ print 'a valid argument must be provided to -p' >+ sys.exit(1) >+ BROWSER_BUNDLE_PATH = sys.argv[i] >+ if 'Chrome' in BROWSER_BUNDLE_PATH: >+ BENCH_SCRIPT = ''' >+ tell application "%s" >+ 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" >+ set tab_two to item 2 of tabs of item 1 of windows >+ set stopTime to (execute tab_two javascript "performance.timing.navigationStart") >+ item 2 of tabs of item 1 of windows close >+ do shell script "echo " & startTime & "-" & stopTime >+ end tell >+ ''' >+ used['-p'] = True >+ elif arg == '-n': >+ if arg in used: >+ print '-n used more than once' >+ sys.exit(1) >+ i += 1 >+ if i >= len(sys.argv): >+ print 'a valid argument must be provided to -n' >+ sys.exit(1) >+ NUM_TESTS = int(sys.argv[i]) >+ used['-n'] = True >+ else: >+ print '%s is not a valid option' >+ sys.exit(1) >+ >+ i += 1 >+ >+ BENCH_SCRIPT = BENCH_SCRIPT % BROWSER_BUNDLE_PATH >+ >+ >+def launch_browser(): >+ call(['open', '-a', BROWSER_BUNDLE_PATH, 'http://mysneakywebsite.com']) >+ time.sleep(1) >+ >+ >+def run_applescript(script): >+ runnable = ['osascript', ] >+ for line in script.splitlines(): >+ runnable.append('-e') >+ runnable.append(line) >+ 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 main(): >+ global NUM_TESTS >+ global BROWSER_BUNDLE_PATH >+ >+ parse_args() >+ launch_browser() >+ time.sleep(1) >+ >+ sys.stdout.write('Running tests') >+ sys.stdout.flush() >+ >+ tests = [] >+ for i in range(NUM_TESTS): >+ try: >+ sys.stdout.write('.') >+ sys.stdout.flush() >+ >+ # time.sleep(0.5) >+ 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 few tests allowing system to warm up >+ if len(tests) >= 5: >+ tests = tests[1:] >+ elif len(tests) >= 10: >+ tests = tests[3:] >+ elif len(tests) >= 20: >+ tests = tests[10:] >+ 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/LaunchBench/startup.py b/PerformanceTests/LaunchBench/startup.py >new file mode 100644 >index 0000000000000000000000000000000000000000..56235224f8f1f3614e8cca9d22363c97afe99aa1 >--- /dev/null >+++ b/PerformanceTests/LaunchBench/startup.py >@@ -0,0 +1,194 @@ >+#! /usr/bin/env python >+ >+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 >+NUM_TESTS = 5 >+PORT = 8080 >+MODE = 'launch' >+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_TESTS >+ global MODE >+ global TEST_PAGE >+ global GET_OPEN_TAB_TIME >+ >+ used = {} >+ i = 1 >+ while True: >+ if i >= len(sys.argv): >+ break >+ arg = sys.argv[i] >+ >+ if arg == '-p': >+ if arg in used: >+ print '-p used more than once' >+ sys.exit(1) >+ i += 1 >+ if i >= len(sys.argv): >+ print 'a valid argument must be provided to -p' >+ sys.exit(1) >+ BROWSER_BUNDLE_PATH = sys.argv[i] >+ used['-p'] = True >+ elif arg == '-n': >+ if arg in used: >+ print '-n used more than once' >+ sys.exit(1) >+ i += 1 >+ if i >= len(sys.argv): >+ print 'a valid argument must be provided to -n' >+ sys.exit(1) >+ NUM_TESTS = int(sys.argv[i]) >+ used['-n'] = True >+ else: >+ print '%s is not a valid option' % arg >+ sys.exit(1) >+ >+ i += 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.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 main(): >+ global start_time >+ global stop_time >+ global NUM_TESTS >+ global BROWSER_BUNDLE_PATH >+ >+ parse_args() >+ >+ while True: >+ try: >+ server = SocketServer.TCPServer(('0.0.0.0', PORT), Handler) >+ break >+ except: >+ continue >+ >+ server_thread = threading.Thread(target=run_server, args=(server,)) >+ server_thread.start() >+ time.sleep(1) >+ >+ sys.stdout.write('Running tests') >+ sys.stdout.flush() >+ >+ tests = [] >+ for i in range(NUM_TESTS): >+ 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 failed)') >+ sys.stdout.flush() >+ NUM_TESTS -= 1 >+ continue >+ print 'done.' >+ >+ server.shutdown() >+ server_thread.join() >+ >+ if len(tests) >= 5: >+ tests = tests[1:] >+ elif len(tests) >= 10: >+ tests = tests[3:] >+ elif len(tests) >= 20: >+ tests = tests[10:] >+ 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
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