Skip to content

Instantly share code, notes, and snippets.

@jsantell
Created May 5, 2015 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsantell/7833795ad07d94476b9f to your computer and use it in GitHub Desktop.
Save jsantell/7833795ad07d94476b9f to your computer and use it in GitHub Desktop.
worker test
/*
const { CanvasGraphUtils } = Cu.import("resource:///modules/devtools/GraphsOriginal.jsm", {});
const { DevToolsWorker } = devtools.require("devtools/shared/worker");
const UPPERBOUND = Math.pow(10, 3);
const timestamps = (function(){
var array = [];
for (let i = 0; i < UPPERBOUND; i++) {
array.push(i);
}
return array;
})();
const LOOP = 100;
*/
const { RecordingUtils } = devtools.require("devtools/performance/recording-utils");
const { RecordingUtils: RecordingUtils2 } = devtools.require("devtools/performance/recording-utils2");
const MARKERS = 40;
const TIMESTAMPS = 40;
const bigProfile = makeProfile();
const timestamps = (function () {
var times = [];
for (let i = 0; i < TIMESTAMPS; i++) {
times.push(i * 10000);
}
return times;
})();
const markers = (function () {
var markers = [];
for (let i = 0; i < MARKERS; i++) {
markers.push({ start: 10000, end: 11000 });
}
return markers;
})();
let test_workerSpeed = Task.async(function*(timer) {
let profile = makeProfile(5000);
timer.start("current-worker-offsetSampleTimes-small");
yield RecordingUtils.offsetSampleTimes(profile, 1);
timer.stop("current-worker-offsetSampleTimes-small");
timer.start("current-worker-offsetSampleTimes-large");
yield RecordingUtils.offsetSampleTimes(bigProfile, 1);
timer.stop("current-worker-offsetSampleTimes-large");
timer.start("current-worker-offsetMarkerTimes");
for (let i = 0; i < 20; i++) {
yield RecordingUtils.offsetMarkerTimes(markers, 1);
}
timer.stop("current-worker-offsetMarkerTimes");
timer.start("current-worker-offsetAndScaleTimestamps");
for (let i = 0; i < 20; i++) {
yield RecordingUtils.offsetAndScaleTimestamps(timestamps, 1, 1);
}
timer.stop("current-worker-offsetAndScaleTimestamps");
// Create a new profile for filtering samples. Filter out around half of the samples.
profile = makeProfile(5000);
timer.start("current-worker-filterSamples-small");
yield RecordingUtils2.filterSamples(profile, 12500);
timer.stop("current-worker-filterSamples-small");
// Create a new profile for filtering samples. Filter out around half of the samples.
profile = makeProfile();
timer.start("current-worker-filterSamples-large");
yield RecordingUtils2.filterSamples(profile, 25000);
timer.stop("current-worker-filterSamples-large");
profile = makeProfile(5000);
timer.start("dt-worker-offsetSampleTimes-small");
yield RecordingUtils2.offsetSampleTimes(profile, 1);
timer.stop("dt-worker-offsetSampleTimes-small");
timer.start("dt-worker-offsetSampleTimes-large");
yield RecordingUtils2.offsetSampleTimes(bigProfile, 1);
timer.stop("dt-worker-offsetSampleTimes-large");
timer.start("dt-worker-offsetMarkerTimes");
for (let i = 0; i < 20; i++) {
yield RecordingUtils2.offsetMarkerTimes(markers, 1);
}
timer.stop("dt-worker-offsetMarkerTimes");
timer.start("dt-worker-offsetAndScaleTimestamps");
for (let i = 0; i < 20; i++) {
yield RecordingUtils2.offsetAndScaleTimestamps(timestamps, 1, 1);
}
timer.stop("dt-worker-offsetAndScaleTimestamps");
// Create a new profile for filtering samples. Filter out around half of the samples.
profile = makeProfile(5000);
timer.start("dt-worker-filterSamples-small");
yield RecordingUtils2.filterSamples(profile, 12500);
timer.stop("dt-worker-filterSamples-small");
// Create a new profile for filtering samples. Filter out around half of the samples.
profile = makeProfile();
timer.start("dt-worker-filterSamples-large");
yield RecordingUtils2.filterSamples(profile, 25000);
timer.stop("dt-worker-filterSamples-large");
});
function makeProfile (count=50000) {
var p = {};
p.threads = [];
var thread = {};
p.threads.push(thread);
thread.samples = [];
for (let i = 0; i < count; i++) {
thread.samples.push({ time: 10000+i });
}
return p;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment