Quasimondo / QuasimondoJS

A collection of more or less useful Javascript utils and snippets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance hit from try/catch

mbloch opened this issue · comments

It looks like the presence of try/catch statements in your blur functions is affecting performance. After removing the try/catch, I saw a 2.5x speedup blurring a 1000x1000 image using stack blur in Chrome (version 32). Other browsers had smaller improvements.

Apparently functions containing try/catch statements will run in unoptimized mode in Chrome and other browsers, which even affects the performance of code outside the try block. (e.g. http://jsperf.com/213123123901230291)

Putting the blur calculations into separate functions should fix this.

Ah, that's very interesting -. thanks for reporting it! I can surely remove the try/catch and have everyone handle those errors themselves.