box2d 3.0.0
A 2D physics engine for games
 
Loading...
Searching...
No Matches
timer.h
1// SPDX-FileCopyrightText: 2023 Erin Catto
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "types.h"
7
9typedef struct b2Profile
10{
11 float step;
12 float pairs;
13 float collide;
14 float solve;
15 float buildIslands;
16 float solveConstraints;
17 float broadphase;
18 float continuous;
19} b2Profile;
20
22static const b2Profile b2_emptyProfile = B2_ZERO_INIT;
23
25typedef struct b2Statistics
26{
27 int32_t islandCount;
28 int32_t bodyCount;
29 int32_t contactCount;
30 int32_t jointCount;
31 int32_t proxyCount;
32 int32_t pairCount;
33 int32_t treeHeight;
34 int32_t stackCapacity;
35 int32_t stackUsed;
36 int32_t byteCount;
37 int32_t taskCount;
38 int32_t colorCounts[b2_graphColorCount + 1];
40
42typedef struct b2Timer
43{
44#if defined(_WIN32)
45 int64_t start;
46#elif defined(__linux__) || defined(__APPLE__)
47 unsigned long long start_sec;
48 unsigned long long start_usec;
49#else
50 int dummy;
51#endif
52} b2Timer;
53
54BOX2D_API b2Timer b2CreateTimer(void);
55BOX2D_API int64_t b2GetTicks(b2Timer* timer);
56BOX2D_API float b2GetMilliseconds(const b2Timer* timer);
57BOX2D_API float b2GetMillisecondsAndReset(b2Timer* timer);
58BOX2D_API void b2SleepMilliseconds(float milliseconds);
59
62#ifdef BOX2D_PROFILE
63
64#include <tracy/TracyC.h>
65#define b2TracyCZoneC(ctx, color, active) TracyCZoneC(ctx, color, active)
66#define b2TracyCZoneNC(ctx, name, color, active) TracyCZoneNC(ctx, name, color, active)
67#define b2TracyCZoneEnd(ctx) TracyCZoneEnd(ctx)
68
69#else
70
71#define b2TracyCZoneC(ctx, color, active)
72#define b2TracyCZoneNC(ctx, name, color, active)
73#define b2TracyCZoneEnd(ctx)
74
75#endif
#define b2_graphColorCount
Solver graph coloring.
Definition constants.h:83
Profiling data. Times are in milliseconds.
Definition timer.h:10
Counters that give details of the simulation size.
Definition timer.h:26
Timer for profiling. This has platform specific code and may not work on every platform.
Definition timer.h:43
types used by the Box2D API
#define B2_ZERO_INIT
Used for C zero initialization, such as b2Vec2 v = {0} where C++ requires b2Vec2 v = {}.
Definition types.h:32