evaluateJavaScript on WKWebView running slow - wkwebview

Running evaluateJavaScript on a WKWebView to inject a JS script can take quite some time to run on a device.
The JS script is quite complex, but is is normal for evaluateJavascript to take 20-30 seconds to run?

Related

Node takes too long to run and use too much ram

I'm building a website with react. whenever I start react app using npm start. it takes too much time to exicute (almost 30-40 minutes). and after starting the app my laptop be too much slower. How can I fix this problem.?
Note: I have used yarn start and almost same result.

How do I profile a node.js program from start to end?

Suppose I have a node.js cli program that can be run as node some-program.js and it exits in 10 seconds. How do I profile it? I want to get flame graphs and time spent in each functions.
node --prof some-program.js will produce an isolate-* for each worker thread.
node --prof-process isolate... will produce a user-friendly output.
You need some experience to be able to read it - but basically your program spends time in three ways: executing JS code, compiling JS code and running system libraries.

Simulating heavy load in node/electron application

I am looking to spawn some child processes in the background of an electron app to handle certain tasks. While I'm working on this, I'd like to see how it affects performance of the front end. Is there a function I can run that would simulate semi-heavy processing for a node process? The end goal here is to make sure that I am building an app that has a snappy UI even when there are some background processes that are under heavy load. I've messed this up in the past and want to get a head start on making sure I don't repeat mistakes.

Heroku node timeout because of enormous task

Our node app gets quite big and one job takes quite some time to execute. We run this job with a cronjob, but by calling the URL. Now Heroku has problems with this, because the job takes more than 30 seconds to finish. So we receive a time-out and after that it tries to execute it immediately again, and again, till our Memory quota is about 300% and the app crashes.
Now I want to fix this. Locally we don't have any problems running this script at all. It takes about a minute (for now, but in the future if we have more users it may take more time) to finish and memory stays stable.
Now running this script on the background should fix the problem according https://devcenter.heroku.com/articles/request-timeout#debugging-request-timeouts
Overe here https://devcenter.heroku.com/articles/asynchronous-web-worker-model-using-rabbitmq-in-node#getting-started I read about JackRabbit. But it seems like it's used for systems like RabbitMQ https://github.com/hunterloftis/jackrabbit
So my question: anyone who has experience with background tasks in node? Can and should I use JackRabbit for my background tasks, or are there better solutions? My background task just contains a very complex ExpressJS task, which takes some time to execute so....
I'm the Node.js platform owner at Heroku (and I actually wrote the web worker article you referenced).
Your use case sounds like it may fit the scheduler very well:
https://devcenter.heroku.com/articles/scheduler
It's a great replacement for cron-type jobs.

Node.js require becomes extremely slow after OS X has been running for a while

When I reboot my Mac, starting up Node.js apps is nice and fast. Later, after the Mac has been on for a few hours, it gets REALLY slow.
I've used process.hrtime() to time various things, and it seems that it's all the require calls that take time, ie loading dependencies. Once everything is loaded, my apps run reasonably fast.
The difference is extreme: just after I've rebooted, an app may take 300ms to get through the require calls, then it takes something like 30 seconds once it's been on for a few hours.
What could be causing this?
Since how fast executing require is perfectly related to a disk loading performance.
So I suppose It's highly possible that HDD/SSD or whatever your project belongs causing that.
it's working fine right after you rebooted so maybe some background software(such as virus scan or auto downloader) is making IO blocking
You'd better start by checking your CPU/RAM/HDD status while the issue is occurring and see what happens if you move your project into USB flash drive or external HDD

Resources