I have a Firebase Cloud Function that parses some HTML among other things. I've measured the HTML-parsing method itself, and it takes about 300ms in the emulator on a MacBook Pro. It seems to take about 4-8 seconds when deployed to Firebase, which is not a tolerable duration for my application.
I am using Dart to write my Firebase Cloud Functions using firebase_functions_interop and compiling to JS with Dart2JS. The method that is performing drastically differently between environments is actually Dart's built-in HTML parsing method. I know cold starts are a common reason for cloud functions taking longer than expected, but it seems like that's not the culprit here, since I'm explicitly measuring the time it takes to parse the HTML, and that's where I'm seeing the huge difference.
Is it to be expected that a Cloud Function would run drastically slower in production than on a MacBook Pro?