MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / move_gameobjects_benchmark

Function move_gameobjects_benchmark

test/embind/embind_benchmark.cpp:392–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390}
391
392void __attribute__((noinline)) move_gameobjects_benchmark()
393{
394 const int N = 10000;
395 GameObjectPtr objects[N];
396 for (int i = 0; i < N; ++i) {
397 objects[i] = create_game_object();
398 }
399
400 volatile float t = emscripten_get_now();
401 for (int i = 0; i < N; ++i) {
402 TransformPtr t = objects[i]->GetTransform();
403 Vec3 pos = add(t->GetPosition(), Vec3(2.f, 0.f, 1.f));
404 Vec3 rot = add(t->GetRotation(), Vec3(0.1f, 0.2f, 0.3f));
405 t->SetPosition(pos);
406 t->SetRotation(rot);
407 }
408 volatile float t2 = emscripten_get_now();
409
410 Vec3 accum;
411 for (int i = 0; i < N; ++i) {
412 accum = add(add(accum, objects[i]->GetTransform()->GetPosition()), objects[i]->GetTransform()->GetRotation());
413 }
414 printf("C++ move_gameobjects %d iters: %f msecs. Result: %f\n", N, (t2-t), accum.x+accum.y+accum.z);
415}
416
417void __attribute__((noinline)) pass_gameobject_ptr_benchmark()
418{

Callers 1

mainFunction · 0.85

Calls 10

create_game_objectFunction · 0.85
Vec3Class · 0.85
printfFunction · 0.85
GetTransformMethod · 0.80
GetPositionMethod · 0.80
GetRotationMethod · 0.80
SetPositionMethod · 0.80
SetRotationMethod · 0.80
addFunction · 0.70
emscripten_get_nowFunction · 0.50

Tested by

no test coverage detected