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

Function main

test/benchmark/test_box2d_benchmark.cpp:72–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70void iter();
71
72int main(int argc, char **argv) {
73 int arg = argc > 1 ? argv[1][0] - '0' : 3;
74 switch(arg) {
75 case 0: return 0; break;
76 case 1: WARMUP = 5; FRAMES = 35; break;
77 case 2: WARMUP = 32; FRAMES = 161; break;
78 case 3: WARMUP = 64; FRAMES = 333; break;
79 case 4: WARMUP = 5*64; FRAMES = 7*333; break;
80 case 5: WARMUP = 10*64; FRAMES = 17*333; break;
81 default: printf("error: %d\\n", arg); return -1;
82 }
83
84 // do not split out warmup, do not ignore initial stalls
85 FRAMES += WARMUP;
86 WARMUP = 0;
87
88 times = new clock_t[FRAMES];
89
90 // Define the gravity vector.
91 b2Vec2 gravity(0.0f, -10.0f);
92
93 // Construct a world object, which will hold and simulate the rigid bodies.
94 world = new b2World(gravity);
95 world->SetAllowSleeping(false);
96
97 {
98 b2BodyDef bd;
99 b2Body* ground = world->CreateBody(&bd);
100
101 b2EdgeShape shape;
102 shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
103 ground->CreateFixture(&shape, 0.0f);
104 }
105
106 {
107 float32 a = 0.5f;
108 b2PolygonShape shape;
109 shape.SetAsBox(a, a);
110
111 b2Vec2 x(-7.0f, 0.75f);
112 b2Vec2 y;
113 b2Vec2 deltaX(0.5625f, 1);
114 b2Vec2 deltaY(1.125f, 0.0f);
115
116 for (int32 i = 0; i < e_count; ++i) {
117 y = x;
118
119 for (int32 j = i; j < e_count; ++j) {
120 b2BodyDef bd;
121 bd.type = b2_dynamicBody;
122 bd.position = y;
123 b2Body* body = world->CreateBody(&bd);
124 body->CreateFixture(&shape, 5.0f);
125
126 topBody = body;
127
128 y += deltaY;
129 }

Callers

nothing calls this directly

Calls 3

printfFunction · 0.85
iterFunction · 0.70
SetMethod · 0.45

Tested by

no test coverage detected