This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from sethladd/master
Run benchmarks in browser
- Loading branch information
Showing
9 changed files
with
157 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
library ray_trace; | ||
|
||
import 'dart:html'; | ||
import 'dart:math'; | ||
|
||
part 'color.dart'; | ||
part 'engine.dart'; | ||
part 'materials.dart'; | ||
part 'scene.dart'; | ||
part 'shapes.dart'; | ||
part 'vector.dart'; | ||
part 'renderscene.dart'; | ||
|
||
// used to check if raytrace was correct (used by benchmarks) | ||
var checkNumber; | ||
|
||
main() { | ||
var button = query('#render'); | ||
var canvas = query('#canvas'); | ||
var time = query('#time'); | ||
button.onClick.listen((e) { | ||
canvas.width = int.parse(query('#imageWidth').value); | ||
canvas.height = int.parse(query('#imageHeight').value); | ||
var sw = new Stopwatch()..start(); | ||
renderScene(e); | ||
sw.stop(); | ||
time.text = sw.elapsedMilliseconds.toString(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
|
||
<html> | ||
<head> | ||
<title>index</title> | ||
</head> | ||
|
||
<body> | ||
<canvas id="canvas" width="100" height="100" style="border:1px solid black"></canvas> | ||
|
||
<div> | ||
Width: <input type="text" id="imageWidth" value="100"> | ||
</div> | ||
<div> | ||
Height: <input type="text" id="imageHeight" value="100"> | ||
</div> | ||
<div> | ||
Pixel Size: <input type="text" id="pixelSize" value="5,5"> | ||
</div> | ||
<div> | ||
Diffuse: <input type="checkbox" id="renderDiffuse" checked> | ||
</div> | ||
<div> | ||
Shadows: <input type="checkbox" id="renderShadows" checked> | ||
</div> | ||
<div> | ||
Highlights: <input type="checkbox" id="renderHighlights" checked> | ||
</div> | ||
<div> | ||
Reflections: <input type="checkbox" id="renderReflections" checked> | ||
</div> | ||
<button id="render">Render</button> | ||
<div> | ||
Time (ms): <span id="time"></span> | ||
</div> | ||
<script type="application/dart" src="app.dart"></script> | ||
<!-- for this next line to work, your pubspec.yaml file must have a dependency on 'browser' --> | ||
<script src="packages/browser/dart.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var button = document.getElementById('render'); | ||
var canvas = document.getElementById('canvas'); | ||
var time = document.getElementById('time'); | ||
|
||
button.addEventListener('click', function (e) { | ||
canvas.width = parseInt(document.getElementById('imageWidth').value); | ||
canvas.height = parseInt(document.getElementById('imageHeight').value); | ||
var start = new Date(); | ||
renderScene(e); | ||
var stop = new Date(); | ||
time.innerHTML = (stop - start).toString(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Benchmark.report("Tracer", renderScene, renderScene); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
|
||
<html> | ||
<head> | ||
<title>index</title> | ||
</head> | ||
|
||
<body> | ||
<canvas id="canvas" width="100" height="100" style="border:1px solid black"></canvas> | ||
|
||
<div> | ||
Width: <input type="text" id="imageWidth" value="100"> | ||
</div> | ||
<div> | ||
Height: <input type="text" id="imageHeight" value="100"> | ||
</div> | ||
<div> | ||
Pixel Size: <input type="text" id="pixelSize" value="5,5"> | ||
</div> | ||
<div> | ||
Diffuse: <input type="checkbox" id="renderDiffuse" checked> | ||
</div> | ||
<div> | ||
Shadows: <input type="checkbox" id="renderShadows" checked> | ||
</div> | ||
<div> | ||
Highlights: <input type="checkbox" id="renderHighlights" checked> | ||
</div> | ||
<div> | ||
Reflections: <input type="checkbox" id="renderReflections" checked> | ||
</div> | ||
<button id="render">Render</button> | ||
<div> | ||
Time (ms): <span id="time"></span> | ||
</div> | ||
<script src="Tracer.js"></script> | ||
<script src="app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
name: benchmark_harness | ||
version: 1.0.2 | ||
description: The official Dart project benchmark harness. | ||
author: Dart Project <[email protected]> | ||
description: The official Dart project benchmark harness. | ||
homepage: http://www.dartlang.org | ||
dependencies: | ||
browser: any |