Skip to content

Commit

Permalink
use less workers for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Nov 8, 2016
1 parent c08b084 commit c3dde59
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
3 changes: 1 addition & 2 deletions js/mapbox-gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ const browser = require('./util/browser');
const mapboxgl = module.exports = {};

mapboxgl.version = require('../package.json').version;
mapboxgl.workerCount = Math.max(browser.hardwareConcurrency - 1, 1);

mapboxgl.workerCount = Math.max(Math.floor(Math.log(browser.hardwareConcurrency) / Math.LN2), 1);

mapboxgl.Map = require('./ui/map');
mapboxgl.Control = require('./ui/control/control');
Expand Down
8 changes: 2 additions & 6 deletions test/js/mapbox-gl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const test = require('mapbox-gl-js-test').test;
const proxyquire = require('proxyquire');
const mapboxgl = require('../../js/mapbox-gl');

test('mapboxgl', (t) => {
Expand All @@ -10,11 +9,8 @@ test('mapboxgl', (t) => {
t.end();
});

t.test('.workerCount defaults to hardwareConcurrency - 1', (t) => {
const mapboxgl = proxyquire('../../js/mapbox-gl', {
'./util/browser': { hardwareConcurrency: 15 }
});
t.equal(mapboxgl.workerCount, 14);
t.test('workerCount', (t) => {
t.ok(typeof mapboxgl.workerCount === 'number');
t.end();
});
t.end();
Expand Down

0 comments on commit c3dde59

Please sign in to comment.