-
Notifications
You must be signed in to change notification settings - Fork 1
/
profiling.c
70 lines (54 loc) · 2.57 KB
/
profiling.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "profiling.h"
#include "logger.h"
#include <stdlib.h>
int tickComparison(const void* first, const void* second)
{
const ProfilingItem* a = first;
const ProfilingItem* b = second;
if (a->ticks > b->ticks) return -1;
if (a->ticks < b->ticks) return 1;
return 0;
}
void sort(ProfilingItem* items, const unsigned count)
{
qsort(items, count, sizeof(ProfilingItem), tickComparison);
}
void primitiveStats(const PrimitiveCounter* const counter, const double seconds, const double drawcalls)
{
logAlways(" Primitive statistics:");
const uint64 total = counter->triangles + counter->triangleStrips + counter->triangleFans +
counter->lines + counter->lineStrips + counter->lineLoops + counter->points;
if (total == 0) {
logAlways(" Nothing was drawn, vertex count 0");
return;
}
logAlways(" Total vertices %llu. %.1f vertices/s, %.1f vertices/call, consisting of:", total, (double)total / seconds, (double)total / drawcalls);
if (counter->triangles) {
logAlways(" - Triangle vertices %llu. %.1f verts/s, %.1f verts/call", counter->triangles,
(double)counter->triangles / seconds, (double)counter->triangles / drawcalls);
}
if (counter->triangleStrips) {
logAlways(" - Triangle strip vertices %llu. %.1f verts/s, %.1f verts/call", counter->triangleStrips,
(double)counter->triangleStrips / seconds, (double)counter->triangleStrips / drawcalls);
}
if (counter->triangleFans) {
logAlways(" - Triangle fan vertices %llu. %.1f verts/s, %.1f verts/call", counter->triangleFans,
(double)counter->triangleFans / seconds, (double)counter->triangleFans / drawcalls);
}
if (counter->lines) {
logAlways(" - Line vertices %llu. %.1f verts/s, %.1f verts/call", counter->lines,
(double)counter->lines / seconds, (double)counter->lines / drawcalls);
}
if (counter->lineStrips) {
logAlways(" - Line strip vertices %llu. %.1f verts/s, %.1f verts/call", counter->lineStrips,
(double)counter->lineStrips / seconds, (double)counter->lineStrips / drawcalls);
}
if (counter->lineLoops) {
logAlways(" - Line loop vertices %llu. %.1f verts/s, %.1f verts/call", counter->lineLoops,
(double)counter->lineLoops / seconds, (double)counter->lineLoops / drawcalls);
}
if (counter->points) {
logAlways(" - Point vertices %llu. %.1f verts/s, %.1f verts/call", counter->points,
(double)counter->points / seconds, (double)counter->points / drawcalls);
}
}