Extremely slow execution of an external dependency function

I am using mmwr-week package. For some reason it takes about 30 seconds on average to run the following code in Realm while it takes about 0.15 seconds on my MacBook Pro:

exports = function(){
  const mmwr = require("mmwr-week");
  let mdate = new mmwr.MMWRDate();
  const d = new Date();
  for (let i = 0; i < 1000; i++) {
    mdate.fromJSDate(d);
  }
};

Any ideas why there is a ~200x difference in performance?

Hey Ilya,

There are some improvements we have planned to make dependency resolution a bit faster over the next few months. In the meantime, I would suggest looking into an alternative package if the latency is blocking.

1 Like

Hi Sumedha, just to clarify: the dependency itself is loading quickly. It’s a very simple function call (inside the loop) that is very slow.