Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
making stuff faster

Vladimir Agafonkin mourner

🔥
making stuff faster
View GitHub Profile
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Worker Test</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
#log { font: 14px monospace; }
</style>
</head>
@mourner
mourner / bench.js
Last active Apr 1, 2020
Fast MSD in-place radix sort for Uint32 numbers in JavaScript
View bench.js
const radixSort = require('./index.js');
const N = 10000000;
const arr = new Uint32Array(N);
for (let i = 0; i < N; i++) arr[i] = Math.floor(Math.random() * 4294967295);
console.log(`sorting ${N.toLocaleString()} uint32 numbers`);
// warmup
radixSort(arr.slice());
@mourner
mourner / shadows.html
Created Aug 17, 2018
Experimental Mapbox GL shadows (for custom-layers branch)
View shadows.html
<!DOCTYPE html>
<html>
<head>
<title>Mapbox GL JS debug page</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel='stylesheet' href='/dist/mapbox-gl.css' />
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
View bspline.js
export default class BSpline {
constructor(degree = 3, dimensions = 2) {
this.degree = degree;
this.dim = dimensions;
this.temp = new Float64Array(dimensions * (degree + 1));
this.current = this.temp.subarray(dimensions * degree);
}
View fibonacci.js
import {Worker, Agent} from '@mapbox/workerpool';
// only used on the worker side
export class FibonacciWorker extends Worker {
calculate(num, callback) {
let a = 1;
let b = 0;
for (let i = num; num >= 0; num--) {
const tmp = a;
a += b;
View workerlog.json
This file has been truncated, but you can view the full file.
{
"name": "Object",
"properties": {
"rawTileData": {},
"buckets": [
{
"name": "FillBucket",
"properties": {
"zoom": 17,
View bench_geodata.js
const numFeatures = 100;
const numPolygons = 5;
const numRings = 10;
const numPoints = 10000;
console.time('populate storage');
const features = [];
for (let i = 0; i < numFeatures; i++) {
@mourner
mourner / str-concat.js
Last active Jun 1, 2018
A benchmark that demonstrates something is wrong with v8's concatenation performance
View str-concat.js
const N = 1000000;
function simpleConcat() {
let str = '';
for (let i = 0; i < N; i++) {
str += 'a';
}
return str;
}
@mourner
mourner / perf.log
Created Mar 9, 2018
Rollup GL JS perf log
View perf.log
Statistical profiling result from isolate-0x104801800-v8.log, (8048 ticks, 375 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
29 0.4% /usr/lib/system/libsystem_malloc.dylib
20 0.2% /usr/lib/system/libsystem_pthread.dylib
12 0.1% /usr/lib/system/libsystem_platform.dylib
8 0.1% /usr/lib/system/libsystem_c.dylib
3 0.0% /usr/lib/libc++abi.dylib
@mourner
mourner / contours.js
Created Sep 29, 2017
Quick example of generating GeoJSON contours from raster with d3
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++) {
You can’t perform that action at this time.