Split profiling code into cpp files.

3 jobs from master in 3 minutes 47 seconds (queued for 2 seconds)
Status Job ID Name Coverage
  Build
passed #3780
build_cmake

00:57

 
  Test
passed #3781
run_tests

00:58

 
  Sanitizer
passed #3782
run_address_sanitizer

01:51