Blender  V2.93
subdiv_stats.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2018 by Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "BKE_subdiv.h"
25 
26 #include <stdio.h>
27 
28 #include "PIL_time.h"
29 
31 {
32  stats->topology_refiner_creation_time = 0.0;
33  stats->subdiv_to_mesh_time = 0.0;
34  stats->subdiv_to_mesh_geometry_time = 0.0;
35  stats->evaluator_creation_time = 0.0;
36  stats->evaluator_refine_time = 0.0;
37  stats->subdiv_to_ccg_time = 0.0;
38  stats->subdiv_to_ccg_elements_time = 0.0;
39  stats->topology_compare_time = 0.0;
40 }
41 
43 {
44  stats->begin_timestamp_[value] = PIL_check_seconds_timer();
45 }
46 
48 {
49  stats->values_[value] = PIL_check_seconds_timer() - stats->begin_timestamp_[value];
50 }
51 
53 {
54  stats->values_[value] = 0.0;
55 }
56 
58 {
59 #define STATS_PRINT_TIME(stats, value, description) \
60  do { \
61  if ((stats)->value > 0.0) { \
62  printf(" %s: %f (sec)\n", description, (stats)->value); \
63  } \
64  } while (false)
65 
66  printf("Subdivision surface statistics:\n");
67 
68  STATS_PRINT_TIME(stats, topology_refiner_creation_time, "Topology refiner creation time");
69  STATS_PRINT_TIME(stats, subdiv_to_mesh_time, "Subdivision to mesh time");
70  STATS_PRINT_TIME(stats, subdiv_to_mesh_geometry_time, " Geometry time");
71  STATS_PRINT_TIME(stats, evaluator_creation_time, "Evaluator creation time");
72  STATS_PRINT_TIME(stats, evaluator_refine_time, "Evaluator refine time");
73  STATS_PRINT_TIME(stats, subdiv_to_ccg_time, "Subdivision to CCG time");
74  STATS_PRINT_TIME(stats, subdiv_to_ccg_elements_time, " Elements time");
75  STATS_PRINT_TIME(stats, topology_compare_time, "Topology comparison time");
76 
77 #undef STATS_PRINT_TIME
78 }
eSubdivStatsValue
Definition: BKE_subdiv.h:91
Platform independent time functions.
double topology_compare_time
Definition: BKE_subdiv.h:124
double topology_refiner_creation_time
Definition: BKE_subdiv.h:110
double begin_timestamp_[NUM_SUBDIV_STATS_VALUES]
Definition: BKE_subdiv.h:131
double values_[NUM_SUBDIV_STATS_VALUES]
Definition: BKE_subdiv.h:126
double subdiv_to_mesh_time
Definition: BKE_subdiv.h:112
double evaluator_refine_time
Definition: BKE_subdiv.h:118
double subdiv_to_ccg_time
Definition: BKE_subdiv.h:120
double subdiv_to_ccg_elements_time
Definition: BKE_subdiv.h:122
double subdiv_to_mesh_geometry_time
Definition: BKE_subdiv.h:114
double evaluator_creation_time
Definition: BKE_subdiv.h:116
void BKE_subdiv_stats_init(SubdivStats *stats)
Definition: subdiv_stats.c:30
void BKE_subdiv_stats_end(SubdivStats *stats, eSubdivStatsValue value)
Definition: subdiv_stats.c:47
void BKE_subdiv_stats_reset(SubdivStats *stats, eSubdivStatsValue value)
Definition: subdiv_stats.c:52
void BKE_subdiv_stats_begin(SubdivStats *stats, eSubdivStatsValue value)
Definition: subdiv_stats.c:42
#define STATS_PRINT_TIME(stats, value, description)
void BKE_subdiv_stats_print(const SubdivStats *stats)
Definition: subdiv_stats.c:57
double PIL_check_seconds_timer(void)
Definition: time.c:80