Blender V4.3
subdiv_stats.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2018 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BKE_subdiv.hh"
10
11#include <cstdio>
12
13#include "BLI_time.h"
14
15namespace blender::bke::subdiv {
16
18{
20 stats->subdiv_to_mesh_time = 0.0;
22 stats->evaluator_creation_time = 0.0;
23 stats->evaluator_refine_time = 0.0;
24 stats->subdiv_to_ccg_time = 0.0;
25 stats->subdiv_to_ccg_elements_time = 0.0;
26 stats->topology_compare_time = 0.0;
27}
28
30{
31 stats->begin_timestamp_[value] = BLI_time_now_seconds();
32}
33
34void stats_end(SubdivStats *stats, StatsValue value)
35{
36 stats->values_[value] = BLI_time_now_seconds() - stats->begin_timestamp_[value];
37}
38
40{
41 stats->values_[value] = 0.0;
42}
43
44void stats_print(const SubdivStats *stats)
45{
46#define STATS_PRINT_TIME(stats, value, description) \
47 do { \
48 if ((stats)->value > 0.0) { \
49 printf(" %s: %f (sec)\n", description, (stats)->value); \
50 } \
51 } while (false)
52
53 printf("Subdivision surface statistics:\n");
54
55 STATS_PRINT_TIME(stats, topology_refiner_creation_time, "Topology refiner creation time");
56 STATS_PRINT_TIME(stats, subdiv_to_mesh_time, "Subdivision to mesh time");
57 STATS_PRINT_TIME(stats, subdiv_to_mesh_geometry_time, " Geometry time");
58 STATS_PRINT_TIME(stats, evaluator_creation_time, "Evaluator creation time");
59 STATS_PRINT_TIME(stats, evaluator_refine_time, "Evaluator refine time");
60 STATS_PRINT_TIME(stats, subdiv_to_ccg_time, "Subdivision to CCG time");
61 STATS_PRINT_TIME(stats, subdiv_to_ccg_elements_time, " Elements time");
62 STATS_PRINT_TIME(stats, topology_compare_time, "Topology comparison time");
63
64#undef STATS_PRINT_TIME
65}
66
67} // namespace blender::bke::subdiv
Platform independent time functions.
double BLI_time_now_seconds(void)
Definition time.c:65
#define printf
void stats_init(SubdivStats *stats)
void stats_reset(SubdivStats *stats, StatsValue value)
void stats_begin(SubdivStats *stats, StatsValue value)
void stats_end(SubdivStats *stats, StatsValue value)
void stats_print(const SubdivStats *stats)
double values_[NUM_SUBDIV_STATS_VALUES]
double begin_timestamp_[NUM_SUBDIV_STATS_VALUES]
#define STATS_PRINT_TIME(stats, value, description)