MCPcopy Create free account
hub / github.com/anjo76/angelscript / Test

Function Test

sdk/tests/test_performance/source/test_string_pooled.cpp:218–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216
217
218void Test(double *testTime)
219{
220 asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
221 COutStream out;
222 engine->SetMessageCallback(asMETHOD(COutStream,Callback), &out, asCALL_THISCALL);
223
224 RegisterScriptString2(engine);
225
226 asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE);
227 mod->AddScriptSection(TESTNAME, script, strlen(script), 0);
228 int r = mod->Build();
229 if( r >= 0 )
230 {
231#ifndef _DEBUG
232 asIScriptContext *ctx = engine->CreateContext();
233 ctx->Prepare(mod->GetFunctionByDecl("void TestStringP()"));
234
235 double time = GetSystemTimer();
236
237 r = ctx->Execute();
238
239 time = GetSystemTimer() - time;
240
241 if( r != 0 )
242 {
243 printf("Execution didn't terminate with asEXECUTION_FINISHED\n");
244 if( r == asEXECUTION_EXCEPTION )
245 {
246 printf("Script exception\n");
247 asIScriptFunction *func = ctx->GetExceptionFunction();
248 printf("Func: %s\n", func->GetName());
249 printf("Line: %d\n", ctx->GetExceptionLineNumber());
250 printf("Desc: %s\n", ctx->GetExceptionString());
251 }
252 }
253 else
254 *testTime = time;
255
256 ctx->Release();
257#endif
258 }
259 else
260 printf("Build failed\n");
261 engine->Release();
262
263 // Clean up the string pool
264 for( asUINT n = 0; n < pool.size(); n++ )
265 delete pool[n];
266 pool.clear();
267}
268
269} // namespace
270

Callers

nothing calls this directly

Calls 15

RegisterScriptString2Function · 0.85
SetMessageCallbackMethod · 0.80
AddScriptSectionMethod · 0.80
CreateContextMethod · 0.80
GetFunctionByDeclMethod · 0.80
ExecuteMethod · 0.80
GetExceptionFunctionMethod · 0.80
GetExceptionStringMethod · 0.80
GetSystemTimerFunction · 0.70
GetModuleMethod · 0.45
BuildMethod · 0.45

Tested by

no test coverage detected