1
0
forked from mirrors/0ad

Change profiling calls to get a better view of what is actually slow and what is not.

This was SVN commit r18438.
This commit is contained in:
wraitii
2016-06-25 13:12:35 +00:00
parent d2e081b602
commit 898ab5229b
14 changed files with 58 additions and 15 deletions
@@ -268,6 +268,32 @@ bool ProfileStop(JSContext* UNUSED(cx), uint UNUSED(argc), jsval* vp)
return true;
}
bool ProfileAttribute(JSContext* cx, uint argc, jsval* vp)
{
const char* name = "(ProfileAttribute)";
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (args.length() >= 1)
{
std::string str;
if (!ScriptInterface::FromJSVal(cx, args[0], str))
return false;
typedef boost::flyweight<
std::string,
boost::flyweights::no_tracking,
boost::flyweights::no_locking
> StringFlyweight;
name = StringFlyweight(str).get().c_str();
}
g_Profiler2.RecordAttribute(name);
args.rval().setUndefined();
return true;
}
// Math override functions:
// boost::uniform_real is apparently buggy in Boost pre-1.47 - for integer generators
@@ -364,6 +390,7 @@ ScriptInterface_impl::ScriptInterface_impl(const char* nativeScopeName, const sh
Register("ProfileStart", ::ProfileStart, 1);
Register("ProfileStop", ::ProfileStop, 0);
Register("ProfileAttribute", ::ProfileAttribute, 1);
runtime->RegisterContext(m_cx);
}