Skip to content

Instantly share code, notes, and snippets.

@serialhex
Created January 19, 2017 15:17
Show Gist options
  • Save serialhex/7f729c641f47f58c3e174b2c67e8d851 to your computer and use it in GitHub Desktop.
Save serialhex/7f729c641f47f58c3e174b2c67e8d851 to your computer and use it in GitHub Desktop.
diff --git a/include/export.h b/include/export.h
index ca9bf47..714264b 100644
--- a/include/export.h
+++ b/include/export.h
@@ -279,6 +279,7 @@ int savePLY(ExportPoints points,
fb.open(filename, std::ios::out | std::ios::binary);
std::ostream outputStream(&fb);
std::cout << "Writing to disk...\n";
+ PLY_SCOPED_TIMER("Write");
ply.write(outputStream, true);
}
diff --git a/include/tinyply.h b/include/tinyply.h
index 4dbd436..66a0a27 100644
--- a/include/tinyply.h
+++ b/include/tinyply.h
@@ -19,6 +19,20 @@
#include <functional>
#include <cstring>
+#include <chrono>
+class scoped_timer
+{
+ std::string message;
+ std::chrono::high_resolution_clock::time_point t0;
+public:
+ scoped_timer(std::string message) : message{ std::move(message) }, t0{ std::chrono::high_resolution_clock::now() } {}
+ ~scoped_timer()
+ {
+ std::cout << message << " completed in " << std::to_string((std::chrono::duration<float>(std::chrono::high_resolution_clock::now() - t0).count() * 1000)) << " ms" << std::endl;
+ }
+};
+#define PLY_SCOPED_TIMER(MESSAGE) scoped_timer scoped_timer_ ## __LINE__(MESSAGE)
+
namespace tinyply
{
diff --git a/src/tinyply.cpp b/src/tinyply.cpp
index bc63a8a..e8b0268 100644
--- a/src/tinyply.cpp
+++ b/src/tinyply.cpp
@@ -194,6 +194,7 @@ void PlyFile::write_property_ascii(PlyProperty::Type t, std::ostream & os, uint8
void PlyFile::write_property_binary(PlyProperty::Type t, std::ostream & os, uint8_t * src, size_t & srcOffset)
{
+PLY_SCOPED_TIMER("write_property_binary");
os.write((char *)src, PropertyTable[t].stride);
srcOffset += PropertyTable[t].stride;
}
@@ -214,10 +215,13 @@ void PlyFile::write_binary_internal(std::ostream & os)
isBinary = true;
write_header(os);
+PLY_SCOPED_TIMER("write_binary_internal");
for (auto & e : elements)
{
+PLY_SCOPED_TIMER("for (auto & e : elements)");
for (size_t i = 0; i < e.size; ++i)
{
+PLY_SCOPED_TIMER("for (size_t i = 0; i < e.size; ++i)");
for (auto & p : e.properties)
{
auto & cursor = userDataTable[make_key(e.name, p.name)];
Setting up messaging!
Unwrapping: .\data\CALIBRATION-PANEL-STEINBICHLER
Project name: CALIBRATION-PANEL-STEINBICHLER
running unwrap
PhaseGradGuardBandPct: 5 slmPhaseRange: 5.96903 slmXScale: 2.57194 slmYScale: 1.44613
Doing sensor ROI
ccdVec: 3000 5120 2 1
Correcting Distortion
Computing Rays
slmVec: 3000 5120 2 1
Correcting Distortion
Computing Rays
Saving to PLY file: .\data\CALIBRATION-PANEL-STEINBICHLER\points\CALIBRATION-PANEL-STEINBICHLER.ply
ArrayFire v3.4.1 (CUDA, 64-bit Windows, build b9055b1)
Platform: CUDA Toolkit 8, Driver: CUDA Driver Version: 8000
[0] Quadro M5000, 8192 MB, CUDA Compute 5.2
max(max(input.Epsilon1))
[1 1 1 1]
336.5688
sum(sum(input.Epsilon1)) / (dims[0] * dims[1])
[1 1 1 1]
4.4254
Generating Mask
Masking points
Applying Mask
Getting points
Copying good points....................................................................................................................................................................................
Writing to disk...
write_property_binary completed in 0.002052 ms
write_property_binary completed in 0.012610 ms
write_property_binary completed in 0.000587 ms
write_property_binary completed in 0.001760 ms
write_property_binary completed in 0.001173 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.151902 ms
write_property_binary completed in 0.001173 ms
write_property_binary completed in 0.001173 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000880 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.063928 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.002053 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.139293 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000587 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000587 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.064514 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000587 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000587 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000587 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.061288 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000586 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.059823 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000586 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.082696 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000587 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.063928 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000587 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.058943 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.061289 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.001759 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.061288 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000587 ms
write_property_binary completed in 0.000586 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.062169 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000586 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.082989 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.061582 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000587 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.069206 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000587 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.001466 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000586 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000587 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.096479 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.000880 ms
write_property_binary completed in 0.012317 ms
write_property_binary completed in 0.000879 ms
write_property_binary completed in 0.000587 ms
write_property_binary completed in 0.000587 ms
write_property_binary completed in 0.000880 ms
for (size_t i = 0; i < e.size; ++i) completed in 0.108502 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment