Are .ps1 files containing script-based cmdlets parsed/DLR'd every time they are executed? I'm seeing a huge difference in performance between a function in a .ps1 vs. a function in a .psm1 that suggests the .ps1 function is recompiled into the DLR on every execution. In a 10,000 iteration run:
Calling a function defined in another .ps1: 228,224 ms
Calling a function in the same .ps1: 634 ms, 360x faster
Calling a function defined in another .psm1: 636 ms, 359x faster
This is with PowerShell 4.0 on Windows 8.1 x64.