run_startup_time_test.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. # Copyright 2015 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. if ! which adb &> /dev/null; then
  6. echo "adb is not in your path, did you run envsetup.sh?"
  7. exit -1
  8. fi
  9. TMPFILE=$(tempfile)
  10. echo '<body><div>just some text</div></body>' > $TMPFILE
  11. adb push $TMPFILE /data/local/tmp/file.html
  12. rm $TMPFILE
  13. adb shell am start -n com.android.htmlviewer/.HTMLViewerActivity -d \
  14. "file:///data/local/tmp/file.html" -a VIEW -t "text/html"
  15. sleep 3
  16. echo 'Running test, you should run \
  17. `adb logcat | grep WebViewStartupTimeMillis=` in another shell to see results.'
  18. # Launch webview test shell 100 times
  19. for i in $(seq 1 100); do
  20. if [[ $(($i % 10)) -eq 0 ]]; then
  21. echo -n "..$i.."
  22. fi
  23. adb shell kill -9 `adb shell ps | grep org.chromium.webview_shell \
  24. | tr -s " " " " | cut -d" " -f2`
  25. adb shell am start -n org.chromium.webview_shell/.StartupTimeActivity \
  26. -a VIEW > /dev/null
  27. sleep 0.5
  28. done
  29. echo
  30. adb shell rm /data/local/tmp/file.html