Skip to content

Instantly share code, notes, and snippets.

@erikmaarten
Created December 13, 2016 14:34
Show Gist options
  • Save erikmaarten/92e0807348784b2dea1b455077827ca0 to your computer and use it in GitHub Desktop.
Save erikmaarten/92e0807348784b2dea1b455077827ca0 to your computer and use it in GitHub Desktop.

Revisions

  1. erikmaarten created this gist Dec 13, 2016.
    28 changes: 28 additions & 0 deletions type_checking_performance.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    var viewer = new Cesium.Viewer('cesiumContainer');

    var startTime = performance.now();

    for (var k = 0; k < 999999; k++) {
    var array = [0.3, 2, 2, 3, 3, 4];

    Cesium.Cartesian3.unpackArray(array);
    }

    for (var i = 0; i < 1000000; i++) {
    var coordinates = [Math.random() * 80, Math.random() * 80];
    Cesium.Cartesian3.fromDegreesArray(coordinates);
    Cesium.Cartesian3.fromDegrees(
    Math.random() * 80,
    Math.random() * 80
    );
    }

    for (var j = 0; j < 1000000; j++) {
    Cesium.Cartesian3.fromDegrees(
    Math.random() * 80,
    Math.random() * 80
    );
    }

    var timeElapsed = performance.now() - startTime;
    console.log('done in ' + Math.round(timeElapsed) + ' ms');