Skip to content

Commit

Permalink
Add FeatureDetection.hardwareConcurrency
Browse files Browse the repository at this point in the history
Chrome Canary recently added `navigator.hardwareConcurrency` which exposes the number of physical cores on the client.  This is a simple change to expose that value (or a default if not defined) on `FeatureDetection`.

I chose 3 as the fallback because according to Steam's hardware survey (http://store.steampowered.com/hwsurvey/) (2 cpus 47.26% 4 cpus 44.94%)

This will be handy when we do #1437 (probably post 1.0), but is useful immediately for `Primitive` creation.
  • Loading branch information
mramato committed Jun 16, 2014
1 parent adfc014 commit 44288f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Source/Core/FeatureDetection.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/*global define*/
define([
'./defaultValue',
'./defined',
'./Fullscreen'
], function(
defaultValue,
defined,
Fullscreen) {
"use strict";
Expand Down Expand Up @@ -123,7 +125,8 @@ define([
isWebkit : isWebkit,
webkitVersion : webkitVersion,
isInternetExplorer : isInternetExplorer,
internetExplorerVersion : internetExplorerVersion
internetExplorerVersion : internetExplorerVersion,
hardwareConcurrency : defaultValue(navigator.hardwareConcurrency, 3)
};

/**
Expand Down
4 changes: 3 additions & 1 deletion Source/Scene/Primitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ define([
'../Core/defineProperties',
'../Core/destroyObject',
'../Core/DeveloperError',
'../Core/FeatureDetection',
'../Core/Geometry',
'../Core/GeometryAttribute',
'../Core/GeometryAttributes',
Expand Down Expand Up @@ -35,6 +36,7 @@ define([
defineProperties,
destroyObject,
DeveloperError,
FeatureDetection,
Geometry,
GeometryAttribute,
GeometryAttributes,
Expand Down Expand Up @@ -565,7 +567,7 @@ define([
return pickColors;
}

var numberOfCreationWorkers = 3;
var numberOfCreationWorkers = Math.max(FeatureDetection.hardwareConcurrency - 1, 1);
var createGeometryTaskProcessors;
var combineGeometryTaskProcessor = new TaskProcessor('combineGeometry', Number.POSITIVE_INFINITY);

Expand Down

0 comments on commit 44288f7

Please sign in to comment.