-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
I profiled a WebGL Unity game that had analytics enabled, and by far the most expensive call chain was PATH.normalize and related, in particular because of the .join("/") call. Just replacing the body of normalize with if(path[0] === "/" && path[1] === "/") return path.slice(1); return path; fixed the constant stutters that I was looking at. I cannot stress enough how much of a performance increase this was. Checking if the string is already normalized should help immensely.
I'm sorry I don't have any hard statistics ready for you, but just profiling any Unity game that has frequent virtual FS access (as with Unity's analytics enabled) with the Firefox Profiler should show it immediately.
I'm unsure what version of Emscripten was used in the game I profiled, but PATH.normalize is completely unchanged relative to now.