Seems that casting param from text to char(32) needs to be done only once and f1 and f2 must be identical on performance. But function f2 with text param significantly slower, even with casting arg while pass it to function.
Tested postgresql versions 9.5.5 and 9.6.1 on Ubuntu 16.04. It's normal behavior or it's can be fixed?