Commit 4af50a89 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Minor measure_loc improvements

parent ee277f56
...@@ -124,6 +124,9 @@ def run(sampler, kind): ...@@ -124,6 +124,9 @@ def run(sampler, kind):
except KeyboardInterrupt: except KeyboardInterrupt:
print "Interrupted!" print "Interrupted!"
traceback.print_exc() traceback.print_exc()
except:
print "ERROR!"
traceback.print_exc()
times = sampler.stop() times = sampler.stop()
......
...@@ -34,11 +34,25 @@ double floattime() { ...@@ -34,11 +34,25 @@ double floattime() {
return (double)t.tv_sec + t.tv_usec*0.000001; return (double)t.tv_sec + t.tv_usec*0.000001;
} }
static double time_to_log = 0.0;
// Run calibrate.py and divide the time accounted to calibrate.py:2 by the loop count (10M)
#define CALIBRATION_CONSTANT 0.0000001
static PyObject * static PyObject *
trace(PyObject *self, PyObject *args) trace(PyObject *self, PyObject *args)
{ {
if (next_time) bool log = false;
*next_time += (floattime() - prev_time); if (next_time) {
double f = (floattime() - prev_time);
f -= CALIBRATION_CONSTANT;
*next_time += f;
time_to_log -= f;
if (time_to_log < 0) {
time_to_log = 0.1;
log = true;
}
}
PyObject* _frame; PyObject* _frame;
char* event; char* event;
...@@ -51,7 +65,8 @@ trace(PyObject *self, PyObject *args) ...@@ -51,7 +65,8 @@ trace(PyObject *self, PyObject *args)
PyObject* fn = frame->f_code->co_filename; PyObject* fn = frame->f_code->co_filename;
char* fn_str = PyString_AsString(fn); char* fn_str = PyString_AsString(fn);
//printf("'%s': %s:%d (%p)\n", event, fn_str, frame->f_lineno, frame->f_back); if (log)
printf("'%s': %s:%d (%p)\n", event, fn_str, frame->f_lineno, frame->f_back);
if (strcmp(event, "call") == 0) { if (strcmp(event, "call") == 0) {
Position p(fn_str, frame->f_lineno); Position p(fn_str, frame->f_lineno);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment