forked from visgl/deck.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmarks for node and browser.js (visgl#299)
* Add benchmarks on node and browser. Optimize layer construction * Clean up layer construction optimziation
- Loading branch information
Showing
15 changed files
with
220 additions
and
49 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
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
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,24 @@ | ||
require('babel-polyfill'); | ||
const _ = require('lodash'); | ||
const process = require('process'); | ||
|
||
const benchmark = require('benchmark'); | ||
const Benchmark = benchmark.runInContext({_, process}); | ||
/* global window */ | ||
window.Benchmark = Benchmark; | ||
|
||
/* eslint-disable */ | ||
(function () { | ||
const old = console.log; | ||
const logger = document.createElement('div'); | ||
document.body.appendChild(logger); | ||
console.log = function f(message) { | ||
if (typeof message === 'object') { | ||
logger.innerHTML += (JSON && JSON.stringify ? JSON.stringify(message) : message) + '<br />'; | ||
} else { | ||
logger.innerHTML += message + '<br />'; | ||
} | ||
} | ||
})(); | ||
|
||
require('./index'); |
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,64 @@ | ||
/* eslint-disable no-console, no-invalid-this */ | ||
/* global console */ | ||
import {Suite} from 'benchmark'; | ||
import * as data from '../data'; | ||
import {ScatterplotLayer, ChoroplethLayer} from 'deck.gl'; | ||
|
||
import {createGLContext} from 'luma.gl'; | ||
|
||
export function testInitializeLayer({gl, layer}) { | ||
const oldContext = {gl}; | ||
const context = {gl}; | ||
let failures = 0; | ||
try { | ||
layer.context = context; | ||
|
||
layer.initializeLayer({ | ||
oldProps: {}, | ||
props: layer.props, | ||
oldContext, | ||
context, | ||
changeFlags: layer.diffProps({}, layer.props, context) | ||
}); | ||
|
||
layer.updateLayer({ | ||
oldProps: {}, | ||
props: layer.props, | ||
oldContext, | ||
context, | ||
changeFlags: layer.diffProps({}, layer.props, context) | ||
}); | ||
} catch (error) { | ||
failures++; | ||
} | ||
return failures; | ||
} | ||
|
||
const gl = createGLContext(); | ||
|
||
const suite = new Suite(); | ||
|
||
// add tests | ||
suite | ||
.add('ScatterplotLayer#construct', () => { | ||
return new ScatterplotLayer({data: data.choropleths}); | ||
}) | ||
.add('ChoroplethLayer#construct', () => { | ||
return new ChoroplethLayer({data: data.choropleths}); | ||
}) | ||
.add('ChoroplethLayer#initialize', () => { | ||
const layer = new ChoroplethLayer({data: data.choropleths}); | ||
testInitializeLayer({gl, layer}); | ||
}) | ||
// add listeners | ||
.on('start', (event) => { | ||
console.log('Starting bench...'); | ||
}) | ||
.on('cycle', (event) => { | ||
console.log(String(event.target)); | ||
}) | ||
.on('complete', function t() { | ||
console.log(`Fastest is ${this.filter('fastest').map('name')}`); | ||
}) | ||
// run async | ||
.run({delay: 0.1}); |
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,20 @@ | ||
// Enables ES2015 import/export in Node.js | ||
require('reify'); | ||
|
||
// Enables import of glsl | ||
const fs = require('fs'); | ||
require.extensions['.glsl'] = function readShader(module, filename) { | ||
module.exports = fs.readFileSync(filename, 'utf8'); | ||
}; | ||
|
||
// Registers an alias for this module | ||
const path = require('path'); | ||
const moduleAlias = require('module-alias'); | ||
moduleAlias.addAlias('deck.gl', path.resolve('./src')); | ||
|
||
require('babel-polyfill'); | ||
|
||
// Import headless luma support | ||
require('luma.gl/headless'); | ||
|
||
require('./index'); |
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 @@ | ||
export * from '../../examples/main/data-samples'; |
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 @@ | ||
// Webpack 2 configuration file for running tests in browser | ||
const {resolve} = require('path'); | ||
module.exports = require('./webpack.config.test-browser'); | ||
|
||
// Replace the entry point for webpack-dev-server | ||
module.exports.entry = { | ||
'test-browser': resolve('./test/bench/browser.js') | ||
}; | ||
|
||
module.exports.module.noParse = [ | ||
/benchmark/ | ||
]; |
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
Oops, something went wrong.