Compute heartbeat size by a function