From a7314d6f0d6e9078a26051ccefe58ff814bb67de Mon Sep 17 00:00:00 2001 From: Boaz Sender Date: Thu, 16 Nov 2017 15:43:51 -0500 Subject: [PATCH] adds ui styling and context to benchmark prototype --- src/benchmark/benchmark.css | 54 +++++++++++++++++++++++++++++++++++-- src/benchmark/benchmark.js | 10 ++++++- src/benchmark/index.html | 26 +++++++++++++----- 3 files changed, 80 insertions(+), 10 deletions(-) diff --git a/src/benchmark/benchmark.css b/src/benchmark/benchmark.css index e843b5e94ff..07068f59bea 100644 --- a/src/benchmark/benchmark.css +++ b/src/benchmark/benchmark.css @@ -1,7 +1,57 @@ +body { + font-family: monospace; +} +p { + max-width: 400px; +} @media (min-width: 960px) { .profile-tables { + top: 0px; position: absolute; - top: 0; - left: 520px; + left: 450px; } } +#scratch-stage { + border: 5px solid black; + display: block; + width: 400px; + height: 300px; +} +.loading label, .profile-count label{ + width: 15em; + display: inline-block; +} +.profile-tables table { + margin: 30px 0 30px 0px; +} +.profile-tables th { + border-bottom: 1px solid #333; + text-align: center; +} +.profile-tables th:first-child { + width: 215px; +} +.profile-tables th, .profile-tables td { + min-width: 85px; + border-bottom: 1px solid #ccc; + border-spacing: 0; + border-collapse: collapse; + padding: 5px; +} +.profile-tables td:not(:first-child) { + text-align: center; +} +.profile-tables img{ + margin: 0 auto; + display: block; + clear: both; + width: 20%; +} + +.slow { + background-color: #ffa1a1; +} +.profiler-count-running { + height: 4em; + background-color: #dddddd; +} diff --git a/src/benchmark/benchmark.js b/src/benchmark/benchmark.js index d8540404af0..3fd1bc2a2d4 100644 --- a/src/benchmark/benchmark.js +++ b/src/benchmark/benchmark.js @@ -5,10 +5,18 @@ const PROJECT_SERVER = 'https://cdn.projects.scratch.mit.edu/'; const SLOW = .1; +const projectInput = document.querySelector('input'); + +document.querySelector('.run') + .addEventListener('click', () => { + window.location.hash = projectInput.value; + location.reload(); + }, false); + const loadProject = function () { let id = location.hash.substring(1); if (id.length < 1 || !isFinite(id)) { - id = '119615668'; + id = projectInput.value; } Scratch.vm.downloadProjectId(id); }; diff --git a/src/benchmark/index.html b/src/benchmark/index.html index 7ddc98dc3a8..9e6b885a4f6 100644 --- a/src/benchmark/index.html +++ b/src/benchmark/index.html @@ -4,16 +4,28 @@ Scratch VM Benchmark - -

Scratch VM Benchmark

-
+

Scratch VM Benchmark

+

+ Welcome to the scratch-vm benchmark. This tool helps you profile a scratch + project. When you load the page, it: +

    +
  1. loads the default project +
  2. runs the project for 4 seconds to warm up +
  3. profiles for 6 seconds +
  4. stops and reports +
+

+ + +

+ Try a different project, like `130041250` +

+ +
+
0 / 0