Commit bdaaf6b6 authored by Chris Toshok's avatar Chris Toshok

add Stats::clear, and expose clearStats/dumpStats under the __pyston__ module

parent 3c972d7b
......@@ -40,6 +40,7 @@ public:
static void setEnabled(bool enabled) { Stats::enabled = enabled; }
static void log(int id, int count = 1) { (*counts)[id] += count; }
static void clear() { std::fill(counts->begin(), counts->end(), 0); }
static void dump();
static void endOfInit();
};
......
......@@ -48,10 +48,25 @@ static Box* setOption(Box* option, Box* value) {
return None;
}
static Box* clearStats() {
Stats::clear();
return None;
}
static Box* dumpStats() {
Stats::dump();
return None;
}
void setupPyston() {
pyston_module = createModule("__pyston__", "__builtin__");
pyston_module->giveAttr("setOption",
new BoxedBuiltinFunctionOrMethod(boxRTFunction((void*)setOption, UNKNOWN, 2), "setOption"));
pyston_module->giveAttr("clearStats",
new BoxedBuiltinFunctionOrMethod(boxRTFunction((void*)clearStats, NONE, 0), "clearStats"));
pyston_module->giveAttr("dumpStats",
new BoxedBuiltinFunctionOrMethod(boxRTFunction((void*)dumpStats, NONE, 0), "dumpStats"));
}
}
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