Skip to content

Instantly share code, notes, and snippets.

@timholy
Created July 25, 2021 13:23
Show Gist options
  • Save timholy/f30ecca60a3154b934f4513f2004b8b2 to your computer and use it in GitHub Desktop.
Save timholy/f30ecca60a3154b934f4513f2004b8b2 to your computer and use it in GitHub Desktop.
DataFrames specialization and latency
using DataFrames, SnoopCompile, Statistics, ProfileView
# Note: load all packages first to prevent invalidation
d = DataFrame(n = 1:20, x = [3, 3, 3, 3, 1, 1, 1, 2, 1, 1,
2, 1, 1, 2, 2, 2, 3, 1, 1, 2]);
g = groupby(d, :x);
subset(g, :n => (n -> n .> mean(n))); # compile
select(g, :n => (n -> n .> mean(n))); # compile
tinf_subset = @snoopi_deep begin
subset(g, :n => (n -> n .> mean(n)))
end
tinf_select = @snoopi_deep begin
select(g, :n => (n -> n .> mean(n)))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment