View contours.js
'use strict';
var contours = require('d3-contour').contours;
var PNG = require('pngjs').PNG;
var fs = require('fs');
var png = PNG.sync.read(fs.readFileSync('./rain.png'));
var data = [];
for (var i = 0; i < png.height; i++) {
View index.html
<!doctype html>
<meta charset="utf-8">
<title>Benchmark</title>
<body></body>
<style>html, body, #map { height: 100%; margin: 0; } </style>
<div id="map"></div>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.40.0/mapbox-gl.js'></script>
<!-- <script src="mapbox-gl.js"></script> -->
View simplify.wasm
(module
(func $segDist (export "segDist")
(param $x0 f64) (param $y0 f64)
(param $x1 f64) (param $y1 f64)
(param $x2 f64) (param $y2 f64)
(result f64)
(local $x f64) (local $y f64)
(local $dx f64) (local $dy f64)
View index.js
'use strict';
function genFn(ctx, body) {
let id = ctx.cache[body];
if (!id) {
id = ctx.id++;
ctx.cache[body] = id;
ctx.src += `
function e${id}() { ${body} }`;
}
View index.css
html, body {
margin: 0;
font-family: sans-serif;
}
#map {
position: absolute;
top: 45px;
bottom: 0;
View sunpos.js
function getSunPosition(date, lat, lng) {
var r = Math.PI / 180, sin = Math.sin, cos = Math.cos, t = date / 315576e7 - 0.3,
m = r * (357.52911 + t * (35999.05029 - t * 1537e-7)), c = cos(r * (125.04 - 1934.136 * t)),
l = r * ((280.46646 + t * (36000.76983 + t * 3032e-7)) + (1.914602 - t * (4817e-6 - t * 14e-6)) *
sin(m) - (569e-5 + 478e-5 * c)) + (0.019993 - 101e-6 * t) * sin(2 * m) + 289e-6 * sin(3 * m),
e = r * (84381.448 - t * (46.815 - t * (59e-5 + 1813e-6 * t))) / 3600 + r * 256e-5 * c,
d = Math.asin(sin(e) * sin(l)),
h = r * (280.46061837 + 13184999.8983375 * t) + r * lng - Math.atan2(cos(e) * sin(l), cos(l)),
z = Math.atan2(sin(h), cos(h) * sin(r * lat) - (sin(d) / cos(d)) * cos(r * lat)),
a = Math.asin(sin(r * lat) * sin(d) + cos(r * lat) * cos(d) * cos(h));
View bench.js
mapboxgl.accessToken = 'pk.eyJ1IjoibW91cm5lciIsImEiOiJWWnRiWG1VIn0.j6eccFHpE3Q04XPLI7JxbA';
console.log('Version: ' + mapboxgl.version);
const container = document.createElement('div');
container.style.width = '1200px';
container.style.height = '700px';
document.body.appendChild(container);
View arr.js
'use strict';
var v8 = require('v8');
var N = 1000000;
var values = [];
for (var i = 0; i < 2 * N; i++) values.push(Math.random());
var memStart = v8.getHeapStatistics().used_heap_size;
View approx.js
// not working
// based on https://github.com/Project-OSRM/osrm-backend/blob/master/include/util/web_mercator.hpp
'use strict';
function latY(lat) {
var sin = Math.sin(lat * Math.PI / 180);
return 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI;
}
View viz.js
function DebugViz(id, options) {
var canvas = this.canvas = document.getElementById(id);
var ctx = this.ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
}
var padding = 5;
DebugViz.prototype = {