Hi
Should I call ex. "contex->Prepare(functionID);" every time I wish to call a function? I have speed tested it and it is three-times slower then in LUA if I
have to.
AngelScript
int r = 0;
// Find the function id for the function we want to execute.
int functionID = engine->GetFunctionIDByDecl(0, "float testFunc(float)");
if( functionID < 0 )
{
cout << "Test2() - The function 'float testFunc(float)' was not found." << endl;
contex->Release();
return -1;
}
timeOut = g_Timer.get() + 5.0;
//Operation speed test
OST = g_Timer.get();
int accum = 0;
r = contex->Prepare(functionID);
if( r < 0 )
{
cout << "Test2() - Failed to prepare the context." << endl;
return -1;
}
for (unsigned int i = 0; i < sz; i++)
{
contex->SetArgFloat(0, 2.55);
contex->Execute();
accum += contex->GetReturnFloat();
}
//Operation speed test
OST = g_Timer.get() - OST;
...
LUA
//Operation speed test
OST = g_Timer.get();
//g_scriptMgr.openFunc("testFunc");
//g_scriptMgr.addNumber(2.55);
int accum = 0;
for (unsigned int i = 0; i < sz; i++)
{
lua_pushstring(m_luaVM, "testFunc");
lua_gettable(m_luaVM, LUA_GLOBALSINDEX);
lua_pushnumber(m_luaVM, 2.55);
lua_call(m_luaVM, 1, 1);
const double ret = lua_tonumber(m_luaVM, -1);
lua_pop(m_luaVM, 1);
accum += ret;
}
//Operation speed test
OST = g_Timer.get() - OST;
...
[Edited by - ZeroSigma on April 19, 2006 5:34:55 AM]