Skip to content

Commit

Permalink
adds ui styling and context to benchmark prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsender authored and mzgoddard committed Nov 21, 2017
1 parent 7356546 commit a7314d6
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 10 deletions.
54 changes: 52 additions & 2 deletions src/benchmark/benchmark.css
Original file line number Diff line number Diff line change
@@ -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;
}
10 changes: 9 additions & 1 deletion src/benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
26 changes: 19 additions & 7 deletions src/benchmark/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,28 @@
<head>
<meta charset="utf-8">
<title>Scratch VM Benchmark</title>
<style>
canvas {
border: 5px solid black;
}
</style>
<link rel="stylesheet" href="./benchmark.css" type="text/css" media="screen">
</head>
<body>
<h2>Scratch VM Benchmark</h2>
<canvas id="scratch-stage" style="width: 480px; height: 360px;"></canvas><br />
<h2>Scratch VM Benchmark</h2>
<p>
Welcome to the scratch-vm benchmark. This tool helps you profile a scratch
project. When you load the page, it:
<ol>
<li>loads the default project
<li>runs the project for 4 seconds to warm up
<li>profiles for 6 seconds
<li>stops and reports
</ol>
</p>
<input type="text" value="119615668">
<button class="run">run</button>
<p>
<i>Try a different project, like `130041250`</i>
</p>

<canvas id="scratch-stage"></canvas><br />

<div class="loading">
<label>Loading:</label>
<span class="loading-complete">0</span> / <span class="loading-total">0</span>
Expand Down

0 comments on commit a7314d6

Please sign in to comment.