Rust Performance: A story featuring perf and flamegraph on Linux
blog.adamperry.me
blog.adamperry.me
for i := 0; i < 10; i++ {
something(honk[i])
}
But if you do that, you get a bounds check on every iteration. Much faster to do this: subhonk := honk[:10]
for _, v := range subhonk {
something(v)
}
There's no range check inside the loop of a golang range iterator, for obvious reasons. let mut count = 0;
for b in &bwt[(i * self.k) + 1 .. r + 1] {
if b == a {
count += 1;
}
}
Gave me similar performance to the filter/count iterators, as both elide bounds checking. I thought I mentioned that in the parting thoughts, but I may be misremembering and I have to run.I was looking for an alternative to Instruments (macOS) on Linux and I came across callgrind and kcachegrind, which worked really well for me when profiling some Rust code.
I am growing to like perf a lot, though. It seems (haven't measured though) to impose less runtime overhead, and the reporting and source annotation tools are top notch.