我的目标是分析内核模块中每个函数的执行时间。使用我在网上看到的示例脚本,我想出了以下脚本来满足我的需求。但有时我会得到计算延迟的负值。虽然,它们很少发生,但我想这表明我的脚本有问题。有人可以帮我吗?
probe module(@1).function(@2).call {
begin = gettimeofday_ns()
}
probe module(@1).function(@2).return {
if (begin>0)
stats <<< gettimeofday_ns() - begin
}
probe end {
if (begin == 0) {
printf("No samples observed so far.\n");
} else {
printf("Distribution of %s latencies (in nanoseconds) for %d samples\n", @2, @count(stats))
printf("max/avg/min: %d/%d/%d\n", @max(stats), @avg(stats), @min(stats))
print(@hist_log(stats))
}
}
global begin, stats