Skip to content

Instantly share code, notes, and snippets.

@purplecabbage
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save purplecabbage/812fa5bb8e58ee258f8d to your computer and use it in GitHub Desktop.

Select an option

Save purplecabbage/812fa5bb8e58ee258f8d to your computer and use it in GitHub Desktop.

Revisions

  1. purplecabbage revised this gist Jul 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion devicereadyPerformance.js
    Original file line number Diff line number Diff line change
    @@ -22,4 +22,4 @@ document.addEventListener('deviceready',function() {
    console.log("average = " + (total / maxSamples));
    window.localStorage.perfLog = JSON.stringify([]);
    }
    }
    });
  2. purplecabbage revised this gist Jul 17, 2014. 1 changed file with 23 additions and 22 deletions.
    45 changes: 23 additions & 22 deletions devicereadyPerformance.js
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,25 @@
    var deltaT = +new Date() - window.performance.timing.navigationStart;
    var perfLog = window.localStorage.perfLog ? JSON.parse(window.localStorage.perfLog) : [];

    perfLog.push(deltaT);

    window.localStorage.perfLog = JSON.stringify(perfLog);

    var maxSamples = 100;
    if (perfLog.length < maxSamples) {
    window.location.reload();
    }
    else {
    perfLog.sort(function (a, b) {
    return (( a < b ) ? -1 : (( a > b ) ? 1 : 0 ));
    });
    console.log("min = " + perfLog[0]);
    console.log("max = " + perfLog[maxSamples-1]);
    var total = 0;
    for (var n = 0; n < maxSamples; n++) {
    total += perfLog[n];
    document.addEventListener('deviceready',function() {
    var deltaT = +new Date() - window.performance.timing.navigationStart;
    var perfLog = window.localStorage.perfLog ? JSON.parse(window.localStorage.perfLog) : [];
    perfLog.push(deltaT);

    window.localStorage.perfLog = JSON.stringify(perfLog);

    var maxSamples = 100;
    if (perfLog.length < maxSamples) {
    window.location.reload();
    }
    else {
    perfLog.sort(function (a, b) {
    return (( a < b ) ? -1 : (( a > b ) ? 1 : 0 ));
    });
    console.log("min = " + perfLog[0]);
    console.log("max = " + perfLog[maxSamples-1]);
    var total = 0;
    for (var n = 0; n < maxSamples; n++) {
    total += perfLog[n];
    }
    console.log("average = " + (total / maxSamples));
    window.localStorage.perfLog = JSON.stringify([]);
    }
    console.log("average = " + (total / maxSamples));
    window.localStorage.perfLog = JSON.stringify([]);
    }
  3. purplecabbage created this gist Jul 17, 2014.
    24 changes: 24 additions & 0 deletions devicereadyPerformance.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    var deltaT = +new Date() - window.performance.timing.navigationStart;
    var perfLog = window.localStorage.perfLog ? JSON.parse(window.localStorage.perfLog) : [];

    perfLog.push(deltaT);

    window.localStorage.perfLog = JSON.stringify(perfLog);

    var maxSamples = 100;
    if (perfLog.length < maxSamples) {
    window.location.reload();
    }
    else {
    perfLog.sort(function (a, b) {
    return (( a < b ) ? -1 : (( a > b ) ? 1 : 0 ));
    });
    console.log("min = " + perfLog[0]);
    console.log("max = " + perfLog[maxSamples-1]);
    var total = 0;
    for (var n = 0; n < maxSamples; n++) {
    total += perfLog[n];
    }
    console.log("average = " + (total / maxSamples));
    window.localStorage.perfLog = JSON.stringify([]);
    }