From 7e77048593dfa7f31c2bac00d8dd2f7cb8628cb7 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 24 Aug 2022 16:32:01 +0200 Subject: [PATCH] Removed shiny profiler. The Shiny profiler was only working on MSVC and nowadays the sampling profiler inside Visual Studio is better. --- CMakeLists.txt | 20 - doc/Dependencies.md | 1 - sandboxes/aabb-evaluation/aabb-evaluation.cpp | 192 +++----- src/CMakeLists.txt | 1 - src/Shiny/CMakeLists.txt | 25 - src/Shiny/Shiny.h | 36 -- src/Shiny/ShinyConfig.h | 61 --- src/Shiny/ShinyData.h | 102 ---- src/Shiny/ShinyMacros.h | 281 ----------- src/Shiny/ShinyManager.c | 445 ------------------ src/Shiny/ShinyManager.h | 263 ----------- src/Shiny/ShinyNode.c | 129 ----- src/Shiny/ShinyNode.h | 133 ------ src/Shiny/ShinyNodePool.c | 77 --- src/Shiny/ShinyNodePool.h | 67 --- src/Shiny/ShinyNodeState.c | 108 ----- src/Shiny/ShinyNodeState.h | 56 --- src/Shiny/ShinyOutput.c | 189 -------- src/Shiny/ShinyOutput.h | 68 --- src/Shiny/ShinyPrereqs.h | 138 ------ src/Shiny/ShinyTools.c | 116 ----- src/Shiny/ShinyTools.h | 57 --- src/Shiny/ShinyVersion.h | 37 -- src/Shiny/ShinyZone.c | 201 -------- src/Shiny/ShinyZone.h | 91 ---- src/clipper/CMakeLists.txt | 4 - src/clipper/clipper.cpp | 33 -- src/libslic3r/CMakeLists.txt | 4 - src/libslic3r/ClipperUtils.cpp | 11 - src/libslic3r/GCode.cpp | 10 - src/libslic3r/GCodeReader.cpp | 9 +- src/libslic3r/PrintObject.cpp | 139 +++--- src/libslic3r/Thread.cpp | 2 +- src/libslic3r/pchheader.hpp | 2 - src/libslic3r/utils.cpp | 2 +- src/slic3r/CMakeLists.txt | 1 - src/slic3r/GUI/AboutDialog.cpp | 1 - src/slic3r/Utils/Profile.hpp | 19 - 38 files changed, 142 insertions(+), 2989 deletions(-) delete mode 100644 src/Shiny/CMakeLists.txt delete mode 100644 src/Shiny/Shiny.h delete mode 100644 src/Shiny/ShinyConfig.h delete mode 100644 src/Shiny/ShinyData.h delete mode 100644 src/Shiny/ShinyMacros.h delete mode 100644 src/Shiny/ShinyManager.c delete mode 100644 src/Shiny/ShinyManager.h delete mode 100644 src/Shiny/ShinyNode.c delete mode 100644 src/Shiny/ShinyNode.h delete mode 100644 src/Shiny/ShinyNodePool.c delete mode 100644 src/Shiny/ShinyNodePool.h delete mode 100644 src/Shiny/ShinyNodeState.c delete mode 100644 src/Shiny/ShinyNodeState.h delete mode 100644 src/Shiny/ShinyOutput.c delete mode 100644 src/Shiny/ShinyOutput.h delete mode 100644 src/Shiny/ShinyPrereqs.h delete mode 100644 src/Shiny/ShinyTools.c delete mode 100644 src/Shiny/ShinyTools.h delete mode 100644 src/Shiny/ShinyVersion.h delete mode 100644 src/Shiny/ShinyZone.c delete mode 100644 src/Shiny/ShinyZone.h delete mode 100644 src/slic3r/Utils/Profile.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e1aef5e1..70b7ed567 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,6 @@ option(SLIC3R_STATIC "Compile PrusaSlicer with static libraries (Boost, TBB, option(SLIC3R_GUI "Compile PrusaSlicer with GUI components (OpenGL, wxWidgets)" 1) option(SLIC3R_FHS "Assume PrusaSlicer is to be installed in a FHS directory structure" 0) option(SLIC3R_WX_STABLE "Build against wxWidgets stable (3.0) as oppsed to dev (3.1) on Linux" 0) -option(SLIC3R_PROFILE "Compile PrusaSlicer with an invasive Shiny profiler" 0) option(SLIC3R_PCH "Use precompiled headers" 1) option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1) option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 1) @@ -328,25 +327,6 @@ add_definitions(-DwxUSE_UNICODE -D_UNICODE -DUNICODE -DWXINTL_NO_GETTEXT_MACRO) # Disable unsafe implicit wxString to const char* / std::string and vice versa. This implicit conversion breaks the UTF-8 encoding quite often. add_definitions(-DwxNO_UNSAFE_WXSTRING_CONV) -if (SLIC3R_PROFILE) - message("PrusaSlicer will be built with a Shiny invasive profiler") - add_definitions(-DSLIC3R_PROFILE) -endif () - -# Disable optimization even with debugging on. -if (0) - message(STATUS "Perl compiled without optimization. Disabling optimization for the PrusaSlicer build.") - message("Old CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") - message("Old CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELEASE}") - message("Old CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS_RELEASE}") - set(CMAKE_CXX_FLAGS_RELEASE "/MD /Od /Zi /EHsc /DWIN32 /DTBB_USE_ASSERT") - set(CMAKE_C_FLAGS_RELEASE "/MD /Od /Zi /DWIN32 /DTBB_USE_ASSERT") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Od /Zi /EHsc /DWIN32 /DTBB_USE_ASSERT") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "/MD /Od /Zi /DWIN32 /DTBB_USE_ASSERT") - set(CMAKE_CXX_FLAGS "/MD /Od /Zi /EHsc /DWIN32 /DTBB_USE_ASSERT") - set(CMAKE_C_FLAGS "/MD /Od /Zi /DWIN32 /DTBB_USE_ASSERT") -endif() - # Find and configure boost if(SLIC3R_STATIC) # Use static boost libraries. diff --git a/doc/Dependencies.md b/doc/Dependencies.md index f37f45466..d8ced6318 100644 --- a/doc/Dependencies.md +++ b/doc/Dependencies.md @@ -24,7 +24,6 @@ * miniz: No packages, author suggests using in the source tree * qhull: libqhull-dev does not contain libqhullcpp => link errors. Until it is fixed, we will use the builtin version. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=925540 * semver: One module C library, author expects to use clib for installation. No packages. -* Shiny: no packages ## Header only * igl diff --git a/sandboxes/aabb-evaluation/aabb-evaluation.cpp b/sandboxes/aabb-evaluation/aabb-evaluation.cpp index 1019ecf28..c11af70e4 100644 --- a/sandboxes/aabb-evaluation/aabb-evaluation.cpp +++ b/sandboxes/aabb-evaluation/aabb-evaluation.cpp @@ -6,8 +6,6 @@ #include #include -#include - #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4244) @@ -42,53 +40,42 @@ void profile(const TriangleMesh &mesh) Eigen::MatrixXd occlusion_output0; { - AABBTreeIndirect::Tree3f tree; - { - PROFILE_BLOCK(AABBIndirect_Init); - tree = AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(mesh.its.vertices, mesh.its.indices); - } - { - PROFILE_BLOCK(EigenMesh3D_AABBIndirectF_AmbientOcclusion); - occlusion_output0.resize(num_vertices, 1); - for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) { - const Eigen::Vector3d origin = mesh.its.vertices[ivertex].template cast(); - const Eigen::Vector3d normal = vertex_normals.row(ivertex).template cast(); - int num_hits = 0; - for (int s = 0; s < num_samples; s++) { - Eigen::Vector3d d = dirs.row(s); - if(d.dot(normal) < 0) { - // reverse ray - d *= -1; - } - igl::Hit hit; - if (AABBTreeIndirect::intersect_ray_first_hit(mesh.its.vertices, mesh.its.indices, tree, (origin + 1e-4 * d).eval(), d, hit)) - ++ num_hits; + AABBTreeIndirect::Tree3f tree = AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(mesh.its.vertices, mesh.its.indices); + occlusion_output0.resize(num_vertices, 1); + for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) { + const Eigen::Vector3d origin = mesh.its.vertices[ivertex].template cast(); + const Eigen::Vector3d normal = vertex_normals.row(ivertex).template cast(); + int num_hits = 0; + for (int s = 0; s < num_samples; s++) { + Eigen::Vector3d d = dirs.row(s); + if(d.dot(normal) < 0) { + // reverse ray + d *= -1; } - occlusion_output0(ivertex) = (double)num_hits/(double)num_samples; + igl::Hit hit; + if (AABBTreeIndirect::intersect_ray_first_hit(mesh.its.vertices, mesh.its.indices, tree, (origin + 1e-4 * d).eval(), d, hit)) + ++ num_hits; } + occlusion_output0(ivertex) = (double)num_hits/(double)num_samples; } - - { - PROFILE_BLOCK(EigenMesh3D_AABBIndirectFF_AmbientOcclusion); - occlusion_output0.resize(num_vertices, 1); - for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) { - const Eigen::Vector3d origin = mesh.its.vertices[ivertex].template cast(); - const Eigen::Vector3d normal = vertex_normals.row(ivertex).template cast(); - int num_hits = 0; - for (int s = 0; s < num_samples; s++) { - Eigen::Vector3d d = dirs.row(s); - if(d.dot(normal) < 0) { - // reverse ray - d *= -1; - } - igl::Hit hit; - if (AABBTreeIndirect::intersect_ray_first_hit(mesh.its.vertices, mesh.its.indices, tree, - Eigen::Vector3f((origin + 1e-4 * d).template cast()), - Eigen::Vector3f(d.template cast()), hit)) - ++ num_hits; + occlusion_output0.resize(num_vertices, 1); + for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) { + const Eigen::Vector3d origin = mesh.its.vertices[ivertex].template cast(); + const Eigen::Vector3d normal = vertex_normals.row(ivertex).template cast(); + int num_hits = 0; + for (int s = 0; s < num_samples; s++) { + Eigen::Vector3d d = dirs.row(s); + if(d.dot(normal) < 0) { + // reverse ray + d *= -1; } - occlusion_output0(ivertex) = (double)num_hits/(double)num_samples; + igl::Hit hit; + if (AABBTreeIndirect::intersect_ray_first_hit(mesh.its.vertices, mesh.its.indices, tree, + Eigen::Vector3f((origin + 1e-4 * d).template cast()), + Eigen::Vector3f(d.template cast()), hit)) + ++ num_hits; } + occlusion_output0(ivertex) = (double)num_hits/(double)num_samples; } } @@ -100,31 +87,23 @@ void profile(const TriangleMesh &mesh) vertices.emplace_back(V.row(i).transpose()); for (int i = 0; i < F.rows(); ++ i) triangles.emplace_back(F.row(i).transpose()); - AABBTreeIndirect::Tree3d tree; - { - PROFILE_BLOCK(AABBIndirectD_Init); - tree = AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(vertices, triangles); - } - - { - PROFILE_BLOCK(EigenMesh3D_AABBIndirectD_AmbientOcclusion); - occlusion_output1.resize(num_vertices, 1); - for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) { - const Eigen::Vector3d origin = V.row(ivertex).template cast(); - const Eigen::Vector3d normal = vertex_normals.row(ivertex).template cast(); - int num_hits = 0; - for (int s = 0; s < num_samples; s++) { - Eigen::Vector3d d = dirs.row(s); - if(d.dot(normal) < 0) { - // reverse ray - d *= -1; - } - igl::Hit hit; - if (AABBTreeIndirect::intersect_ray_first_hit(vertices, triangles, tree, Eigen::Vector3d(origin + 1e-4 * d), d, hit)) - ++ num_hits; + AABBTreeIndirect::Tree3d tree = AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(vertices, triangles); + occlusion_output1.resize(num_vertices, 1); + for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) { + const Eigen::Vector3d origin = V.row(ivertex).template cast(); + const Eigen::Vector3d normal = vertex_normals.row(ivertex).template cast(); + int num_hits = 0; + for (int s = 0; s < num_samples; s++) { + Eigen::Vector3d d = dirs.row(s); + if(d.dot(normal) < 0) { + // reverse ray + d *= -1; } - occlusion_output1(ivertex) = (double)num_hits/(double)num_samples; + igl::Hit hit; + if (AABBTreeIndirect::intersect_ray_first_hit(vertices, triangles, tree, Eigen::Vector3d(origin + 1e-4 * d), d, hit)) + ++ num_hits; } + occlusion_output1(ivertex) = (double)num_hits/(double)num_samples; } } @@ -133,29 +112,23 @@ void profile(const TriangleMesh &mesh) Eigen::MatrixXd occlusion_output2; { igl::AABB AABB; - { - PROFILE_BLOCK(EigenMesh3D_AABB_Init); - AABB.init(V, F); - } - { - PROFILE_BLOCK(EigenMesh3D_AABB_AmbientOcclusion); - occlusion_output2.resize(num_vertices, 1); - for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) { - const Eigen::Vector3d origin = V.row(ivertex).template cast(); - const Eigen::Vector3d normal = vertex_normals.row(ivertex).template cast(); - int num_hits = 0; - for (int s = 0; s < num_samples; s++) { - Eigen::Vector3d d = dirs.row(s); - if(d.dot(normal) < 0) { - // reverse ray - d *= -1; - } - igl::Hit hit; - if (AABB.intersect_ray(V, F, origin + 1e-4 * d, d, hit)) - ++ num_hits; + AABB.init(V, F); + occlusion_output2.resize(num_vertices, 1); + for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) { + const Eigen::Vector3d origin = V.row(ivertex).template cast(); + const Eigen::Vector3d normal = vertex_normals.row(ivertex).template cast(); + int num_hits = 0; + for (int s = 0; s < num_samples; s++) { + Eigen::Vector3d d = dirs.row(s); + if(d.dot(normal) < 0) { + // reverse ray + d *= -1; } - occlusion_output2(ivertex) = (double)num_hits/(double)num_samples; + igl::Hit hit; + if (AABB.intersect_ray(V, F, origin + 1e-4 * d, d, hit)) + ++ num_hits; } + occlusion_output2(ivertex) = (double)num_hits/(double)num_samples; } } @@ -166,37 +139,28 @@ void profile(const TriangleMesh &mesh) igl::AABB AABB; auto vertices = MapMatrixXfUnaligned(mesh.its.vertices.front().data(), mesh.its.vertices.size(), 3); auto faces = MapMatrixXiUnaligned(mesh.its.indices.front().data(), mesh.its.indices.size(), 3); - { - PROFILE_BLOCK(EigenMesh3D_AABBf_Init); - AABB.init( - vertices, - faces); - } + AABB.init( + vertices, + faces); - { - PROFILE_BLOCK(EigenMesh3D_AABBf_AmbientOcclusion); - occlusion_output3.resize(num_vertices, 1); - for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) { - const Eigen::Vector3d origin = mesh.its.vertices[ivertex].template cast(); - const Eigen::Vector3d normal = vertex_normals.row(ivertex).template cast(); - int num_hits = 0; - for (int s = 0; s < num_samples; s++) { - Eigen::Vector3d d = dirs.row(s); - if(d.dot(normal) < 0) { - // reverse ray - d *= -1; - } - igl::Hit hit; - if (AABB.intersect_ray(vertices, faces, (origin + 1e-4 * d).eval().template cast(), d.template cast(), hit)) - ++ num_hits; + occlusion_output3.resize(num_vertices, 1); + for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) { + const Eigen::Vector3d origin = mesh.its.vertices[ivertex].template cast(); + const Eigen::Vector3d normal = vertex_normals.row(ivertex).template cast(); + int num_hits = 0; + for (int s = 0; s < num_samples; s++) { + Eigen::Vector3d d = dirs.row(s); + if(d.dot(normal) < 0) { + // reverse ray + d *= -1; } - occlusion_output3(ivertex) = (double)num_hits/(double)num_samples; + igl::Hit hit; + if (AABB.intersect_ray(vertices, faces, (origin + 1e-4 * d).eval().template cast(), d.template cast(), hit)) + ++ num_hits; } + occlusion_output3(ivertex) = (double)num_hits/(double)num_samples; } } - - PROFILE_UPDATE(); - PROFILE_OUTPUT(nullptr); } int main(const int argc, const char *argv[]) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 131a69b5a..c8b54ba80 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,7 +9,6 @@ add_subdirectory(boost) add_subdirectory(clipper) add_subdirectory(miniz) add_subdirectory(glu-libtess) -add_subdirectory(Shiny) add_subdirectory(semver) add_subdirectory(libigl) add_subdirectory(hints) diff --git a/src/Shiny/CMakeLists.txt b/src/Shiny/CMakeLists.txt deleted file mode 100644 index abdb96a72..000000000 --- a/src/Shiny/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(Shiny) - -add_library(Shiny STATIC - Shiny.h - ShinyConfig.h - ShinyData.h - ShinyMacros.h - ShinyManager.c - ShinyManager.h - ShinyNode.c - ShinyNode.h - ShinyNodePool.c - ShinyNodePool.h - ShinyNodeState.c - ShinyNodeState.h - ShinyOutput.c - ShinyOutput.h - ShinyPrereqs.h - ShinyTools.c - ShinyTools.h - ShinyVersion.h - ShinyZone.c - ShinyZone.h -) diff --git a/src/Shiny/Shiny.h b/src/Shiny/Shiny.h deleted file mode 100644 index a2905aef0..000000000 --- a/src/Shiny/Shiny.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_H -#define SHINY_H - -/*---------------------------------------------------------------------------*/ - -#include "ShinyMacros.h" - -#ifdef SLIC3R_PROFILE -#include "ShinyManager.h" -#endif /* SLIC3R_PROFILE */ - -#endif /* SHINY_H */ diff --git a/src/Shiny/ShinyConfig.h b/src/Shiny/ShinyConfig.h deleted file mode 100644 index 54c632151..000000000 --- a/src/Shiny/ShinyConfig.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_CONFIG_H -#define SHINY_CONFIG_H - - -/*---------------------------------------------------------------------------*/ - -/* if SHINY_LOOKUP_RATE is defined to TRUE then Shiny will record the success of its hash function. This is useful for debugging. Default is FALSE. - */ -#ifndef SHINY_LOOKUP_RATE -// #define SHINY_LOOKUP_RATE FALSE -#endif - -/* if SHINY_HAS_ENABLED is defined to TRUE then Shiny can be enabled and disabled at runtime. TODO: bla bla... - */ -#ifndef SHINY_HAS_ENABLED -// #define SHINY_HAS_ENABLED FALSE -#endif - -/* TODO: - */ -#define SHINY_OUTPUT_MODE_FLAT 0x1 - -/* TODO: - */ -#define SHINY_OUTPUT_MODE_TREE 0x2 - -/* TODO: - */ -#define SHINY_OUTPUT_MODE_BOTH 0x3 - -/* TODO: - */ -#ifndef SHINY_OUTPUT_MODE -#define SHINY_OUTPUT_MODE SHINY_OUTPUT_MODE_BOTH -#endif - -#endif /* SHINY_CONFIG_H */ diff --git a/src/Shiny/ShinyData.h b/src/Shiny/ShinyData.h deleted file mode 100644 index d75d4f5bf..000000000 --- a/src/Shiny/ShinyData.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_DATA_H -#define SHINY_DATA_H - -#include "ShinyPrereqs.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*---------------------------------------------------------------------------*/ - -typedef struct { - uint32_t entryCount; - shinytick_t selfTicks; -} ShinyLastData; - - -/*---------------------------------------------------------------------------*/ - -typedef struct { - shinytick_t cur; - float avg; -} ShinyTickData; - -typedef struct { - uint32_t cur; - float avg; -} ShinyCountData; - -typedef struct { - ShinyCountData entryCount; - ShinyTickData selfTicks; - ShinyTickData childTicks; -} ShinyData; - -SHINY_INLINE shinytick_t ShinyData_totalTicksCur(const ShinyData *self) { - return self->selfTicks.cur + self->childTicks.cur; -} - -SHINY_INLINE float ShinyData_totalTicksAvg(const ShinyData *self) { - return self->selfTicks.avg + self->childTicks.avg; -} - -SHINY_INLINE void ShinyData_computeAverage(ShinyData *self, float a_damping) { - self->entryCount.avg = self->entryCount.cur + - a_damping * (self->entryCount.avg - self->entryCount.cur); - self->selfTicks.avg = self->selfTicks.cur + - a_damping * (self->selfTicks.avg - self->selfTicks.cur); - self->childTicks.avg = self->childTicks.cur + - a_damping * (self->childTicks.avg - self->childTicks.cur); -} - -SHINY_INLINE void ShinyData_copyAverage(ShinyData *self) { - self->entryCount.avg = (float) self->entryCount.cur; - self->selfTicks.avg = (float) self->selfTicks.cur; - self->childTicks.avg = (float) self->childTicks.cur; -} - -SHINY_INLINE void ShinyData_clearAll(ShinyData *self) { - self->entryCount.cur = 0; - self->entryCount.avg = 0; - self->selfTicks.cur = 0; - self->selfTicks.avg = 0; - self->childTicks.cur = 0; - self->childTicks.avg = 0; -} - -SHINY_INLINE void ShinyData_clearCurrent(ShinyData *self) { - self->entryCount.cur = 0; - self->selfTicks.cur = 0; - self->childTicks.cur = 0; -} - -#if __cplusplus -} /* end of extern "C" */ -#endif - -#endif /* SHINY_DATA_H */ diff --git a/src/Shiny/ShinyMacros.h b/src/Shiny/ShinyMacros.h deleted file mode 100644 index 79dfa4381..000000000 --- a/src/Shiny/ShinyMacros.h +++ /dev/null @@ -1,281 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_MACROS_H -#define SHINY_MACROS_H - -#ifdef SLIC3R_PROFILE - -#include "ShinyManager.h" - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#define PROFILE_UPDATE() \ - ShinyManager_update(&Shiny_instance) - -#define PROFILE_SET_DAMPING(floatfrom0to1) \ - Shiny_instance.damping = (floatfrom0to1); - -#define PROFILE_GET_DAMPING() \ - (Shiny_instance.damping) - -#define PROFILE_OUTPUT(filename) \ - ShinyManager_output(&Shiny_instance, (filename)) - -#define PROFILE_OUTPUT_STREAM(stream) \ - ShinyManager_outputToStream(&Shiny_instance, (stream)) - -#ifdef __cplusplus -#define PROFILE_GET_TREE_STRING() \ - ShinyManager_outputTreeToString(&Shiny_instance) - -#define PROFILE_GET_FLAT_STRING() \ - ShinyManager_outputFlatToString(&Shiny_instance) -#endif /* __cplusplus */ - -#define PROFILE_DESTROY() \ - ShinyManager_destroy(&Shiny_instance) - -#define PROFILE_CLEAR() \ - ShinyManager_clear(&Shiny_instance) - -#define PROFILE_SORT_ZONES() \ - ShinyManager_sortZones(&Shiny_instance) - - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#define PROFILE_GET_TOTAL_TICKS_CUR() \ - ShinyData_totalTicksCur(&Shiny_instance.rootZone.data) - -#define PROFILE_GET_TOTAL_TICKS() \ - ShinyData_totalTicksAvg(&Shiny_instance.rootZone.data) - -#define PROFILE_GET_PROFILED_TICKS_CUR() \ - (Shiny_instance.rootZone.data.selfTicks.cur) - -#define PROFILE_GET_PROFILED_TICKS() \ - (Shiny_instance.rootZone.data.selfTicks.avg) - -#define PROFILE_GET_UNPROFILED_TICKS_CUR() \ - (Shiny_instance.rootZone.data.childTicks.cur) - -#define PROFILE_GET_UNPROFILED_TICKS() \ - (Shiny_instance.rootZone.data.childTicks.avg) - -#define PROFILE_GET_SHARED_TOTAL_TICKS_CUR(name) \ - ShinyData_totalTicksCur(&(_PROFILE_ID_ZONE_SHARED(name).data)) - -#define PROFILE_GET_SHARED_TOTAL_TICKS(name) \ - ShinyData_totalTicksAvg(&(_PROFILE_ID_ZONE_SHARED(name).data)) - -#define PROFILE_GET_SHARED_SELF_TICKS_CUR(name) \ - (_PROFILE_ID_ZONE_SHARED(name).data.selfTicks.cur) - -#define PROFILE_GET_SHARED_SELF_TICKS(name) \ - (_PROFILE_ID_ZONE_SHARED(name).data.selfTicks.avg) - - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#define PROFILE_IS_SHARED_SELF_BELOW(name, floatfrom0to1) \ - ShinyManager_isZoneSelfTimeBelow( \ - &Shiny_instance, _PROFILE_ID_ZONE_SHARED(name), floatfrom0to1) - -#define PROFILE_IS_SHARED_TOTAL_BELOW(name, floatfrom0to1) \ - ShinyManager_isZoneTotalTimeBelow( \ - &Shiny_instance, _PROFILE_ID_ZONE_SHARED(name), floatfrom0to1) - - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#define PROFILE_END() \ - ShinyManager_endCurNode(&Shiny_instance) - - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#define PROFILE_BEGIN( name ) \ - \ - static _PROFILE_ZONE_DEFINE(_PROFILE_ID_ZONE(name), #name); \ - _PROFILE_ZONE_BEGIN(_PROFILE_ID_ZONE(name)) - - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#ifdef __cplusplus -#define PROFILE_BLOCK( name ) \ - \ - _PROFILE_BLOCK_DEFINE(_PROFILE_ID_BLOCK()); \ - PROFILE_BEGIN(name) -#endif /* __cplusplus */ - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#ifdef __cplusplus -#define PROFILE_FUNC() \ - \ - _PROFILE_BLOCK_DEFINE(_PROFILE_ID_BLOCK()); \ - static _PROFILE_ZONE_DEFINE(_PROFILE_ID_ZONE_FUNC(), __FUNCTION__); \ - _PROFILE_ZONE_BEGIN(_PROFILE_ID_ZONE_FUNC()) -#endif /* __cplusplus */ - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#define PROFILE_CODE( code ) \ - \ - do { \ - static _PROFILE_ZONE_DEFINE(_PROFILE_ID_ZONE_CODE(), #code); \ - _PROFILE_ZONE_BEGIN(_PROFILE_ID_ZONE_CODE()); \ - { code; } \ - PROFILE_END(); \ - } while(0) - - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#define PROFILE_SHARED_EXTERN( name ) \ - \ - _PROFILE_ZONE_DECLARE(extern, _PROFILE_ID_ZONE_SHARED(name)) - - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#define PROFILE_SHARED_DEFINE( name ) \ - \ - _PROFILE_ZONE_DEFINE(_PROFILE_ID_ZONE_SHARED(name), #name) - - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#define PROFILE_SHARED_BEGIN( name ) \ - \ - _PROFILE_ZONE_BEGIN(_PROFILE_ID_ZONE_SHARED(name)) - - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#ifdef __cplusplus -#define PROFILE_SHARED_BLOCK( name ) \ - \ - _PROFILE_BLOCK_DEFINE(_PROFILE_ID_BLOCK()); \ - _PROFILE_ZONE_BEGIN(_PROFILE_ID_ZONE_SHARED(name)) -#endif /* __cplusplus */ - - -/*---------------------------------------------------------------------------*/ -/* public preprocessors */ - -#ifdef SHINY_HAS_ENABLED -#define PROFILE_SET_ENABLED( boolean ) \ - Shiny_instance.enabled = boolean -#endif - - -/*---------------------------------------------------------------------------*/ -/* internal preprocessors */ - -#define _PROFILE_ID_ZONE( name ) __ShinyZone_##name -#define _PROFILE_ID_ZONE_FUNC() __ShinyZoneFunc -#define _PROFILE_ID_ZONE_CODE() __ShinyZoneCode -#define _PROFILE_ID_ZONE_SHARED( name ) name##__ShinyZoneShared -#define _PROFILE_ID_BLOCK() __ShinyBlock - - -/*---------------------------------------------------------------------------*/ -/* internal preprocessor */ - -#define _PROFILE_ZONE_DEFINE( id, string ) \ - \ - ShinyZone id = { \ - NULL, SHINY_ZONE_STATE_HIDDEN, string, \ - { { 0, 0 }, { 0, 0 }, { 0, 0 } } \ - } - - -/*---------------------------------------------------------------------------*/ -/* internal preprocessor */ - -#define _PROFILE_ZONE_DECLARE( prefix, id ) \ - \ - prefix ShinyZone id - - -/*---------------------------------------------------------------------------*/ -/* internal preprocessor */ - -#define _PROFILE_BLOCK_DEFINE( id ) \ - \ - ShinyEndNodeOnDestruction SHINY_UNUSED id - - -/*---------------------------------------------------------------------------*/ -/* internal preprocessor */ - -#define _PROFILE_ZONE_BEGIN( id ) \ - \ - do { \ - static ShinyNodeCache cache = &_ShinyNode_dummy; \ - ShinyManager_lookupAndBeginNode(&Shiny_instance, &cache, &id); \ - } while(0) - -/*---------------------------------------------------------------------------*/ - -#else /* SLIC3R_PROFILE */ - -#define PROFILE_UPDATE() -#define PROFILE_SET_DAMPING(x) -#define PROFILE_GET_DAMPING() 0.0f -#define PROFILE_OUTPUT(x) -#define PROFILE_OUTPUT_STREAM(x) -#define PROFILE_CLEAR() -#define PROFILE_GET_TREE_STRING() std::string() -#define PROFILE_GET_FLAT_STRING() std::string() -#define PROFILE_DESTROY() -#define PROFILE_BEGIN(name) -#define PROFILE_BLOCK(name) -#define PROFILE_FUNC() -#define PROFILE_CODE(code) do { code; } while (0) -#define PROFILE_SHARED_GLOBAL(name) -#define PROFILE_SHARED_MEMBER(name) -#define PROFILE_SHARED_DEFINE(name) -#define PROFILE_SHARED_BEGIN(name) -#define PROFILE_SHARED_BLOCK(name) -#define PROFILE_SET_ENABLED(boolean) - -#endif /* SLIC3R_PROFILE */ - -#endif /* SHINY_MACROS_H */ diff --git a/src/Shiny/ShinyManager.c b/src/Shiny/ShinyManager.c deleted file mode 100644 index 6b2811851..000000000 --- a/src/Shiny/ShinyManager.c +++ /dev/null @@ -1,445 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifdef SLIC3R_PROFILE - -#include "ShinyManager.h" - -#include -#include -#include -#include - -/*---------------------------------------------------------------------------*/ - -#define TABLE_SIZE_INIT 256 - -/*---------------------------------------------------------------------------*/ - -ShinyManager Shiny_instance = { -#if SHINY_HAS_ENABLED == TRUE - /* enabled = */ false, -#endif - /* _lastTick = */ 0, - /* _curNode = */ &Shiny_instance.rootNode, - /* _tableMask = */ 0, - /* _nodeTable = */ _ShinyManager_dummyNodeTable, -#if SHINY_LOOKUP_RATE == TRUE - /* _lookupCount = */ 0, - /* _lookupSuccessCount = */ 0, -#endif - /* _tableSize = */ 1, - /* nodeCount = */ 1, - /* zoneCount = */ 1, - /* _lastZone = */ &Shiny_instance.rootZone, - /* _lastNodePool = */ NULL, - /* _firstNodePool = */ NULL, - /* rootNode = */ { - /* _last = */ { 0, 0 }, - /* zone = */ &Shiny_instance.rootZone, - /* parent = */ &Shiny_instance.rootNode, - /* nextSibling = */ NULL, - /* firstChild = */ NULL, - /* lastChild = */ NULL, - /* childCount = */ 0, - /* entryLevel = */ 0, - /* _cache = */ NULL, - /* data = */ { { 0, 0 }, { 0, 0 }, { 0, 0 } } - }, - /* rootZone = */ { - /* next = */ NULL, - /* _state = */ SHINY_ZONE_STATE_HIDDEN, - /* name = */ "", - /* data = */ { { 0, 0 }, { 0, 0 }, { 0, 0 } } - }, - /* damping = */ 0.f, // Damping disabled, every PROFILE_UPDATE will be performed from scratch. Original value: 0.9f - /* _initialized = */ FALSE, - /* _firstUpdate = */ TRUE -}; - -ShinyNode* _ShinyManager_dummyNodeTable[] = { NULL }; - - -/*---------------------------------------------------------------------------*/ - -#if SHINY_COMPILER == SHINY_COMPILER_MSVC -# pragma warning (push) -# pragma warning (disable: 4311) -#endif - -/* primary hash function */ -SHINY_INLINE uint32_t hash_value(void* a_pParent, void* a_pZone) { - uint32_t a = (uint32_t) a_pParent + (uint32_t) a_pZone; -// uint32_t a = *reinterpret_cast(&a_pParent) + *reinterpret_cast(&a_pZone); - - a = (a+0x7ed55d16) + (a<<12); - a = (a^0xc761c23c) ^ (a>>19); - return a; -} - -/* - * secondary hash used as index offset: force it to be odd - * so it's relatively prime to the power-of-two table size - */ -SHINY_INLINE uint32_t hash_offset(uint32_t a) { - return ((a << 8) + (a >> 4)) | 1; -} - -#if SHINY_COMPILER == SHINY_COMPILER_MSVC -# pragma warning (pop) -#endif - - -/*---------------------------------------------------------------------------*/ - -void ShinyManager_preLoad(ShinyManager *self) { - if (!self->_initialized) { - _ShinyManager_init(self); - - _ShinyManager_createNodeTable(self, TABLE_SIZE_INIT); - _ShinyManager_createNodePool(self, TABLE_SIZE_INIT / 2); - } -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyManager_update(ShinyManager *self) { -#if SHINY_HAS_ENABLED == TRUE - if (!enabled) return; -#endif - - _ShinyManager_appendTicksToCurNode(self); - ShinyZone_preUpdateChain(&self->rootZone); - - if (self->_firstUpdate || self->damping == 0) { - self->_firstUpdate = FALSE; - ShinyNode_updateTreeClean(&self->rootNode); - ShinyZone_updateChainClean(&self->rootZone); - - } else { - ShinyNode_updateTree(&self->rootNode, self->damping); - ShinyZone_updateChain(&self->rootZone, self->damping); - } -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyManager_updateClean(ShinyManager *self) { -#if SHINY_HAS_ENABLED == TRUE - if (!enabled) return; -#endif - - _ShinyManager_appendTicksToCurNode(self); - ShinyZone_preUpdateChain(&self->rootZone); - - self->_firstUpdate = FALSE; - ShinyNode_updateTreeClean(&self->rootNode); - ShinyZone_updateChainClean(&self->rootZone); -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyManager_clear(ShinyManager *self) { - ShinyManager_destroy(self); - ShinyManager_preLoad(self); -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyManager_destroy(ShinyManager *self) { - ShinyManager_destroyNodes(self); - ShinyManager_resetZones(self); - _ShinyManager_uninit(self); -} - - -/*---------------------------------------------------------------------------*/ - -ShinyNode* _ShinyManager_lookupNode(ShinyManager *self, ShinyNodeCache *a_cache, ShinyZone *a_zone) { - uint32_t nHash = hash_value(self->_curNode, a_zone); - uint32_t nIndex = nHash & self->_tableMask; - ShinyNode* pNode = self->_nodeTable[nIndex]; - - _ShinyManager_incLookup(self); - _ShinyManager_incLookupSuccess(self); - - if (pNode) { - uint32_t nStep; - - if (ShinyNode_isEqual(pNode, self->_curNode, a_zone)) return pNode; /* found it! */ - - /* hash collision: */ - - /* compute a secondary hash function for stepping */ - nStep = hash_offset(nHash); - - for (;;) { - _ShinyManager_incLookup(self); - - nIndex = (nIndex + nStep) & self->_tableMask; - pNode = self->_nodeTable[nIndex]; - - if (!pNode) break; /* found empty slot */ - else if (ShinyNode_isEqual(pNode, self->_curNode, a_zone)) return pNode; /* found it! */ - } - - /* loop is guaranteed to end because the hash table is never full */ - } - - if (a_zone->_state == SHINY_ZONE_STATE_HIDDEN) { /* zone is not initialized */ - ShinyZone_init(a_zone, self->_lastZone); - - self->_lastZone = a_zone; - self->zoneCount++; - - if (self->_initialized == FALSE) { /* first time init */ - _ShinyManager_init(self); - - _ShinyManager_createNodeTable(self, TABLE_SIZE_INIT); - _ShinyManager_createNodePool(self, TABLE_SIZE_INIT / 2); - - /* initialization has invalidated nIndex - * we must compute nIndex again - */ - return _ShinyManager_createNode(self, a_cache, a_zone); - } - } - - /* Althouth nodeCount is not updated - * it includes rootNode so it adds up. - * - * check if we need to grow the table - * we keep it at most 1/2 full to be very fast - */ - if (self->_tableSize < 2 * self->nodeCount) { - - _ShinyManager_resizeNodeTable(self, 2 * self->_tableSize); - _ShinyManager_resizeNodePool(self, self->nodeCount - 1); - - /* resize has invalidated nIndex - * we must compute nIndex again - */ - return _ShinyManager_createNode(self, a_cache, a_zone); - } - - self->nodeCount++; - - { - ShinyNode* pNewNode = ShinyNodePool_newItem(self->_lastNodePool); - ShinyNode_init(pNewNode, self->_curNode, a_zone, a_cache); - - self->_nodeTable[nIndex] = pNewNode; - return pNewNode; - } -} - - -/*---------------------------------------------------------------------------*/ - -void _ShinyManager_insertNode(ShinyManager *self, ShinyNode* a_pNode) { - uint32_t nHash = hash_value(a_pNode->parent, a_pNode->zone); - uint32_t nIndex = nHash & self->_tableMask; - - if (self->_nodeTable[nIndex]) { - uint32_t nStep = hash_offset(nHash); - - while (self->_nodeTable[nIndex]) - nIndex = (nIndex + nStep) & self->_tableMask; - } - - self->_nodeTable[nIndex] = a_pNode; -} - - -/*---------------------------------------------------------------------------*/ - -ShinyNode* _ShinyManager_createNode(ShinyManager *self, ShinyNodeCache* a_cache, ShinyZone* a_pZone) { - ShinyNode* pNewNode = ShinyNodePool_newItem(self->_lastNodePool); - ShinyNode_init(pNewNode, self->_curNode, a_pZone, a_cache); - - self->nodeCount++; - _ShinyManager_insertNode(self, pNewNode); - return pNewNode; -} - - -/*---------------------------------------------------------------------------*/ - -void _ShinyManager_createNodePool(ShinyManager *self, uint32_t a_nCount) { - self->_firstNodePool = ShinyNodePool_create(a_nCount); - self->_lastNodePool = self->_firstNodePool; -} - - -/*---------------------------------------------------------------------------*/ - -void _ShinyManager_resizeNodePool(ShinyManager *self, uint32_t a_nCount) { - ShinyNodePool* pPool = ShinyNodePool_create(a_nCount); - self->_lastNodePool->nextPool = pPool; - self->_lastNodePool = pPool; -} - - -/*---------------------------------------------------------------------------*/ - -void _ShinyManager_createNodeTable(ShinyManager *self, uint32_t a_nCount) { - self->_tableSize = a_nCount; - self->_tableMask = a_nCount - 1; - - self->_nodeTable = (ShinyNodeTable*) - malloc(sizeof(ShinyNode) * a_nCount); - - memset(self->_nodeTable, 0, a_nCount * sizeof(ShinyNode*)); -} - - -/*---------------------------------------------------------------------------*/ - -void _ShinyManager_resizeNodeTable(ShinyManager *self, uint32_t a_nCount) { - ShinyNodePool* pPool; - - free(self->_nodeTable); - _ShinyManager_createNodeTable(self, a_nCount); - - pPool = self->_firstNodePool; - while (pPool) { - - ShinyNode *pIter = ShinyNodePool_firstItem(pPool); - - while (pIter != pPool->_nextItem) - _ShinyManager_insertNode(self, pIter++); - - pPool = pPool->nextPool; - } -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyManager_resetZones(ShinyManager *self) { - ShinyZone_resetChain(&self->rootZone); - self->_lastZone = &self->rootZone; - self->zoneCount = 1; -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyManager_destroyNodes(ShinyManager *self) { - if (self->_firstNodePool) { - ShinyNodePool_destroy(self->_firstNodePool); - self->_firstNodePool = NULL; - } - - if (self->_nodeTable != _ShinyManager_dummyNodeTable) { - free(self->_nodeTable); - - self->_nodeTable = _ShinyManager_dummyNodeTable; - self->_tableSize = 1; - self->_tableMask = 0; - } - - self->_curNode = &self->rootNode; - self->nodeCount = 1; - - _ShinyManager_init(self); -} - - -/*---------------------------------------------------------------------------*/ - -const char* ShinyManager_getOutputErrorString(ShinyManager *self) { - if (self->_firstUpdate) return "!!! Profile data must first be updated !!!"; - else if (!self->_initialized) return "!!! No profiles where executed !!!"; - else return NULL; -} - - -/*---------------------------------------------------------------------------*/ - -#if SHINY_COMPILER == SHINY_COMPILER_MSVC -# pragma warning (push) -# pragma warning (disable: 4996) -#endif - -int ShinyManager_output(ShinyManager *self, const char *a_filename) { - if (!a_filename) { - ShinyManager_outputToStream(self, stdout); - - } else { - FILE *file = fopen(a_filename, "w"); - if (!file) return FALSE; - ShinyManager_outputToStream(self, file); - fclose(file); - } - - return TRUE; -} - -#if SHINY_COMPILER == SHINY_COMPILER_MSVC -# pragma warning (pop) -#endif - - -/*---------------------------------------------------------------------------*/ - -void ShinyManager_outputToStream(ShinyManager *self, FILE *a_stream) { - const char *error = ShinyManager_getOutputErrorString(self); - - if (error) { - fwrite(error, 1, strlen(error), a_stream); - fwrite("\n\n", 1, 2, a_stream); - return; - } - -#if SHINY_OUTPUT_MODE & SHINY_OUTPUT_MODE_FLAT - ShinyManager_sortZones(self); - - { - int size = ShinyPrintZonesSize(self->zoneCount); - char *buffer = (char*) malloc(size); - ShinyPrintZones(buffer, &self->rootZone); - fwrite(buffer, 1, size - 1, a_stream); - fwrite("\n\n", 1, 2, a_stream); - free(buffer); - } -#endif - -#if SHINY_OUTPUT_MODE & SHINY_OUTPUT_MODE_TREE - { - int size = ShinyPrintNodesSize(self->nodeCount); - char *buffer = (char*) malloc(size); - ShinyPrintNodes(buffer, &self->rootNode); - fwrite(buffer, 1, size - 1, a_stream); - fwrite("\n\n", 1, 2, a_stream); - free(buffer); - } -#endif -} - -#endif /* SLIC3R_PROFILE */ diff --git a/src/Shiny/ShinyManager.h b/src/Shiny/ShinyManager.h deleted file mode 100644 index 403e0e878..000000000 --- a/src/Shiny/ShinyManager.h +++ /dev/null @@ -1,263 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_MANAGER_H -#define SHINY_MANAGER_H - -#include "ShinyZone.h" -#include "ShinyNode.h" -#include "ShinyNodePool.h" -#include "ShinyTools.h" -#include "ShinyOutput.h" - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/*---------------------------------------------------------------------------*/ - -typedef struct { -#ifdef SHINY_HAS_ENABLED - bool enabled; -#endif - - shinytick_t _lastTick; - - ShinyNode* _curNode; - - uint32_t _tableMask; /* = _tableSize - 1 */ - - ShinyNodeTable* _nodeTable; - -#ifdef SHINY_LOOKUP_RATE - uint64_t _lookupCount; - uint64_t _lookupSuccessCount; -#endif - - uint32_t _tableSize; - - uint32_t nodeCount; - uint32_t zoneCount; - - ShinyZone* _lastZone; - - ShinyNodePool* _lastNodePool; - ShinyNodePool* _firstNodePool; - - ShinyNode rootNode; - ShinyZone rootZone; - - float damping; - - int _initialized; - int _firstUpdate; -} ShinyManager; - - -/*---------------------------------------------------------------------------*/ - -extern ShinyNode* _ShinyManager_dummyNodeTable[]; - -extern ShinyManager Shiny_instance; - - -/*---------------------------------------------------------------------------*/ - -SHINY_INLINE void _ShinyManager_appendTicksToCurNode(ShinyManager *self) { - shinytick_t curTick; - ShinyGetTicks(&curTick); - - ShinyNode_appendTicks(self->_curNode, curTick - self->_lastTick); - self->_lastTick = curTick; -} - -SHINY_API ShinyNode* _ShinyManager_lookupNode(ShinyManager *self, ShinyNodeCache* a_cache, ShinyZone* a_zone); - -SHINY_API void _ShinyManager_createNodeTable(ShinyManager *self, uint32_t a_count); -SHINY_API void _ShinyManager_resizeNodeTable(ShinyManager *self, uint32_t a_count); - -SHINY_API void _ShinyManager_createNodePool(ShinyManager *self, uint32_t a_count); -SHINY_API void _ShinyManager_resizeNodePool(ShinyManager *self, uint32_t a_count); - -SHINY_API ShinyNode* _ShinyManager_createNode(ShinyManager *self, ShinyNodeCache* a_cache, ShinyZone* a_pZone); -SHINY_API void _ShinyManager_insertNode(ShinyManager *self, ShinyNode* a_pNode); - -SHINY_INLINE void _ShinyManager_init(ShinyManager *self) { - self->_initialized = TRUE; - - self->rootNode._last.entryCount = 1; - self->rootNode._last.selfTicks = 0; - ShinyGetTicks(&self->_lastTick); -} - -SHINY_INLINE void _ShinyManager_uninit(ShinyManager *self) { - self->_initialized = FALSE; - - ShinyNode_clear(&self->rootNode); - self->rootNode.parent = &self->rootNode; - self->rootNode.zone = &self->rootZone; -} - -#ifdef SHINY_LOOKUP_RATE -SHINY_INLINE void _ShinyManager_incLookup(ShinyManager *self) { self->_lookupCount++; } -SHINY_INLINE void _ShinyManager_incLookupSuccess(ShinyManager *self) { self->_lookupSuccessCount++; } -SHINY_INLINE float ShinyManager_lookupRate(const ShinyManager *self) { return ((float) self->_lookupSuccessCount) / ((float) self->_lookupCount); } - -#else -SHINY_INLINE void _ShinyManager_incLookup(ShinyManager * self) { self = self; } -SHINY_INLINE void _ShinyManager_incLookupSuccess(ShinyManager * self) { self = self; } -SHINY_INLINE float ShinyManager_lookupRate(const ShinyManager * self) { self = self; return -1; } -#endif - -SHINY_API void ShinyManager_resetZones(ShinyManager *self); -SHINY_API void ShinyManager_destroyNodes(ShinyManager *self); - -SHINY_INLINE float ShinyManager_tableUsage(const ShinyManager *self) { - return ((float) self->nodeCount) / ((float) self->_tableSize); -} - -SHINY_INLINE uint32_t ShinyManager_allocMemInBytes(const ShinyManager *self) { - return self->_tableSize * sizeof(ShinyNode*) - + (self->_firstNodePool)? ShinyNodePool_memoryUsageChain(self->_firstNodePool) : 0; -} - -SHINY_INLINE void ShinyManager_beginNode(ShinyManager *self, ShinyNode* a_node) { - ShinyNode_beginEntry(a_node); - - _ShinyManager_appendTicksToCurNode(self); - self->_curNode = a_node; -} - -SHINY_INLINE void ShinyManager_lookupAndBeginNode(ShinyManager *self, ShinyNodeCache* a_cache, ShinyZone* a_zone) { -#ifdef SHINY_HAS_ENABLED - if (!self->enabled) return; -#endif - - if (self->_curNode != (*a_cache)->parent) - *a_cache = _ShinyManager_lookupNode(self, a_cache, a_zone); - - ShinyManager_beginNode(self, *a_cache); -} - -SHINY_INLINE void ShinyManager_endCurNode(ShinyManager *self) { -#ifdef SHINY_HAS_ENABLED - if (!self->enabled) return; -#endif - - _ShinyManager_appendTicksToCurNode(self); - self->_curNode = self->_curNode->parent; -} - -/**/ - -SHINY_API void ShinyManager_preLoad(ShinyManager *self); - -SHINY_API void ShinyManager_updateClean(ShinyManager *self); -SHINY_API void ShinyManager_update(ShinyManager *self); - -SHINY_API void ShinyManager_clear(ShinyManager *self); -SHINY_API void ShinyManager_destroy(ShinyManager *self); - -SHINY_INLINE void ShinyManager_sortZones(ShinyManager *self) { - if (self->rootZone.next) - self->_lastZone = ShinyZone_sortChain(&self->rootZone.next); -} - -SHINY_API const char* ShinyManager_getOutputErrorString(ShinyManager *self); - -SHINY_API int ShinyManager_output(ShinyManager *self, const char *a_filename); -SHINY_API void ShinyManager_outputToStream(ShinyManager *self, FILE *stream); - -#if __cplusplus -} /* end of extern "C" */ - -SHINY_INLINE std::string ShinyManager_outputTreeToString(ShinyManager *self) { - const char* error = ShinyManager_getOutputErrorString(self); - if (error) return error; - else return ShinyNodesToString(&self->rootNode, self->nodeCount); -} - -SHINY_INLINE std::string ShinyManager_outputFlatToString(ShinyManager *self) { - const char* error = ShinyManager_getOutputErrorString(self); - if (error) return error; - - ShinyManager_sortZones(self); - return ShinyZonesToString(&self->rootZone, self->zoneCount); -} - -extern "C" { /* end of c++ */ -#endif - -SHINY_INLINE int ShinyManager_isZoneSelfTimeBelow(ShinyManager *self, ShinyZone* a_zone, float a_percentage) { - return a_percentage * (float) self->rootZone.data.childTicks.cur - <= (float) a_zone->data.selfTicks.cur; -} - -SHINY_INLINE int ShinyManager_isZoneTotalTimeBelow(ShinyManager *self, ShinyZone* a_zone, float a_percentage) { - return a_percentage * (float) self->rootZone.data.childTicks.cur - <= (float) ShinyData_totalTicksCur(&a_zone->data); -} - -/**/ - -SHINY_INLINE void ShinyManager_enumerateNodes(ShinyManager *self, void (*a_func)(const ShinyNode*)) { - ShinyNode_enumerateNodes(&self->rootNode, a_func); -} - -SHINY_INLINE void ShinyManager_enumerateZones(ShinyManager *self, void (*a_func)(const ShinyZone*)) { - ShinyZone_enumerateZones(&self->rootZone, a_func); -} - -#if __cplusplus -} /* end of extern "C" */ - -template void ShinyManager_enumerateNodes(ShinyManager *self, T* a_this, void (T::*a_func)(const ShinyNode*)) { - ShinyNode_enumerateNodes(&self->rootNode, a_this, a_func); -} - -template void ShinyManager_enumerateZones(ShinyManager *self, T* a_this, void (T::*a_func)(const ShinyZone*)) { - ShinyZone_enumerateZones(&self->rootZone, a_this, a_func); -} - -extern "C" { /* end of c++ */ -#endif - - -/*---------------------------------------------------------------------------*/ - -#if __cplusplus -} /* end of extern "C" */ - -class ShinyEndNodeOnDestruction { -public: - - SHINY_INLINE ~ShinyEndNodeOnDestruction() { - ShinyManager_endCurNode(&Shiny_instance); - } -}; -#endif - -#endif /* SHINY_MANAGER_H */ diff --git a/src/Shiny/ShinyNode.c b/src/Shiny/ShinyNode.c deleted file mode 100644 index 9d777073b..000000000 --- a/src/Shiny/ShinyNode.c +++ /dev/null @@ -1,129 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifdef SLIC3R_PROFILE - -#include "ShinyNode.h" -#include "ShinyZone.h" -#include "ShinyNodeState.h" - -#include - -/*---------------------------------------------------------------------------*/ - -ShinyNode _ShinyNode_dummy = { - /* _last = */ { 0, 0 }, - /* zone = */ NULL, - /* parent = */ NULL, - /* nextSibling = */ NULL, - /* firstChild = */ NULL, - /* lastChild = */ NULL -}; - - -/*---------------------------------------------------------------------------*/ - -void ShinyNode_updateTree(ShinyNode* first, float a_damping) { - ShinyNodeState *top = NULL; - ShinyNode *node = first; - - for (;;) { - do { - top = ShinyNodeState_push(top, node); - node = node->firstChild; - } while (node); - - for (;;) { - node = ShinyNodeState_finishAndGetNext(top, a_damping); - top = ShinyNodeState_pop(top); - - if (node) break; - else if (!top) return; - } - } -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyNode_updateTreeClean(ShinyNode* first) { - ShinyNodeState *top = NULL; - ShinyNode *node = first; - - for (;;) { - do { - top = ShinyNodeState_push(top, node); - node = node->firstChild; - } while (node); - - for (;;) { - node = ShinyNodeState_finishAndGetNextClean(top); - top = ShinyNodeState_pop(top); - - if (node) break; - else if (!top) return; - } - } -} - - -/*---------------------------------------------------------------------------*/ - -const ShinyNode* ShinyNode_findNextInTree(const ShinyNode* self) { - if (self->firstChild) { - return self->firstChild; - - } else if (self->nextSibling) { - return self->nextSibling; - - } else { - ShinyNode* pParent = self->parent; - - while (!ShinyNode_isRoot(pParent)) { - if (pParent->nextSibling) return pParent->nextSibling; - else pParent = pParent->parent; - } - - return NULL; - } -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyNode_clear(ShinyNode* self) { - memset(self, 0, sizeof(ShinyNode)); -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyNode_enumerateNodes(const ShinyNode* a_node, void (*a_func)(const ShinyNode*)) { - a_func(a_node); - - if (a_node->firstChild) ShinyNode_enumerateNodes(a_node->firstChild, a_func); - if (a_node->nextSibling) ShinyNode_enumerateNodes(a_node->nextSibling, a_func); -} - -#endif /* SLIC3R_PROFILE */ diff --git a/src/Shiny/ShinyNode.h b/src/Shiny/ShinyNode.h deleted file mode 100644 index ee5fdb0de..000000000 --- a/src/Shiny/ShinyNode.h +++ /dev/null @@ -1,133 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_NODE_H -#define SHINY_NODE_H - -#include "ShinyData.h" -#include "ShinyTools.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*---------------------------------------------------------------------------*/ - -typedef struct _ShinyNode { - - ShinyLastData _last; - - struct _ShinyZone* zone; - struct _ShinyNode* parent; - struct _ShinyNode* nextSibling; - - struct _ShinyNode* firstChild; - struct _ShinyNode* lastChild; - - uint32_t childCount; - uint32_t entryLevel; - - ShinyNodeCache* _cache; - - ShinyData data; - -} ShinyNode; - - -/*---------------------------------------------------------------------------*/ - -extern ShinyNode _ShinyNode_dummy; - - -/*---------------------------------------------------------------------------*/ - -SHINY_INLINE void ShinyNode_addChild(ShinyNode* self, ShinyNode* a_child) { - if (self->childCount++) { - self->lastChild->nextSibling = a_child; - self->lastChild = a_child; - - } else { - self->lastChild = a_child; - self->firstChild = a_child; - } -} - -SHINY_INLINE void ShinyNode_init(ShinyNode* self, ShinyNode* a_parent, struct _ShinyZone* a_zone, ShinyNodeCache* a_cache) { - /* NOTE: all member variables are assumed to be zero when allocated */ - - self->zone = a_zone; - self->parent = a_parent; - - self->entryLevel = a_parent->entryLevel + 1; - ShinyNode_addChild(a_parent, self); - - self->_cache = a_cache; -} - -SHINY_API void ShinyNode_updateTree(ShinyNode* self, float a_damping); -SHINY_API void ShinyNode_updateTreeClean(ShinyNode* self); - -SHINY_INLINE void ShinyNode_destroy(ShinyNode* self) { - *(self->_cache) = &_ShinyNode_dummy; -} - -SHINY_INLINE void ShinyNode_appendTicks(ShinyNode* self, shinytick_t a_elapsedTicks) { - self->_last.selfTicks += a_elapsedTicks; -} - -SHINY_INLINE void ShinyNode_beginEntry(ShinyNode* self) { - self->_last.entryCount++; -} - -SHINY_INLINE int ShinyNode_isRoot(ShinyNode* self) { - return (self->entryLevel == 0); -} - -SHINY_INLINE int ShinyNode_isDummy(ShinyNode* self) { - return (self == &_ShinyNode_dummy); -} - -SHINY_INLINE int ShinyNode_isEqual(ShinyNode* self, const ShinyNode* a_parent, const struct _ShinyZone* a_zone) { - return (self->parent == a_parent && self->zone == a_zone); -} - -SHINY_API const ShinyNode* ShinyNode_findNextInTree(const ShinyNode* self); - -SHINY_API void ShinyNode_clear(ShinyNode* self); - -SHINY_API void ShinyNode_enumerateNodes(const ShinyNode* a_node, void (*a_func)(const ShinyNode*)); - -#if __cplusplus -} /* end of extern "C" */ - -template -void ShinyNode_enumerateNodes(const ShinyNode* a_node, T* a_this, void (T::*a_func)(const ShinyNode*)) { - (a_this->*a_func)(a_node); - - if (a_node->firstChild) ShinyNode_enumerateNodes(a_node->firstChild, a_this, a_func); - if (a_node->nextSibling) ShinyNode_enumerateNodes(a_node->nextSibling, a_this, a_func); -} -#endif /* __cplusplus */ - -#endif /* SHINY_NODE_H */ diff --git a/src/Shiny/ShinyNodePool.c b/src/Shiny/ShinyNodePool.c deleted file mode 100644 index f00293252..000000000 --- a/src/Shiny/ShinyNodePool.c +++ /dev/null @@ -1,77 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifdef SLIC3R_PROFILE - -#include "ShinyNodePool.h" -#include "ShinyTools.h" - -#include -#include - -/*---------------------------------------------------------------------------*/ - -ShinyNodePool* ShinyNodePool_create(uint32_t a_items) { - ShinyNodePool* pPool = (ShinyNodePool*) - malloc(sizeof(ShinyNodePool) + sizeof(ShinyNode) * (a_items - 1)); - - pPool->nextPool = NULL; - pPool->_nextItem = &pPool->_items[0]; - pPool->endOfItems = &pPool->_items[a_items]; - - memset(&pPool->_items[0], 0, a_items * sizeof(ShinyNode)); - return pPool; -} - - -/*---------------------------------------------------------------------------*/ - -uint32_t ShinyNodePool_memoryUsageChain(ShinyNodePool *first) { - uint32_t bytes = (uint32_t) ((char*) first->endOfItems - (char*) first); - ShinyNodePool *pool = first->nextPool; - - while (pool) { - bytes += (uint32_t) ((char*) pool->endOfItems - (char*) pool); - pool = pool->nextPool; - } - - return bytes; -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyNodePool_destroy(ShinyNodePool *self) { - ShinyNode* firstNode = ShinyNodePool_firstItem(self); - ShinyNode* lastNode = self->_nextItem; - - while (firstNode != lastNode) - ShinyNode_destroy(firstNode++); - - /* TODO: make this into a loop or a tail recursion */ - if (self->nextPool) ShinyNodePool_destroy(self->nextPool); - free(self); -} - -#endif /* SLIC3R_PROFILE */ diff --git a/src/Shiny/ShinyNodePool.h b/src/Shiny/ShinyNodePool.h deleted file mode 100644 index 5e30a3306..000000000 --- a/src/Shiny/ShinyNodePool.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_NODE_POOL_H -#define SHINY_NODE_POOL_H - -#include "ShinyNode.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*---------------------------------------------------------------------------*/ - -typedef struct _ShinyNodePool { - - struct _ShinyNodePool* nextPool; - - ShinyNode *_nextItem; - ShinyNode *endOfItems; - - ShinyNode _items[1]; - -} ShinyNodePool; - - -/*---------------------------------------------------------------------------*/ - -SHINY_INLINE ShinyNode* ShinyNodePool_firstItem(ShinyNodePool *self) { - return &(self->_items[0]); -} - -SHINY_INLINE ShinyNode* ShinyNodePool_newItem(ShinyNodePool *self) { - return self->_nextItem++; -} - -ShinyNodePool* ShinyNodePool_create(uint32_t a_items); -void ShinyNodePool_destroy(ShinyNodePool *self); - -uint32_t ShinyNodePool_memoryUsageChain(ShinyNodePool *first); - -#if __cplusplus -} /* end of extern "C" */ -#endif - -#endif /* SHINY_NODE_POOL_H */ diff --git a/src/Shiny/ShinyNodeState.c b/src/Shiny/ShinyNodeState.c deleted file mode 100644 index fbf6dc870..000000000 --- a/src/Shiny/ShinyNodeState.c +++ /dev/null @@ -1,108 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifdef SLIC3R_PROFILE - -#include "ShinyNodeState.h" -#include "ShinyNode.h" -#include "ShinyZone.h" - -#include - -/*---------------------------------------------------------------------------*/ - -ShinyNodeState* ShinyNodeState_push(ShinyNodeState *a_top, ShinyNode *a_node) { - ShinyZone *zone = a_node->zone; - ShinyNodeState *self = (ShinyNodeState*) malloc(sizeof(ShinyNodeState)); - self->node = a_node; - self->_prev = a_top; - - a_node->data.selfTicks.cur = a_node->_last.selfTicks; - a_node->data.entryCount.cur = a_node->_last.entryCount; - - zone->data.selfTicks.cur += a_node->_last.selfTicks; - zone->data.entryCount.cur += a_node->_last.entryCount; - - a_node->data.childTicks.cur = 0; - a_node->_last.selfTicks = 0; - a_node->_last.entryCount = 0; - - self->zoneUpdating = zone->_state != SHINY_ZONE_STATE_UPDATING; - if (self->zoneUpdating) { - zone->_state = SHINY_ZONE_STATE_UPDATING; - } else { - zone->data.childTicks.cur -= a_node->data.selfTicks.cur; - } - - return self; -} - -/*---------------------------------------------------------------------------*/ - -ShinyNodeState* ShinyNodeState_pop(ShinyNodeState *a_top) { - ShinyNodeState *prev = a_top->_prev; - free(a_top); - return prev; -} - -/*---------------------------------------------------------------------------*/ - -ShinyNode* ShinyNodeState_finishAndGetNext(ShinyNodeState *self, float a_damping) { - ShinyNode *node = self->node; - ShinyZone *zone = node->zone; - - if (self->zoneUpdating) { - zone->data.childTicks.cur += node->data.childTicks.cur; - zone->_state = SHINY_ZONE_STATE_INITIALIZED; - } - - ShinyData_computeAverage(&node->data, a_damping); - - if (!ShinyNode_isRoot(node)) - node->parent->data.childTicks.cur += node->data.selfTicks.cur + node->data.childTicks.cur; - - return node->nextSibling; -} - - -/*---------------------------------------------------------------------------*/ - -ShinyNode* ShinyNodeState_finishAndGetNextClean(ShinyNodeState *self) { - ShinyNode *node = self->node; - ShinyZone *zone = node->zone; - - if (self->zoneUpdating) { - zone->data.childTicks.cur += node->data.childTicks.cur; - zone->_state = SHINY_ZONE_STATE_INITIALIZED; - } - - ShinyData_copyAverage(&node->data); - - if (!ShinyNode_isRoot(node)) - node->parent->data.childTicks.cur += node->data.selfTicks.cur + node->data.childTicks.cur; - - return node->nextSibling; -} - -#endif /* SLIC3R_PROFILE */ diff --git a/src/Shiny/ShinyNodeState.h b/src/Shiny/ShinyNodeState.h deleted file mode 100644 index 62fdd4ba8..000000000 --- a/src/Shiny/ShinyNodeState.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_NODE_STATE_H -#define SHINY_NODE_STATE_H - -#include "ShinyNode.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*---------------------------------------------------------------------------*/ - -typedef struct _ShinyNodeState { - ShinyNode *node; - int zoneUpdating; - - struct _ShinyNodeState *_prev; -} ShinyNodeState; - - -/*---------------------------------------------------------------------------*/ - -ShinyNodeState* ShinyNodeState_push(ShinyNodeState *a_top, ShinyNode *a_node); -ShinyNodeState* ShinyNodeState_pop(ShinyNodeState *a_top); - -ShinyNode* ShinyNodeState_finishAndGetNext(ShinyNodeState *self, float a_damping); -ShinyNode* ShinyNodeState_finishAndGetNextClean(ShinyNodeState *self); - -#if __cplusplus -} /* end of extern "C" */ -#endif - -#endif /* SHINY_NODE_STATE_H */ diff --git a/src/Shiny/ShinyOutput.c b/src/Shiny/ShinyOutput.c deleted file mode 100644 index c2c624d58..000000000 --- a/src/Shiny/ShinyOutput.c +++ /dev/null @@ -1,189 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifdef SLIC3R_PROFILE - -#include "ShinyOutput.h" - -#include - -#if SHINY_COMPILER == SHINY_COMPILER_MSVC -# pragma warning(disable: 4996) -# define snprintf _snprintf -# define TRAILING 0 - -#else -# define TRAILING 1 -#endif - -/*---------------------------------------------------------------------------*/ - -#define OUTPUT_WIDTH_CALL 6 -#define OUTPUT_WIDTH_TIME (6+3) -#define OUTPUT_WIDTH_PERC (4+3) -#define OUTPUT_WIDTH_SUM 120 - -#define OUTPUT_WIDTH_DATA (1+OUTPUT_WIDTH_CALL + 1 + 2*(OUTPUT_WIDTH_TIME+4+OUTPUT_WIDTH_PERC+1) + 1) -#define OUTPUT_WIDTH_NAME (OUTPUT_WIDTH_SUM - OUTPUT_WIDTH_DATA) - - -/*---------------------------------------------------------------------------*/ - -SHINY_INLINE char* printHeader(char *output, const char *a_title) { - snprintf(output, OUTPUT_WIDTH_SUM + TRAILING, - "%-*s %*s %*s %*s", - OUTPUT_WIDTH_NAME, a_title, - OUTPUT_WIDTH_CALL, "calls", - OUTPUT_WIDTH_TIME+4+OUTPUT_WIDTH_PERC+1, "self time", - OUTPUT_WIDTH_TIME+4+OUTPUT_WIDTH_PERC+1, "total time"); - - return output + OUTPUT_WIDTH_SUM; -} - - -/*---------------------------------------------------------------------------*/ - -SHINY_INLINE char* printData(char *output, const ShinyData *a_data, float a_topercent) { - float totalTicksAvg = ShinyData_totalTicksAvg(a_data); - const ShinyTimeUnit *selfUnit = ShinyGetTimeUnit(a_data->selfTicks.avg); - const ShinyTimeUnit *totalUnit = ShinyGetTimeUnit(totalTicksAvg); - - snprintf(output, OUTPUT_WIDTH_DATA + TRAILING, - " %*.1f %*.2f %-2s %*.2f%% %*.2f %-2s %*.2f%%", - OUTPUT_WIDTH_CALL, a_data->entryCount.avg, - OUTPUT_WIDTH_TIME, a_data->selfTicks.avg * selfUnit->invTickFreq, selfUnit->suffix, - OUTPUT_WIDTH_PERC, a_data->selfTicks.avg * a_topercent, - OUTPUT_WIDTH_TIME, totalTicksAvg * totalUnit->invTickFreq, totalUnit->suffix, - OUTPUT_WIDTH_PERC, totalTicksAvg * a_topercent); - - return output + OUTPUT_WIDTH_DATA; -} - - -/*---------------------------------------------------------------------------*/ - -SHINY_INLINE char* printNode(char* output, const ShinyNode *a_node, float a_topercent) { - int offset = a_node->entryLevel * 2; - - snprintf(output, OUTPUT_WIDTH_NAME + TRAILING, "%*s%-*s", - offset, "", OUTPUT_WIDTH_NAME - offset, a_node->zone->name); - - output += OUTPUT_WIDTH_NAME; - - output = printData(output, &a_node->data, a_topercent); - return output; -} - - -/*---------------------------------------------------------------------------*/ - -SHINY_INLINE char* printZone(char* output, const ShinyZone *a_zone, float a_topercent) { - snprintf(output, OUTPUT_WIDTH_NAME + TRAILING, "%-*s", - OUTPUT_WIDTH_NAME, a_zone->name); - - output += OUTPUT_WIDTH_NAME; - - output = printData(output, &a_zone->data, a_topercent); - return output; -} - - -/*---------------------------------------------------------------------------*/ - -int ShinyPrintNodesSize(uint32_t a_count) { - return (1 + a_count) * (OUTPUT_WIDTH_SUM + 1); -} - - -/*---------------------------------------------------------------------------*/ - -int ShinyPrintZonesSize(uint32_t a_count) { - return (1 + a_count) * (OUTPUT_WIDTH_SUM + 1); -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyPrintANode(char* output, const ShinyNode *a_node, const ShinyNode *a_root) { - float fTicksToPc = 100.0f / a_root->data.childTicks.avg; - output = printNode(output, a_node, fTicksToPc); - (*output++) = '\0'; -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyPrintAZone(char* output, const ShinyZone *a_zone, const ShinyZone *a_root) { - float fTicksToPc = 100.0f / a_root->data.childTicks.avg; - output = printZone(output, a_zone, fTicksToPc); - (*output++) = '\0'; -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyPrintNodes(char* output, const ShinyNode *a_root) { - float fTicksToPc = 100.0f / a_root->data.childTicks.avg; - const ShinyNode *node = a_root; - - output = printHeader(output, "call tree"); - (*output++) = '\n'; - - for (;;) { - output = printNode(output, node, fTicksToPc); - - node = ShinyNode_findNextInTree(node); - if (node) { - (*output++) = '\n'; - } else { - (*output++) = '\0'; - return; - } - } -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyPrintZones(char* output, const ShinyZone *a_root) { - float fTicksToPc = 100.0f / a_root->data.childTicks.avg; - const ShinyZone *zone = a_root; - - output = printHeader(output, "sorted list"); - (*output++) = '\n'; - - for (;;) { - output = printZone(output, zone, fTicksToPc); - - zone = zone->next; - if (zone) { - (*output++) = '\n'; - } else { - (*output++) = '\0'; - return; - } - } -} - -#endif /* SLIC3R_PROFILE */ diff --git a/src/Shiny/ShinyOutput.h b/src/Shiny/ShinyOutput.h deleted file mode 100644 index 81c1783db..000000000 --- a/src/Shiny/ShinyOutput.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_OUTPUT_H -#define SHINY_OUTPUT_H - -#include "ShinyNode.h" -#include "ShinyZone.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*---------------------------------------------------------------------------*/ - -SHINY_API int ShinyPrintNodesSize(uint32_t a_count); -SHINY_API int ShinyPrintZonesSize(uint32_t a_count); - -SHINY_API void ShinyPrintANode(char* output, const ShinyNode *a_node, const ShinyNode *a_root); -SHINY_API void ShinyPrintAZone(char* output, const ShinyZone *a_zone, const ShinyZone *a_root); - -SHINY_API void ShinyPrintNodes(char* output, const ShinyNode *a_root); -SHINY_API void ShinyPrintZones(char* output, const ShinyZone *a_root); - - -/*---------------------------------------------------------------------------*/ - -#if __cplusplus -} /* end of extern "C" */ -#include - -SHINY_INLINE std::string ShinyNodesToString(const ShinyNode *a_root, uint32_t a_count) { - std::string str; - str.resize(ShinyPrintNodesSize(a_count) - 1); - ShinyPrintNodes(&str[0], a_root); - return str; -} - -SHINY_INLINE std::string ShinyZonesToString(const ShinyZone *a_root, uint32_t a_count) { - std::string str; - str.resize(ShinyPrintZonesSize(a_count) - 1); - ShinyPrintZones(&str[0], a_root); - return str; -} -#endif /* __cplusplus */ - -#endif /* SHINY_OUTPUT_H */ diff --git a/src/Shiny/ShinyPrereqs.h b/src/Shiny/ShinyPrereqs.h deleted file mode 100644 index 5a3044dbc..000000000 --- a/src/Shiny/ShinyPrereqs.h +++ /dev/null @@ -1,138 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_PREREQS_H -#define SHINY_PREREQS_H - - -#include - -/*---------------------------------------------------------------------------*/ - -#ifndef FALSE -#define FALSE 0x0 -#endif - -#ifndef TRUE -#define TRUE 0x1 -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#include "ShinyConfig.h" -#include "ShinyVersion.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*---------------------------------------------------------------------------*/ - -#define SHINY_PLATFORM_WIN32 0x1 -#define SHINY_PLATFORM_POSIX 0x2 - -#if defined (_WIN32) -# define SHINY_PLATFORM SHINY_PLATFORM_WIN32 - -#else /* ASSUME: POSIX-compliant OS */ -# define SHINY_PLATFORM SHINY_PLATFORM_POSIX -#endif - - -/*---------------------------------------------------------------------------*/ - -#define SHINY_COMPILER_MSVC 0x1 -#define SHINY_COMPILER_GNUC 0x2 -#define SHINY_COMPILER_OTHER 0x3 - -#if defined (_MSC_VER) -# define SHINY_COMPILER SHINY_COMPILER_MSVC - -#elif defined (__GNUG__) -# define SHINY_COMPILER SHINY_COMPILER_GNUC - -#else -# define SHINY_COMPILER SHINY_COMPILER_OTHER -#endif - - -/*---------------------------------------------------------------------------*/ - -#if SHINY_COMPILER == SHINY_COMPILER_GNUC -#include -#include -#endif - - -/*---------------------------------------------------------------------------*/ - -struct _ShinyNode; -struct _ShinyZone; - -typedef struct _ShinyNode* ShinyNodeCache; -typedef struct _ShinyNode* ShinyNodeTable; - -/*---------------------------------------------------------------------------*/ - -#define SHINY_API - -/*---------------------------------------------------------------------------*/ - -#if SHINY_COMPILER == SHINY_COMPILER_MSVC -# define SHINY_INLINE __inline -# define SHINY_UNUSED -#elif SHINY_COMPILER == SHINY_COMPILER_GNUC -# define SHINY_INLINE inline -# define SHINY_UNUSED __attribute__((unused)) -#elif SHINY_COMPILER == SHINY_COMPILER_OTHER -# define SHINY_INLINE inline -# define SHINY_UNUSED -#endif - - -/*---------------------------------------------------------------------------*/ - -#if SHINY_COMPILER == SHINY_COMPILER_MSVC - typedef int int32_t; - typedef unsigned int uint32_t; - - typedef __int64 int64_t; - typedef unsigned __int64 uint64_t; - -/* -#elif defined(__CYGWIN__) - typedef u_int32_t uint32_t; - typedef u_int64_t uint64_t; -*/ -#endif - - typedef uint64_t shinytick_t; - -#if __cplusplus -} /* end of extern "C" */ -#endif - -#endif /* SHINY_PREREQS_H */ diff --git a/src/Shiny/ShinyTools.c b/src/Shiny/ShinyTools.c deleted file mode 100644 index 4058e2285..000000000 --- a/src/Shiny/ShinyTools.c +++ /dev/null @@ -1,116 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifdef SLIC3R_PROFILE - -#include "ShinyTools.h" - -#if SHINY_PLATFORM == SHINY_PLATFORM_WIN32 -#define WIN32_LEAN_AND_MEAN -#ifndef NOMINMAX - #define NOMINMAX -#endif /* NOMINMAX */ -#include - -#elif SHINY_PLATFORM == SHINY_PLATFORM_POSIX -#include -#endif - - -/*---------------------------------------------------------------------------*/ - -const ShinyTimeUnit* ShinyGetTimeUnit(float ticks) { - static ShinyTimeUnit units[4] = { 0 }; - - if (units[0].tickFreq == 0) { /* auto initialize first time */ - units[0].tickFreq = ShinyGetTickFreq() / 1.0f; - units[0].invTickFreq = ShinyGetTickInvFreq() * 1.0f; - units[0].suffix = "s"; - - units[1].tickFreq = ShinyGetTickFreq() / 1000.0f; - units[1].invTickFreq = ShinyGetTickInvFreq() * 1000.0f; - units[1].suffix = "ms"; - - units[2].tickFreq = ShinyGetTickFreq() / 1000000.0f; - units[2].invTickFreq = ShinyGetTickInvFreq() * 1000000.0f; - units[2].suffix = "us"; - - units[3].tickFreq = ShinyGetTickFreq() / 1000000000.0f; - units[3].invTickFreq = ShinyGetTickInvFreq() * 1000000000.0f; - units[3].suffix = "ns"; - } - - if (units[0].tickFreq < ticks) return &units[0]; - else if (units[1].tickFreq < ticks) return &units[1]; - else if (units[2].tickFreq < ticks) return &units[2]; - else return &units[3]; -} - - -/*---------------------------------------------------------------------------*/ - -#if SHINY_PLATFORM == SHINY_PLATFORM_WIN32 - -void ShinyGetTicks(shinytick_t *p) { - QueryPerformanceCounter((LARGE_INTEGER*)(p)); -} - -shinytick_t ShinyGetTickFreq(void) { - static shinytick_t freq = 0; - if (freq == 0) QueryPerformanceFrequency((LARGE_INTEGER*)(&freq)); - return freq; -} - -float ShinyGetTickInvFreq(void) { - static float invfreq = 0; - if (invfreq == 0) invfreq = 1.0f / ShinyGetTickFreq(); - return invfreq; -} - - -/*---------------------------------------------------------------------------*/ - -#elif SHINY_PLATFORM == SHINY_PLATFORM_POSIX - -//#include -//#include - -void ShinyGetTicks(shinytick_t *p) { - struct timeval time; - gettimeofday(&time, NULL); - - *p = time.tv_sec * 1000000 + time.tv_usec; -} - -shinytick_t ShinyGetTickFreq(void) { - return 1000000; -} - -float ShinyGetTickInvFreq(void) { - return 1.0f / 1000000.0f; -} - -#endif - -#endif /* SLIC3R_PROFILE */ diff --git a/src/Shiny/ShinyTools.h b/src/Shiny/ShinyTools.h deleted file mode 100644 index 379703ee6..000000000 --- a/src/Shiny/ShinyTools.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_TOOLS_H -#define SHINY_TOOLS_H - -#include "ShinyPrereqs.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*---------------------------------------------------------------------------*/ - -typedef struct { - float tickFreq; - float invTickFreq; - const char* suffix; -} ShinyTimeUnit; - - -/*---------------------------------------------------------------------------*/ - -SHINY_API const ShinyTimeUnit* ShinyGetTimeUnit(float ticks); - -SHINY_API void ShinyGetTicks(shinytick_t *p); - -SHINY_API shinytick_t ShinyGetTickFreq(void); - -SHINY_API float ShinyGetTickInvFreq(void); - -#if __cplusplus -} /* end of extern "C" */ -#endif - -#endif /* SHINY_TOOLS_H */ diff --git a/src/Shiny/ShinyVersion.h b/src/Shiny/ShinyVersion.h deleted file mode 100644 index fe6cd4a33..000000000 --- a/src/Shiny/ShinyVersion.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_VERSION_H -#define SHINY_VERSION_H - - -/*---------------------------------------------------------------------------*/ - -#define SHINY_VERSION "2.6 RC1" -#define SHINY_SHORTNAME "Shiny" -#define SHINY_FULLNAME "Shiny Profiler" -#define SHINY_COPYRIGHT "Copyright (C) 2007-2010 Aidin Abedi" -#define SHINY_DESCRIPTION "Shiny is a state of the art profiler designed to help finding bottlenecks in your project." - -#endif /* SHINY_VERSION_H */ diff --git a/src/Shiny/ShinyZone.c b/src/Shiny/ShinyZone.c deleted file mode 100644 index 99d90d927..000000000 --- a/src/Shiny/ShinyZone.c +++ /dev/null @@ -1,201 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifdef SLIC3R_PROFILE - -#include "ShinyZone.h" - -#include - -/*---------------------------------------------------------------------------*/ - -void ShinyZone_preUpdateChain(ShinyZone *first) { - ShinyZone* zone = first; - - while (zone) { - ShinyData_clearCurrent(&(zone->data)); - zone = zone->next; - } -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyZone_updateChain(ShinyZone *first, float a_damping) { - ShinyZone* zone = first; - - do { - ShinyData_computeAverage(&(zone->data), a_damping); - zone = zone->next; - } while (zone); -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyZone_updateChainClean(ShinyZone *first) { - ShinyZone* zone = first; - - do { - ShinyData_copyAverage(&(zone->data)); - zone = zone->next; - } while (zone); -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyZone_resetChain(ShinyZone *first) { - ShinyZone* zone = first, *temp; - - do { - zone->_state = SHINY_ZONE_STATE_HIDDEN; - temp = zone->next; - zone->next = NULL; - zone = temp; - } while (zone); -} - -/*---------------------------------------------------------------------------*/ - -/* A Linked-List Memory Sort - by Philip J. Erdelsky - pje@efgh.com - http://www.alumni.caltech.edu/~pje/ - - Modified by Aidin Abedi -*/ - -ShinyZone* ShinyZone_sortChain(ShinyZone **first) /* return ptr to last zone */ -{ - ShinyZone *p = *first; - - unsigned base; - unsigned long block_size; - - struct tape - { - ShinyZone *first, *last; - unsigned long count; - } tape[4]; - - /* Distribute the records alternately to tape[0] and tape[1]. */ - - tape[0].count = tape[1].count = 0L; - tape[0].first = NULL; - base = 0; - while (p != NULL) - { - ShinyZone *next = p->next; - p->next = tape[base].first; - tape[base].first = p; - tape[base].count++; - p = next; - base ^= 1; - } - - /* If the list is empty or contains only a single record, then */ - /* tape[1].count == 0L and this part is vacuous. */ - - for (base = 0, block_size = 1L; tape[base+1].count != 0L; - base ^= 2, block_size <<= 1) - { - int dest; - struct tape *tape0, *tape1; - tape0 = tape + base; - tape1 = tape + base + 1; - dest = base ^ 2; - tape[dest].count = tape[dest+1].count = 0; - for (; tape0->count != 0; dest ^= 1) - { - unsigned long n0, n1; - struct tape *output_tape = tape + dest; - n0 = n1 = block_size; - while (1) - { - ShinyZone *chosen_record; - struct tape *chosen_tape; - if (n0 == 0 || tape0->count == 0) - { - if (n1 == 0 || tape1->count == 0) - break; - chosen_tape = tape1; - n1--; - } - else if (n1 == 0 || tape1->count == 0) - { - chosen_tape = tape0; - n0--; - } - else if (ShinyZone_compare(tape1->first, tape0->first) > 0) - { - chosen_tape = tape1; - n1--; - } - else - { - chosen_tape = tape0; - n0--; - } - chosen_tape->count--; - chosen_record = chosen_tape->first; - chosen_tape->first = chosen_record->next; - if (output_tape->count == 0) - output_tape->first = chosen_record; - else - output_tape->last->next = chosen_record; - output_tape->last = chosen_record; - output_tape->count++; - } - } - } - - if (tape[base].count > 1L) { - ShinyZone* last = tape[base].last; - *first = tape[base].first; - last->next = NULL; - return last; - - } else { - return NULL; - } -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyZone_clear(ShinyZone* self) { - memset(self, 0, sizeof(ShinyZone)); -} - - -/*---------------------------------------------------------------------------*/ - -void ShinyZone_enumerateZones(const ShinyZone* a_zone, void (*a_func)(const ShinyZone*)) { - a_func(a_zone); - - if (a_zone->next) ShinyZone_enumerateZones(a_zone->next, a_func); -} - -#endif /* SLIC3R_PROFILE */ diff --git a/src/Shiny/ShinyZone.h b/src/Shiny/ShinyZone.h deleted file mode 100644 index dde0d3624..000000000 --- a/src/Shiny/ShinyZone.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -The MIT License - -Copyright (c) 2007-2010 Aidin Abedi http://code.google.com/p/shinyprofiler/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef SHINY_ZONE_H -#define SHINY_ZONE_H - -#include "ShinyData.h" -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/*---------------------------------------------------------------------------*/ - -#define SHINY_ZONE_STATE_HIDDEN 0 -#define SHINY_ZONE_STATE_INITIALIZED 1 -#define SHINY_ZONE_STATE_UPDATING 2 - - -/*---------------------------------------------------------------------------*/ - -typedef struct _ShinyZone { - struct _ShinyZone* next; - int _state; - const char* name; - ShinyData data; -} ShinyZone; - - -/*---------------------------------------------------------------------------*/ - -SHINY_INLINE void ShinyZone_init(ShinyZone *self, ShinyZone* a_prev) { - self->_state = SHINY_ZONE_STATE_INITIALIZED; - a_prev->next = self; -} - -SHINY_INLINE void ShinyZone_uninit(ShinyZone *self) { - self->_state = SHINY_ZONE_STATE_HIDDEN; - self->next = NULL; -} - -SHINY_API void ShinyZone_preUpdateChain(ShinyZone *first); -SHINY_API void ShinyZone_updateChain(ShinyZone *first, float a_damping); -SHINY_API void ShinyZone_updateChainClean(ShinyZone *first); - -SHINY_API void ShinyZone_resetChain(ShinyZone *first); - -SHINY_API ShinyZone* ShinyZone_sortChain(ShinyZone **first); - -SHINY_INLINE float ShinyZone_compare(ShinyZone *a, ShinyZone *b) { - return a->data.selfTicks.avg - b->data.selfTicks.avg; -} - -SHINY_API void ShinyZone_clear(ShinyZone* self); - -SHINY_API void ShinyZone_enumerateZones(const ShinyZone* a_zone, void (*a_func)(const ShinyZone*)); - -#if __cplusplus -} /* end of extern "C" */ - -template -void ShinyZone_enumerateZones(const ShinyZone* a_zone, T* a_this, void (T::*a_func)(const ShinyZone*)) { - (a_this->*a_func)(a_zone); - - if (a_zone->next) ShinyZone_enumerateZones(a_zone->next, a_this, a_func); -} -#endif /* __cplusplus */ - -#endif /* SHINY_ZONE_H */ diff --git a/src/clipper/CMakeLists.txt b/src/clipper/CMakeLists.txt index f62508820..3cb7cb6bb 100644 --- a/src/clipper/CMakeLists.txt +++ b/src/clipper/CMakeLists.txt @@ -8,7 +8,3 @@ add_library(clipper STATIC clipper_z.cpp clipper_z.hpp ) - -if(SLIC3R_PROFILE) - target_link_libraries(clipper Shiny) -endif() diff --git a/src/clipper/clipper.cpp b/src/clipper/clipper.cpp index 6fde80906..2ca643882 100644 --- a/src/clipper/clipper.cpp +++ b/src/clipper/clipper.cpp @@ -50,17 +50,6 @@ #include #include -// Profiling support using the Shiny intrusive profiler -//#define CLIPPERLIB_PROFILE -#if defined(SLIC3R_PROFILE) && defined(CLIPPERLIB_PROFILE) - #include - #define CLIPPERLIB_PROFILE_FUNC() PROFILE_FUNC() - #define CLIPPERLIB_PROFILE_BLOCK(name) PROFILE_BLOCK(name) -#else - #define CLIPPERLIB_PROFILE_FUNC() - #define CLIPPERLIB_PROFILE_BLOCK(name) -#endif - #ifdef CLIPPERLIB_NAMESPACE_PREFIX namespace CLIPPERLIB_NAMESPACE_PREFIX { #endif // CLIPPERLIB_NAMESPACE_PREFIX @@ -299,7 +288,6 @@ int PointInPolygon (const IntPoint &pt, OutPt *op) // This is potentially very expensive! O(n^2)! bool Poly2ContainsPoly1(OutPt *OutPt1, OutPt *OutPt2) { - CLIPPERLIB_PROFILE_FUNC(); OutPt* op = OutPt1; do { @@ -768,7 +756,6 @@ TEdge* ClipperBase::ProcessBound(TEdge* E, bool NextIsForward) bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed) { - CLIPPERLIB_PROFILE_FUNC(); // Remove duplicate end point from a closed input path. // Remove duplicate points from the end of the input path. int highI = (int)pg.size() -1; @@ -792,7 +779,6 @@ bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed) bool ClipperBase::AddPathInternal(const Path &pg, int highI, PolyType PolyTyp, bool Closed, TEdge* edges) { - CLIPPERLIB_PROFILE_FUNC(); #ifdef use_lines if (!Closed && PolyTyp == ptClip) throw clipperException("AddPath: Open paths must be subject."); @@ -975,7 +961,6 @@ bool ClipperBase::AddPathInternal(const Path &pg, int highI, PolyType PolyTyp, b void ClipperBase::Clear() { - CLIPPERLIB_PROFILE_FUNC(); m_MinimaList.clear(); m_edges.clear(); #ifndef CLIPPERLIB_INT32 @@ -989,7 +974,6 @@ void ClipperBase::Clear() // Sort the LML entries, initialize the left / right bound edges of each Local Minima. void ClipperBase::Reset() { - CLIPPERLIB_PROFILE_FUNC(); if (m_MinimaList.empty()) return; //ie nothing to process std::sort(m_MinimaList.begin(), m_MinimaList.end(), [](const LocalMinimum& lm1, const LocalMinimum& lm2){ return lm1.Y < lm2.Y; }); @@ -1018,7 +1002,6 @@ void ClipperBase::Reset() // Returns (0,0,0,0) for an empty rectangle. IntRect ClipperBase::GetBounds() { - CLIPPERLIB_PROFILE_FUNC(); IntRect result; auto lm = m_MinimaList.begin(); if (lm == m_MinimaList.end()) @@ -1079,7 +1062,6 @@ Clipper::Clipper(int initOptions) : void Clipper::Reset() { - CLIPPERLIB_PROFILE_FUNC(); ClipperBase::Reset(); m_Scanbeam = std::priority_queue(); m_Maxima.clear(); @@ -1094,7 +1076,6 @@ void Clipper::Reset() bool Clipper::Execute(ClipType clipType, Paths &solution, PolyFillType subjFillType, PolyFillType clipFillType) { - CLIPPERLIB_PROFILE_FUNC(); if (m_HasOpenPaths) throw clipperException("Error: PolyTree struct is needed for open path clipping."); solution.clear(); @@ -1112,7 +1093,6 @@ bool Clipper::Execute(ClipType clipType, Paths &solution, bool Clipper::Execute(ClipType clipType, PolyTree& polytree, PolyFillType subjFillType, PolyFillType clipFillType) { - CLIPPERLIB_PROFILE_FUNC(); m_SubjFillType = subjFillType; m_ClipFillType = clipFillType; m_ClipType = clipType; @@ -1126,10 +1106,8 @@ bool Clipper::Execute(ClipType clipType, PolyTree& polytree, bool Clipper::ExecuteInternal() { - CLIPPERLIB_PROFILE_FUNC(); bool succeeded = true; try { - CLIPPERLIB_PROFILE_BLOCK(Clipper_ExecuteInternal_Process); Reset(); if (m_MinimaList.empty()) return true; cInt botY = m_Scanbeam.top(); @@ -1154,13 +1132,11 @@ bool Clipper::ExecuteInternal() if (succeeded) { - CLIPPERLIB_PROFILE_BLOCK(Clipper_ExecuteInternal_Fix); //fix orientations ... //FIXME Vojtech: Does it not invalidate the loop hierarchy maintained as OutRec::FirstLeft pointers? //FIXME Vojtech: The area is calculated with floats, it may not be numerically stable! { - CLIPPERLIB_PROFILE_BLOCK(Clipper_ExecuteInternal_Fix_orientations); for (OutRec *outRec : m_PolyOuts) if (outRec->Pts && !outRec->IsOpen && (outRec->IsHole ^ m_ReverseOutput) == (Area(*outRec) > 0)) ReversePolyPtLinks(outRec->Pts); @@ -1170,7 +1146,6 @@ bool Clipper::ExecuteInternal() //unfortunately FixupOutPolygon() must be done after JoinCommonEdges() { - CLIPPERLIB_PROFILE_BLOCK(Clipper_ExecuteInternal_Fix_fixup); for (OutRec *outRec : m_PolyOuts) if (outRec->Pts) { if (outRec->IsOpen) @@ -1424,7 +1399,6 @@ bool Clipper::IsContributing(const TEdge& edge) const // Called from Clipper::InsertLocalMinimaIntoAEL() and Clipper::IntersectEdges(). OutPt* Clipper::AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt) { - CLIPPERLIB_PROFILE_FUNC(); OutPt* result; TEdge *e, *prevE; if (IsHorizontal(*e2) || ( e1->Dx > e2->Dx )) @@ -1516,7 +1490,6 @@ void Clipper::CopyAELToSEL() // Called from Clipper::ExecuteInternal() void Clipper::InsertLocalMinimaIntoAEL(const cInt botY) { - CLIPPERLIB_PROFILE_FUNC(); while (!m_MinimaList.empty() && m_MinimaList.back().Y == botY) { TEdge* lb = m_MinimaList.back().LeftBound; @@ -2066,7 +2039,6 @@ OutPt* Clipper::GetLastOutPt(TEdge *e) void Clipper::ProcessHorizontals() { - CLIPPERLIB_PROFILE_FUNC(); TEdge* horzEdge = m_SortedEdges; while(horzEdge) { @@ -2443,7 +2415,6 @@ void Clipper::UpdateEdgeIntoAEL(TEdge *&e) bool Clipper::ProcessIntersections(const cInt topY) { - CLIPPERLIB_PROFILE_FUNC(); if( !m_ActiveEdges ) return true; try { BuildIntersectList(topY); @@ -2598,7 +2569,6 @@ void Clipper::DoMaxima(TEdge *e) void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY) { - CLIPPERLIB_PROFILE_FUNC(); TEdge* e = m_ActiveEdges; while( e ) { @@ -3209,7 +3179,6 @@ bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2) // This is potentially very expensive! O(n^3)! void Clipper::FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec) const { - CLIPPERLIB_PROFILE_FUNC(); //tests if NewOutRec contains the polygon before reassigning FirstLeft for (OutRec *outRec : m_PolyOuts) { @@ -3233,7 +3202,6 @@ void Clipper::FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec) const void Clipper::JoinCommonEdges() { - CLIPPERLIB_PROFILE_FUNC(); for (Join &join : m_Joins) { OutRec *outRec1 = GetOutRec(join.OutPt1->Idx); @@ -3784,7 +3752,6 @@ void ClipperOffset::DoRound(int j, int k) // http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Classes/Clipper/Properties/StrictlySimple.htm void Clipper::DoSimplePolygons() { - CLIPPERLIB_PROFILE_FUNC(); size_t i = 0; while (i < m_PolyOuts.size()) { diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index 06701f3c3..3ec4502a2 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -461,10 +461,6 @@ if(WIN32) target_link_libraries(libslic3r Psapi.lib) endif() -if(SLIC3R_PROFILE) - target_link_libraries(libslic3r Shiny) -endif() - if (APPLE) # This flag prevents the need for minimum SDK version 10.14 # currently, PS targets v10.12 diff --git a/src/libslic3r/ClipperUtils.cpp b/src/libslic3r/ClipperUtils.cpp index a570b997a..d03cb5a70 100644 --- a/src/libslic3r/ClipperUtils.cpp +++ b/src/libslic3r/ClipperUtils.cpp @@ -8,17 +8,6 @@ #include "SVG.hpp" #endif /* CLIPPER_UTILS_DEBUG */ -// Profiling support using the Shiny intrusive profiler -//#define CLIPPER_UTILS_PROFILE -#if defined(SLIC3R_PROFILE) && defined(CLIPPER_UTILS_PROFILE) - #include - #define CLIPPERUTILS_PROFILE_FUNC() PROFILE_FUNC() - #define CLIPPERUTILS_PROFILE_BLOCK(name) PROFILE_BLOCK(name) -#else - #define CLIPPERUTILS_PROFILE_FUNC() - #define CLIPPERUTILS_PROFILE_BLOCK(name) -#endif - #define CLIPPER_OFFSET_SHORTEST_EDGE_FACTOR (0.005f) namespace Slic3r { diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 1ddee6b7c..2f03de787 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -53,8 +53,6 @@ using slic3r_tbb_filtermode = tbb::filter; #endif -#include - using namespace std::literals::string_view_literals; #if 0 @@ -735,8 +733,6 @@ namespace DoExport { void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb) { - PROFILE_CLEAR(); - CNumericLocalesSetter locales_setter; // Does the file exist? If so, we hope that it is still valid. @@ -828,10 +824,6 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu BOOST_LOG_TRIVIAL(info) << "Exporting G-code finished" << log_memory_info(); print->set_done(psGCodeExport); - - // Write the profiler measurements to file - PROFILE_UPDATE(); - PROFILE_OUTPUT(debug_out_path("gcode-export-profile.txt").c_str()); } // free functions called by GCode::_do_export() @@ -1048,8 +1040,6 @@ std::vector sort_object_instances_by_model_order(const Pri void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb) { - PROFILE_FUNC(); - // modifies m_silent_time_estimator_enabled DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled); diff --git a/src/libslic3r/GCodeReader.cpp b/src/libslic3r/GCodeReader.cpp index 44b0b89f6..cd6cedf51 100644 --- a/src/libslic3r/GCodeReader.cpp +++ b/src/libslic3r/GCodeReader.cpp @@ -10,7 +10,6 @@ #include "LocalesUtils.hpp" -#include #include namespace Slic3r { @@ -37,14 +36,11 @@ void GCodeReader::apply_config(const DynamicPrintConfig &config) const char* GCodeReader::parse_line_internal(const char *ptr, const char *end, GCodeLine &gline, std::pair &command) { - PROFILE_FUNC(); - assert(is_decimal_separator_point()); // command and args const char *c = ptr; { - PROFILE_BLOCK(command_and_args); // Skip the whitespaces. command.first = skip_whitespaces(c); // Skip the command. @@ -98,10 +94,8 @@ const char* GCodeReader::parse_line_internal(const char *ptr, const char *end, G for (; ! is_end_of_line(*c); ++ c); // Copy the raw string including the comment, without the trailing newlines. - if (c > ptr) { - PROFILE_BLOCK(copy_raw_string); + if (c > ptr) gline.m_raw.assign(ptr, c); - } // Skip the trailing newlines. if (*c == '\r') @@ -117,7 +111,6 @@ const char* GCodeReader::parse_line_internal(const char *ptr, const char *end, G void GCodeReader::update_coordinates(GCodeLine &gline, std::pair &command) { - PROFILE_FUNC(); if (*command.first == 'G') { int cmd_len = int(command.second - command.first); if ((cmd_len == 2 && (command.first[1] == '0' || command.first[1] == '1')) || diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 2b259cb38..602aad540 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -26,8 +26,6 @@ #include -#include - using namespace std::literals; //! macro used to mark string used at localization, @@ -1037,8 +1035,6 @@ void PrintObject::process_external_surfaces() void PrintObject::discover_vertical_shells() { - PROFILE_FUNC(); - BOOST_LOG_TRIVIAL(info) << "Discovering vertical shells..." << log_memory_info(); struct DiscoverVerticalShellsCacheEntry @@ -1149,8 +1145,6 @@ void PrintObject::discover_vertical_shells() } for (size_t region_id = 0; region_id < this->num_printing_regions(); ++ region_id) { - PROFILE_BLOCK(discover_vertical_shells_region); - const PrintRegion ®ion = this->printing_region(region_id); if (! region.config().ensure_vertical_shell_thickness.value) // This region will be handled by discover_horizontal_shells(). @@ -1200,7 +1194,6 @@ void PrintObject::discover_vertical_shells() (const tbb::blocked_range& range) { // printf("discover_vertical_shells from %d to %d\n", range.begin(), range.end()); for (size_t idx_layer = range.begin(); idx_layer < range.end(); ++ idx_layer) { - PROFILE_BLOCK(discover_vertical_shells_region_layer); m_print->throw_if_canceled(); #ifdef SLIC3R_DEBUG_SLICE_PROCESSING static size_t debug_idx = 0; @@ -1225,88 +1218,82 @@ void PrintObject::discover_vertical_shells() ExPolygons shell_ex; #endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ float min_perimeter_infill_spacing = float(infill_line_spacing) * 1.05f; - { - PROFILE_BLOCK(discover_vertical_shells_region_layer_collect); #if 0 // #ifdef SLIC3R_DEBUG_SLICE_PROCESSING - { - Slic3r::SVG svg_cummulative(debug_out_path("discover_vertical_shells-perimeters-before-union-run%d.svg", debug_idx), this->bounding_box()); - for (int n = (int)idx_layer - n_extra_bottom_layers; n <= (int)idx_layer + n_extra_top_layers; ++ n) { - if (n < 0 || n >= (int)m_layers.size()) - continue; - ExPolygons &expolys = m_layers[n]->perimeter_expolygons; - for (size_t i = 0; i < expolys.size(); ++ i) { - Slic3r::SVG svg(debug_out_path("discover_vertical_shells-perimeters-before-union-run%d-layer%d-expoly%d.svg", debug_idx, n, i), get_extents(expolys[i])); - svg.draw(expolys[i]); - svg.draw_outline(expolys[i].contour, "black", scale_(0.05)); - svg.draw_outline(expolys[i].holes, "blue", scale_(0.05)); - svg.Close(); + { + Slic3r::SVG svg_cummulative(debug_out_path("discover_vertical_shells-perimeters-before-union-run%d.svg", debug_idx), this->bounding_box()); + for (int n = (int)idx_layer - n_extra_bottom_layers; n <= (int)idx_layer + n_extra_top_layers; ++ n) { + if (n < 0 || n >= (int)m_layers.size()) + continue; + ExPolygons &expolys = m_layers[n]->perimeter_expolygons; + for (size_t i = 0; i < expolys.size(); ++ i) { + Slic3r::SVG svg(debug_out_path("discover_vertical_shells-perimeters-before-union-run%d-layer%d-expoly%d.svg", debug_idx, n, i), get_extents(expolys[i])); + svg.draw(expolys[i]); + svg.draw_outline(expolys[i].contour, "black", scale_(0.05)); + svg.draw_outline(expolys[i].holes, "blue", scale_(0.05)); + svg.Close(); - svg_cummulative.draw(expolys[i]); - svg_cummulative.draw_outline(expolys[i].contour, "black", scale_(0.05)); - svg_cummulative.draw_outline(expolys[i].holes, "blue", scale_(0.05)); - } + svg_cummulative.draw(expolys[i]); + svg_cummulative.draw_outline(expolys[i].contour, "black", scale_(0.05)); + svg_cummulative.draw_outline(expolys[i].holes, "blue", scale_(0.05)); } } + } #endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ - polygons_append(holes, cache_top_botom_regions[idx_layer].holes); - if (int n_top_layers = region_config.top_solid_layers.value; n_top_layers > 0) { - // Gather top regions projected to this layer. - coordf_t print_z = layer->print_z; - for (int i = int(idx_layer) + 1; - i < int(cache_top_botom_regions.size()) && - (i < int(idx_layer) + n_top_layers || - m_layers[i]->print_z - print_z < region_config.top_solid_min_thickness - EPSILON); - ++ i) { - const DiscoverVerticalShellsCacheEntry &cache = cache_top_botom_regions[i]; - if (! holes.empty()) - holes = intersection(holes, cache.holes); - if (! cache.top_surfaces.empty()) { - polygons_append(shell, cache.top_surfaces); - // Running the union_ using the Clipper library piece by piece is cheaper - // than running the union_ all at once. - shell = union_(shell); - } + polygons_append(holes, cache_top_botom_regions[idx_layer].holes); + if (int n_top_layers = region_config.top_solid_layers.value; n_top_layers > 0) { + // Gather top regions projected to this layer. + coordf_t print_z = layer->print_z; + for (int i = int(idx_layer) + 1; + i < int(cache_top_botom_regions.size()) && + (i < int(idx_layer) + n_top_layers || + m_layers[i]->print_z - print_z < region_config.top_solid_min_thickness - EPSILON); + ++ i) { + const DiscoverVerticalShellsCacheEntry &cache = cache_top_botom_regions[i]; + if (! holes.empty()) + holes = intersection(holes, cache.holes); + if (! cache.top_surfaces.empty()) { + polygons_append(shell, cache.top_surfaces); + // Running the union_ using the Clipper library piece by piece is cheaper + // than running the union_ all at once. + shell = union_(shell); } } - if (int n_bottom_layers = region_config.bottom_solid_layers.value; n_bottom_layers > 0) { - // Gather bottom regions projected to this layer. - coordf_t bottom_z = layer->bottom_z(); - for (int i = int(idx_layer) - 1; - i >= 0 && - (i > int(idx_layer) - n_bottom_layers || - bottom_z - m_layers[i]->bottom_z() < region_config.bottom_solid_min_thickness - EPSILON); - -- i) { - const DiscoverVerticalShellsCacheEntry &cache = cache_top_botom_regions[i]; - if (! holes.empty()) - holes = intersection(holes, cache.holes); - if (! cache.bottom_surfaces.empty()) { - polygons_append(shell, cache.bottom_surfaces); - // Running the union_ using the Clipper library piece by piece is cheaper - // than running the union_ all at once. - shell = union_(shell); - } - } + } + if (int n_bottom_layers = region_config.bottom_solid_layers.value; n_bottom_layers > 0) { + // Gather bottom regions projected to this layer. + coordf_t bottom_z = layer->bottom_z(); + for (int i = int(idx_layer) - 1; + i >= 0 && + (i > int(idx_layer) - n_bottom_layers || + bottom_z - m_layers[i]->bottom_z() < region_config.bottom_solid_min_thickness - EPSILON); + -- i) { + const DiscoverVerticalShellsCacheEntry &cache = cache_top_botom_regions[i]; + if (! holes.empty()) + holes = intersection(holes, cache.holes); + if (! cache.bottom_surfaces.empty()) { + polygons_append(shell, cache.bottom_surfaces); + // Running the union_ using the Clipper library piece by piece is cheaper + // than running the union_ all at once. + shell = union_(shell); + } } + } #ifdef SLIC3R_DEBUG_SLICE_PROCESSING - { - Slic3r::SVG svg(debug_out_path("discover_vertical_shells-perimeters-before-union-%d.svg", debug_idx), get_extents(shell)); - svg.draw(shell); - svg.draw_outline(shell, "black", scale_(0.05)); - svg.Close(); - } + { + Slic3r::SVG svg(debug_out_path("discover_vertical_shells-perimeters-before-union-%d.svg", debug_idx), get_extents(shell)); + svg.draw(shell); + svg.draw_outline(shell, "black", scale_(0.05)); + svg.Close(); + } #endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ #if 0 - { - PROFILE_BLOCK(discover_vertical_shells_region_layer_shell_); - // shell = union_(shell, true); - shell = union_(shell, false); - } +// shell = union_(shell, true); + shell = union_(shell, false); #endif #ifdef SLIC3R_DEBUG_SLICE_PROCESSING - shell_ex = union_safety_offset_ex(shell); + shell_ex = union_safety_offset_ex(shell); #endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ - } //if (shell.empty()) // continue; @@ -1433,10 +1420,6 @@ void PrintObject::discover_vertical_shells() } #endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ } // for each region - - // Write the profiler measurements to file -// PROFILE_UPDATE(); -// PROFILE_OUTPUT(debug_out_path("discover_vertical_shells-profile.txt").c_str()); } // This method applies bridge flow to the first internal solid layer above sparse infill. diff --git a/src/libslic3r/Thread.cpp b/src/libslic3r/Thread.cpp index c099f8de6..4fe07fb59 100644 --- a/src/libslic3r/Thread.cpp +++ b/src/libslic3r/Thread.cpp @@ -203,7 +203,7 @@ void name_tbb_thread_pool_threads_set_locale() const size_t nthreads_hw = tbb::this_task_arena::max_concurrency(); size_t nthreads = nthreads_hw; -#ifdef SLIC3R_PROFILE +#if 0 // Shiny profiler is not thread safe, thus disable parallelization. disable_multi_threading(); nthreads = 1; diff --git a/src/libslic3r/pchheader.hpp b/src/libslic3r/pchheader.hpp index aeb79e3d8..9017a5dea 100644 --- a/src/libslic3r/pchheader.hpp +++ b/src/libslic3r/pchheader.hpp @@ -133,6 +133,4 @@ #include "libslic3r.h" #include "libslic3r_version.h" -#include - #include diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index d4fa30b4f..d9ca1d532 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -127,7 +127,7 @@ static struct RunOnInit { void disable_multi_threading() { - // Disable parallelization so the Shiny profiler works + // Disable parallelization to simplify debugging. #ifdef TBB_HAS_GLOBAL_CONTROL { static tbb::global_control gc(tbb::global_control::max_allowed_parallelism, 1); diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 71a4941a4..5a5e2bb5a 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -244,7 +244,6 @@ set(SLIC3R_GUI_SOURCES Utils/PresetUpdater.hpp Utils/Process.cpp Utils/Process.hpp - Utils/Profile.hpp Utils/UndoRedo.cpp Utils/UndoRedo.hpp Utils/HexFile.cpp diff --git a/src/slic3r/GUI/AboutDialog.cpp b/src/slic3r/GUI/AboutDialog.cpp index bfd6b55dc..4b8b5caa4 100644 --- a/src/slic3r/GUI/AboutDialog.cpp +++ b/src/slic3r/GUI/AboutDialog.cpp @@ -114,7 +114,6 @@ void CopyrightsDialog::fill_entries() { "Expat" , "1998-2000 Thai Open Source Software Center Ltd and Clark Cooper" "2001-2016 Expat maintainers" , "http://www.libexpat.org/" }, { "AVRDUDE" , "2018 Free Software Foundation, Inc." , "http://savannah.nongnu.org/projects/avrdude" }, - { "Shinyprofiler" , "2007-2010 Aidin Abedi" , "http://code.google.com/p/shinyprofiler/" }, { "Real-Time DXT1/DXT5 C compression library" , "Based on original by fabian \"ryg\" giesen v1.04. " "Custom version, modified by Yann Collet" , "https://github.com/Cyan4973/RygsDXTc" }, diff --git a/src/slic3r/Utils/Profile.hpp b/src/slic3r/Utils/Profile.hpp deleted file mode 100644 index 5fb1e3116..000000000 --- a/src/slic3r/Utils/Profile.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef slic3r_GUI_Profile_hpp_ -#define slic3r_GUI_Profile_hpp_ - -// Profiling support using the Shiny intrusive profiler -//#define SLIC3R_PROFILE_GUI -#if defined(SLIC3R_PROFILE) && defined(SLIC3R_PROFILE_GUI) - #include - #define SLIC3R_GUI_PROFILE_FUNC() PROFILE_FUNC() - #define SLIC3R_GUI_PROFILE_BLOCK(name) PROFILE_BLOCK(name) - #define SLIC3R_GUI_PROFILE_UPDATE() PROFILE_UPDATE() - #define SLIC3R_GUI_PROFILE_OUTPUT(x) PROFILE_OUTPUT(x) -#else - #define SLIC3R_GUI_PROFILE_FUNC() - #define SLIC3R_GUI_PROFILE_BLOCK(name) - #define SLIC3R_GUI_PROFILE_UPDATE() - #define SLIC3R_GUI_PROFILE_OUTPUT(x) -#endif - -#endif // slic3r_GUI_Profile_hpp_