The default fields are all calculated in Java (very fast) whereas the custom ones are done in Javascript running in a sandbox (much slower but safe to run untrusted code). I can post Java fragments of specific things.
You can create custom interval fields to compute things for parts of an activity. These are also computed when you zoom on the timeline chart and displayed top left. So that might handle your “part of the activity” requirement.