This test validates that the Datadog Python profiler correctly profiles memory allocations.
- Creates a list of
Noneof a target size (1e6 items) - The list is then filled by two functions
allocate_memory_1andallocate_memory_2that allocate 1024 bytes and 3 * 1024 bytes respectively. The list is filled until the last item is notNone.
Those represent the number of times the function called the allocator. This is hard to estimate manually because of how the sampling logic works (see here), but the numbers are stable.
^<module>;run;allocate_memory_1$should be present and should account for 25% of the samples.^<module>;run;allocate_memory_2$should be present and should account for 45% of the samples.^<module>;__init__;grow_list$should be present and should account for 20% of the samples.
^<module>;run;allocate_memory_1$should be present and should account for 25% of the space (1024 bytes)^<module>;run;allocate_memory_2$should be present and should account for 75% of the space (3 * 1024 bytes)^<module>;__init__;grow_list$should be present and should account for 3% of the space (list container, noise compared to the other allocations)