I’m using React and react-komposer and in some of my composers I have multiple subscriptions. I try not to but in some cases it’s inevitable.
And I had the thought that it might be faster to wait for one to be ready, pass that data, then wait for the next one, and pass in the new data along with re-passing in the first sub’s data.
But I’m having trouble measuring this. In each case, my console log always returns 0. I even tried DevTools throttling and still got 0. (Or maybe it means they’re equal but my intuition doubts that)
- How do I better test this for performance?
- If you’ve already tested this, what were your results?
Here’s my example code
Check at “once” *
const courseSub = Meteor.subscribe('courses.single', id);
const courseUnitsSub = Meteor.subscribe('courseUnits.list.forCourse', id);
const startTime = Date.now(); // attempt at measuring
if (courseSub.ready() && courseUnitsSub.ready()) {
const endTime = Date.now(); // attempt at measuring
console.log('ready after', endTime - startTime, `= ${endTime} - ${startTime}`); // attempt at measuring
// get data
onData(null, data); // pass in data retrieved
Check in sequence
if (courseSub.ready()) {
const endTime1 = Date.now();
console.log('ready after', endTime1 - startTime, `= ${endTime1} - ${startTime}`);
if (courseUnitsSub.ready()) {
const endTime2 = Date.now();
console.log('ready after', endTime2 - startTime, `= ${endTime2} - ${startTime}`);