[Bf-blender-cvs] [a0b8a9fe68] master: Alembic: addition of a scope timer to perform basic profiling.

Kévin Dietrich noreply at git.blender.org
Sat Feb 25 07:09:19 CET 2017


Commit: a0b8a9fe6816f1e704b2edbeccddf1e3285e4520
Author: Kévin Dietrich
Date:   Sat Feb 25 06:18:32 2017 +0100
Branches: master
https://developer.blender.org/rBa0b8a9fe6816f1e704b2edbeccddf1e3285e4520

Alembic: addition of a scope timer to perform basic profiling.

===================================================================

M	source/blender/alembic/intern/abc_util.cc
M	source/blender/alembic/intern/abc_util.h
M	source/blender/alembic/intern/alembic_capi.cc

===================================================================

diff --git a/source/blender/alembic/intern/abc_util.cc b/source/blender/alembic/intern/abc_util.cc
index 08c94f437e..158ec263df 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -37,6 +37,8 @@ extern "C" {
 #include "DNA_object_types.h"
 
 #include "BLI_math.h"
+
+#include "PIL_time.h"
 }
 
 std::string get_id_name(Object *ob)
@@ -523,3 +525,15 @@ AbcObjectReader *create_reader(const Alembic::AbcGeom::IObject &object, ImportSe
 
 	return reader;
 }
+
+/* ********************** */
+
+ScopeTimer::ScopeTimer(const char *message)
+	: m_message(message)
+	, m_start(PIL_check_seconds_timer())
+{}
+
+ScopeTimer::~ScopeTimer()
+{
+	std::fprintf(stderr, "%s: %fs\n", m_message, PIL_check_seconds_timer() - m_start);
+}
diff --git a/source/blender/alembic/intern/abc_util.h b/source/blender/alembic/intern/abc_util.h
index a7ac9df91c..85ba4d5c9c 100644
--- a/source/blender/alembic/intern/abc_util.h
+++ b/source/blender/alembic/intern/abc_util.h
@@ -146,4 +146,23 @@ ABC_INLINE void copy_yup_from_zup(short yup[3], const short zup[3])
 	yup[2] = -zup[1];
 }
 
+/* *************************** */
+
+#undef ABC_DEBUG_TIME
+
+class ScopeTimer {
+	const char *m_message;
+	double m_start;
+
+public:
+	ScopeTimer(const char *message);
+	~ScopeTimer();
+};
+
+#ifdef ABC_DEBUG_TIME
+#	define SCOPE_TIMER(message) ScopeTimer prof(message)
+#else
+#	define SCOPE_TIMER(message)
+#endif
+
 #endif  /* __ABC_UTIL_H__ */
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index d8d017119b..dc5146a26e 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -542,6 +542,8 @@ ABC_INLINE bool is_mesh_and_strands(const IObject &object)
 
 static void import_startjob(void *user_data, short *stop, short *do_update, float *progress)
 {
+	SCOPE_TIMER("Alembic import, objects reading and creation");
+
 	ImportJobData *data = static_cast<ImportJobData *>(user_data);
 
 	data->stop = stop;
@@ -677,6 +679,8 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa
 
 static void import_endjob(void *user_data)
 {
+	SCOPE_TIMER("Alembic import, cleanup");
+
 	ImportJobData *data = static_cast<ImportJobData *>(user_data);
 
 	std::vector<AbcObjectReader *>::iterator iter;




More information about the Bf-blender-cvs mailing list