profile what you care, monitor how it goes
Why semile?
We semile bcoz it helps overcome the flaw/bottleneck of our programs
A profiling framework that provides the ability to monitor programs, in general of any programming language, by the following two pieces of information:
P.S. The user-provided semantic specifications (via the profile library) is necessary for semantic profile
python3 (viewer)
g++ (c/cpp profile library)
(XML format, browse by codebeautify.org/xmlviewer))
semile
does not aim to profile all program execution, it only profile the execution specified via the profile library. Currently, cpp profile library is provided.
SEMILE
in same scope of the statementsAnd that's it!
In particular, a helpful way diagnosing is use SEMILE_MSG
to leave custom footprint message.
void quicksort(vector<int>& x, int start_pos, int end_pos)
{
SEMILE; // profile at beginning of the scope
// SEMILE_N(abc); // or profile with custom name
...
}
Here, every quicksort execution will be profiled.
Nested, or recursive SEMILE
is also possible.
void quicksort(vector<int>& x, int start_pos, int end_pos)
{
SEMILE;
SEMILE_MSG(GetStr(x, start_pos, end_pos));
...
int pivot = start_pos;
SEMILE_MSG("pivot: " + GetStr(x[pivot]) + "\\n");
...
Swap(x, i, j);
SEMILE_MSG(GetStr(x[i]) + " <=> " + GetStr(x[j]) + "\\n");
}
After SEMILE
, we can have SEMILE_MSG
at any time to log profile message.
Here, internal flow of quicksort is revealed and combined to resulted profile.
One possible viewer generated PNG is then as follows:
(run quicksort 3 times with random inputs)
Except c++, semile
also profiles c sources via the c interface.
Due to the lack of RAII, semile
support in c requires a pair of profile specifications:
SEMILE_BEGIN
, where profile resource is allocatedSEMILE_END
, where profile resource is releasedvoid quicksort(int* x, int start_pos, int end_pos)
{
void* inst = SEMILE_BEGIN;
SEMILE_MSG_C(inst, GetStr(x, start_pos, end_pos));
...
SEMILE_END(inst);
}
It takes much care to handle SEMILE_END
. However, be able to control directly the profile instance also gives much flexibility, e.g., conditional profile:
void* inst = NULL;
if (is_cared_run) {
inst = SEMILE_BEGIN;
}
...
SEMILE_END(inst);
Finally, there are two ways to disable semile
:
Please contact Rodney Kan by its_right@msn.com for any question/request/bug without hesitation.