Install profiling module:

ansible-galaxy collection install ansible.posix

Enable profiling in ansible.cfg in [defaults] section:

callback_whitelist = ansible.posix.profile_tasks