Partial function profiling feature
bearophile
bearophileHUGS at lycos.com
Tue Oct 12 04:59:23 PDT 2010
While optimizing D code I have found the built-in dmd profiler very useful. It gives experimental data about where the code may need improvements, you need much less guessing.
In some situations I find that a function that takes lot of the running time is shaped like this, it contains two different big loops:
void foo(int n) {
// pre-stuff
foreach (i; 0 .. n) {
...
}
// middle-stuff
foreach (i; 0 .. n) {
...
}
// post-stuff
}
In this situation often it's only one of the two loops that uses most of the running time of the foo() function. I may guess, but I'd like the profiler to give me more data. So sometimes I split the foo() into something like:
void foo1(int n) {
foreach (i; 0 .. n) {
...
}
}
void foo2(int n) {
foreach (i; 0 .. n) {
...
}
}
void foo(int n) {
// pre-stuff
foo1(n);
// middle-stuff
foo2(n);
// post-stuff
}
This allows me to profile how much time the two parts of foo() take. In this situation in D code I'd like like a profiling "breakpoint":
void foo(int n) {
// pre-stuff
foreach (i; 0 .. n) {
...
}
profile_point(); // ***
// middle-stuff
foreach (i; 0 .. n) {
...
}
// post-stuff
}
So the profiling gives me the foo timings split in two (or more) parts. Is this a possible feature?
Bye,
bearophile
More information about the Digitalmars-d
mailing list