Removed shiny profiler. The Shiny profiler was only working on MSVC
and nowadays the sampling profiler inside Visual Studio is better.
This commit is contained in:
parent
51cfec55cf
commit
7e77048593
@ -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_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_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_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_PCH "Use precompiled headers" 1)
|
||||||
option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 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)
|
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.
|
# 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)
|
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
|
# Find and configure boost
|
||||||
if(SLIC3R_STATIC)
|
if(SLIC3R_STATIC)
|
||||||
# Use static boost libraries.
|
# Use static boost libraries.
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
* miniz: No packages, author suggests using in the source tree
|
* 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
|
* 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.
|
* semver: One module C library, author expects to use clib for installation. No packages.
|
||||||
* Shiny: no packages
|
|
||||||
|
|
||||||
## Header only
|
## Header only
|
||||||
* igl
|
* igl
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
#include <libslic3r/AABBTreeIndirect.hpp>
|
#include <libslic3r/AABBTreeIndirect.hpp>
|
||||||
#include <libslic3r/SLA/EigenMesh3D.hpp>
|
#include <libslic3r/SLA/EigenMesh3D.hpp>
|
||||||
|
|
||||||
#include <Shiny/Shiny.h>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable: 4244)
|
#pragma warning(disable: 4244)
|
||||||
@ -42,13 +40,7 @@ void profile(const TriangleMesh &mesh)
|
|||||||
|
|
||||||
Eigen::MatrixXd occlusion_output0;
|
Eigen::MatrixXd occlusion_output0;
|
||||||
{
|
{
|
||||||
AABBTreeIndirect::Tree3f tree;
|
AABBTreeIndirect::Tree3f tree = AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(mesh.its.vertices, mesh.its.indices);
|
||||||
{
|
|
||||||
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);
|
occlusion_output0.resize(num_vertices, 1);
|
||||||
for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) {
|
for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) {
|
||||||
const Eigen::Vector3d origin = mesh.its.vertices[ivertex].template cast<double>();
|
const Eigen::Vector3d origin = mesh.its.vertices[ivertex].template cast<double>();
|
||||||
@ -66,10 +58,6 @@ void profile(const TriangleMesh &mesh)
|
|||||||
}
|
}
|
||||||
occlusion_output0(ivertex) = (double)num_hits/(double)num_samples;
|
occlusion_output0(ivertex) = (double)num_hits/(double)num_samples;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
PROFILE_BLOCK(EigenMesh3D_AABBIndirectFF_AmbientOcclusion);
|
|
||||||
occlusion_output0.resize(num_vertices, 1);
|
occlusion_output0.resize(num_vertices, 1);
|
||||||
for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) {
|
for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) {
|
||||||
const Eigen::Vector3d origin = mesh.its.vertices[ivertex].template cast<double>();
|
const Eigen::Vector3d origin = mesh.its.vertices[ivertex].template cast<double>();
|
||||||
@ -90,7 +78,6 @@ void profile(const TriangleMesh &mesh)
|
|||||||
occlusion_output0(ivertex) = (double)num_hits/(double)num_samples;
|
occlusion_output0(ivertex) = (double)num_hits/(double)num_samples;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Eigen::MatrixXd occlusion_output1;
|
Eigen::MatrixXd occlusion_output1;
|
||||||
{
|
{
|
||||||
@ -100,14 +87,7 @@ void profile(const TriangleMesh &mesh)
|
|||||||
vertices.emplace_back(V.row(i).transpose());
|
vertices.emplace_back(V.row(i).transpose());
|
||||||
for (int i = 0; i < F.rows(); ++ i)
|
for (int i = 0; i < F.rows(); ++ i)
|
||||||
triangles.emplace_back(F.row(i).transpose());
|
triangles.emplace_back(F.row(i).transpose());
|
||||||
AABBTreeIndirect::Tree3d tree;
|
AABBTreeIndirect::Tree3d tree = AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(vertices, triangles);
|
||||||
{
|
|
||||||
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);
|
occlusion_output1.resize(num_vertices, 1);
|
||||||
for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) {
|
for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) {
|
||||||
const Eigen::Vector3d origin = V.row(ivertex).template cast<double>();
|
const Eigen::Vector3d origin = V.row(ivertex).template cast<double>();
|
||||||
@ -126,19 +106,13 @@ void profile(const TriangleMesh &mesh)
|
|||||||
occlusion_output1(ivertex) = (double)num_hits/(double)num_samples;
|
occlusion_output1(ivertex) = (double)num_hits/(double)num_samples;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Build the AABB accelaration tree
|
// Build the AABB accelaration tree
|
||||||
|
|
||||||
Eigen::MatrixXd occlusion_output2;
|
Eigen::MatrixXd occlusion_output2;
|
||||||
{
|
{
|
||||||
igl::AABB<Eigen::MatrixXd, 3> AABB;
|
igl::AABB<Eigen::MatrixXd, 3> AABB;
|
||||||
{
|
|
||||||
PROFILE_BLOCK(EigenMesh3D_AABB_Init);
|
|
||||||
AABB.init(V, F);
|
AABB.init(V, F);
|
||||||
}
|
|
||||||
{
|
|
||||||
PROFILE_BLOCK(EigenMesh3D_AABB_AmbientOcclusion);
|
|
||||||
occlusion_output2.resize(num_vertices, 1);
|
occlusion_output2.resize(num_vertices, 1);
|
||||||
for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) {
|
for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) {
|
||||||
const Eigen::Vector3d origin = V.row(ivertex).template cast<double>();
|
const Eigen::Vector3d origin = V.row(ivertex).template cast<double>();
|
||||||
@ -157,7 +131,6 @@ void profile(const TriangleMesh &mesh)
|
|||||||
occlusion_output2(ivertex) = (double)num_hits/(double)num_samples;
|
occlusion_output2(ivertex) = (double)num_hits/(double)num_samples;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Eigen::MatrixXd occlusion_output3;
|
Eigen::MatrixXd occlusion_output3;
|
||||||
{
|
{
|
||||||
@ -166,15 +139,10 @@ void profile(const TriangleMesh &mesh)
|
|||||||
igl::AABB<MapMatrixXfUnaligned, 3> AABB;
|
igl::AABB<MapMatrixXfUnaligned, 3> AABB;
|
||||||
auto vertices = MapMatrixXfUnaligned(mesh.its.vertices.front().data(), mesh.its.vertices.size(), 3);
|
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);
|
auto faces = MapMatrixXiUnaligned(mesh.its.indices.front().data(), mesh.its.indices.size(), 3);
|
||||||
{
|
|
||||||
PROFILE_BLOCK(EigenMesh3D_AABBf_Init);
|
|
||||||
AABB.init(
|
AABB.init(
|
||||||
vertices,
|
vertices,
|
||||||
faces);
|
faces);
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
PROFILE_BLOCK(EigenMesh3D_AABBf_AmbientOcclusion);
|
|
||||||
occlusion_output3.resize(num_vertices, 1);
|
occlusion_output3.resize(num_vertices, 1);
|
||||||
for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) {
|
for (int ivertex = 0; ivertex < num_vertices; ++ ivertex) {
|
||||||
const Eigen::Vector3d origin = mesh.its.vertices[ivertex].template cast<double>();
|
const Eigen::Vector3d origin = mesh.its.vertices[ivertex].template cast<double>();
|
||||||
@ -195,10 +163,6 @@ void profile(const TriangleMesh &mesh)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PROFILE_UPDATE();
|
|
||||||
PROFILE_OUTPUT(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(const int argc, const char *argv[])
|
int main(const int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
if(argc < 2) {
|
if(argc < 2) {
|
||||||
|
@ -9,7 +9,6 @@ add_subdirectory(boost)
|
|||||||
add_subdirectory(clipper)
|
add_subdirectory(clipper)
|
||||||
add_subdirectory(miniz)
|
add_subdirectory(miniz)
|
||||||
add_subdirectory(glu-libtess)
|
add_subdirectory(glu-libtess)
|
||||||
add_subdirectory(Shiny)
|
|
||||||
add_subdirectory(semver)
|
add_subdirectory(semver)
|
||||||
add_subdirectory(libigl)
|
add_subdirectory(libigl)
|
||||||
add_subdirectory(hints)
|
add_subdirectory(hints)
|
||||||
|
@ -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
|
|
||||||
)
|
|
@ -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 */
|
|
@ -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 */
|
|
@ -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 */
|
|
@ -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 */
|
|
@ -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 <malloc.h>
|
|
||||||
#include <memory.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#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 = */ "<unprofiled>",
|
|
||||||
/* 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<uint32_t*>(&a_pParent) + *reinterpret_cast<uint32_t*>(&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 */
|
|
@ -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 <stdio.h>
|
|
||||||
|
|
||||||
#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 <class T> void ShinyManager_enumerateNodes(ShinyManager *self, T* a_this, void (T::*a_func)(const ShinyNode*)) {
|
|
||||||
ShinyNode_enumerateNodes(&self->rootNode, a_this, a_func);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T> 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 */
|
|
@ -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 <memory.h>
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
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 */
|
|
@ -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 <class T>
|
|
||||||
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 */
|
|
@ -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 <memory.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
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 */
|
|
@ -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 */
|
|
@ -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 <malloc.h>
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
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 */
|
|
@ -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 */
|
|
@ -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 <stdio.h>
|
|
||||||
|
|
||||||
#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 */
|
|
@ -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 <string>
|
|
||||||
|
|
||||||
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 */
|
|
@ -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 <stdint.h>
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#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 <sys/types.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#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 */
|
|
@ -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 <windows.h>
|
|
||||||
|
|
||||||
#elif SHINY_PLATFORM == SHINY_PLATFORM_POSIX
|
|
||||||
#include <sys/time.h>
|
|
||||||
#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 <time.h>
|
|
||||||
//#include <sys/time.h>
|
|
||||||
|
|
||||||
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 */
|
|
@ -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 */
|
|
@ -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 */
|
|
@ -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 <memory.h>
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
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 */
|
|
@ -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 <memory.h>
|
|
||||||
|
|
||||||
#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 <class T>
|
|
||||||
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 */
|
|
@ -8,7 +8,3 @@ add_library(clipper STATIC
|
|||||||
clipper_z.cpp
|
clipper_z.cpp
|
||||||
clipper_z.hpp
|
clipper_z.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(SLIC3R_PROFILE)
|
|
||||||
target_link_libraries(clipper Shiny)
|
|
||||||
endif()
|
|
||||||
|
@ -50,17 +50,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <libslic3r/Int128.hpp>
|
#include <libslic3r/Int128.hpp>
|
||||||
|
|
||||||
// Profiling support using the Shiny intrusive profiler
|
|
||||||
//#define CLIPPERLIB_PROFILE
|
|
||||||
#if defined(SLIC3R_PROFILE) && defined(CLIPPERLIB_PROFILE)
|
|
||||||
#include <Shiny/Shiny.h>
|
|
||||||
#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
|
#ifdef CLIPPERLIB_NAMESPACE_PREFIX
|
||||||
namespace CLIPPERLIB_NAMESPACE_PREFIX {
|
namespace CLIPPERLIB_NAMESPACE_PREFIX {
|
||||||
#endif // 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)!
|
// This is potentially very expensive! O(n^2)!
|
||||||
bool Poly2ContainsPoly1(OutPt *OutPt1, OutPt *OutPt2)
|
bool Poly2ContainsPoly1(OutPt *OutPt1, OutPt *OutPt2)
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
OutPt* op = OutPt1;
|
OutPt* op = OutPt1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -768,7 +756,6 @@ TEdge* ClipperBase::ProcessBound(TEdge* E, bool NextIsForward)
|
|||||||
|
|
||||||
bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed)
|
bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed)
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
// Remove duplicate end point from a closed input path.
|
// Remove duplicate end point from a closed input path.
|
||||||
// Remove duplicate points from the end of the input path.
|
// Remove duplicate points from the end of the input path.
|
||||||
int highI = (int)pg.size() -1;
|
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)
|
bool ClipperBase::AddPathInternal(const Path &pg, int highI, PolyType PolyTyp, bool Closed, TEdge* edges)
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
#ifdef use_lines
|
#ifdef use_lines
|
||||||
if (!Closed && PolyTyp == ptClip)
|
if (!Closed && PolyTyp == ptClip)
|
||||||
throw clipperException("AddPath: Open paths must be subject.");
|
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()
|
void ClipperBase::Clear()
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
m_MinimaList.clear();
|
m_MinimaList.clear();
|
||||||
m_edges.clear();
|
m_edges.clear();
|
||||||
#ifndef CLIPPERLIB_INT32
|
#ifndef CLIPPERLIB_INT32
|
||||||
@ -989,7 +974,6 @@ void ClipperBase::Clear()
|
|||||||
// Sort the LML entries, initialize the left / right bound edges of each Local Minima.
|
// Sort the LML entries, initialize the left / right bound edges of each Local Minima.
|
||||||
void ClipperBase::Reset()
|
void ClipperBase::Reset()
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
if (m_MinimaList.empty()) return; //ie nothing to process
|
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; });
|
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.
|
// Returns (0,0,0,0) for an empty rectangle.
|
||||||
IntRect ClipperBase::GetBounds()
|
IntRect ClipperBase::GetBounds()
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
IntRect result;
|
IntRect result;
|
||||||
auto lm = m_MinimaList.begin();
|
auto lm = m_MinimaList.begin();
|
||||||
if (lm == m_MinimaList.end())
|
if (lm == m_MinimaList.end())
|
||||||
@ -1079,7 +1062,6 @@ Clipper::Clipper(int initOptions) :
|
|||||||
|
|
||||||
void Clipper::Reset()
|
void Clipper::Reset()
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
ClipperBase::Reset();
|
ClipperBase::Reset();
|
||||||
m_Scanbeam = std::priority_queue<cInt>();
|
m_Scanbeam = std::priority_queue<cInt>();
|
||||||
m_Maxima.clear();
|
m_Maxima.clear();
|
||||||
@ -1094,7 +1076,6 @@ void Clipper::Reset()
|
|||||||
bool Clipper::Execute(ClipType clipType, Paths &solution,
|
bool Clipper::Execute(ClipType clipType, Paths &solution,
|
||||||
PolyFillType subjFillType, PolyFillType clipFillType)
|
PolyFillType subjFillType, PolyFillType clipFillType)
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
if (m_HasOpenPaths)
|
if (m_HasOpenPaths)
|
||||||
throw clipperException("Error: PolyTree struct is needed for open path clipping.");
|
throw clipperException("Error: PolyTree struct is needed for open path clipping.");
|
||||||
solution.clear();
|
solution.clear();
|
||||||
@ -1112,7 +1093,6 @@ bool Clipper::Execute(ClipType clipType, Paths &solution,
|
|||||||
bool Clipper::Execute(ClipType clipType, PolyTree& polytree,
|
bool Clipper::Execute(ClipType clipType, PolyTree& polytree,
|
||||||
PolyFillType subjFillType, PolyFillType clipFillType)
|
PolyFillType subjFillType, PolyFillType clipFillType)
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
m_SubjFillType = subjFillType;
|
m_SubjFillType = subjFillType;
|
||||||
m_ClipFillType = clipFillType;
|
m_ClipFillType = clipFillType;
|
||||||
m_ClipType = clipType;
|
m_ClipType = clipType;
|
||||||
@ -1126,10 +1106,8 @@ bool Clipper::Execute(ClipType clipType, PolyTree& polytree,
|
|||||||
|
|
||||||
bool Clipper::ExecuteInternal()
|
bool Clipper::ExecuteInternal()
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
bool succeeded = true;
|
bool succeeded = true;
|
||||||
try {
|
try {
|
||||||
CLIPPERLIB_PROFILE_BLOCK(Clipper_ExecuteInternal_Process);
|
|
||||||
Reset();
|
Reset();
|
||||||
if (m_MinimaList.empty()) return true;
|
if (m_MinimaList.empty()) return true;
|
||||||
cInt botY = m_Scanbeam.top();
|
cInt botY = m_Scanbeam.top();
|
||||||
@ -1154,13 +1132,11 @@ bool Clipper::ExecuteInternal()
|
|||||||
|
|
||||||
if (succeeded)
|
if (succeeded)
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_BLOCK(Clipper_ExecuteInternal_Fix);
|
|
||||||
|
|
||||||
//fix orientations ...
|
//fix orientations ...
|
||||||
//FIXME Vojtech: Does it not invalidate the loop hierarchy maintained as OutRec::FirstLeft pointers?
|
//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!
|
//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)
|
for (OutRec *outRec : m_PolyOuts)
|
||||||
if (outRec->Pts && !outRec->IsOpen && (outRec->IsHole ^ m_ReverseOutput) == (Area(*outRec) > 0))
|
if (outRec->Pts && !outRec->IsOpen && (outRec->IsHole ^ m_ReverseOutput) == (Area(*outRec) > 0))
|
||||||
ReversePolyPtLinks(outRec->Pts);
|
ReversePolyPtLinks(outRec->Pts);
|
||||||
@ -1170,7 +1146,6 @@ bool Clipper::ExecuteInternal()
|
|||||||
|
|
||||||
//unfortunately FixupOutPolygon() must be done after JoinCommonEdges()
|
//unfortunately FixupOutPolygon() must be done after JoinCommonEdges()
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_BLOCK(Clipper_ExecuteInternal_Fix_fixup);
|
|
||||||
for (OutRec *outRec : m_PolyOuts)
|
for (OutRec *outRec : m_PolyOuts)
|
||||||
if (outRec->Pts) {
|
if (outRec->Pts) {
|
||||||
if (outRec->IsOpen)
|
if (outRec->IsOpen)
|
||||||
@ -1424,7 +1399,6 @@ bool Clipper::IsContributing(const TEdge& edge) const
|
|||||||
// Called from Clipper::InsertLocalMinimaIntoAEL() and Clipper::IntersectEdges().
|
// Called from Clipper::InsertLocalMinimaIntoAEL() and Clipper::IntersectEdges().
|
||||||
OutPt* Clipper::AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt)
|
OutPt* Clipper::AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt)
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
OutPt* result;
|
OutPt* result;
|
||||||
TEdge *e, *prevE;
|
TEdge *e, *prevE;
|
||||||
if (IsHorizontal(*e2) || ( e1->Dx > e2->Dx ))
|
if (IsHorizontal(*e2) || ( e1->Dx > e2->Dx ))
|
||||||
@ -1516,7 +1490,6 @@ void Clipper::CopyAELToSEL()
|
|||||||
// Called from Clipper::ExecuteInternal()
|
// Called from Clipper::ExecuteInternal()
|
||||||
void Clipper::InsertLocalMinimaIntoAEL(const cInt botY)
|
void Clipper::InsertLocalMinimaIntoAEL(const cInt botY)
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
while (!m_MinimaList.empty() && m_MinimaList.back().Y == botY)
|
while (!m_MinimaList.empty() && m_MinimaList.back().Y == botY)
|
||||||
{
|
{
|
||||||
TEdge* lb = m_MinimaList.back().LeftBound;
|
TEdge* lb = m_MinimaList.back().LeftBound;
|
||||||
@ -2066,7 +2039,6 @@ OutPt* Clipper::GetLastOutPt(TEdge *e)
|
|||||||
|
|
||||||
void Clipper::ProcessHorizontals()
|
void Clipper::ProcessHorizontals()
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
TEdge* horzEdge = m_SortedEdges;
|
TEdge* horzEdge = m_SortedEdges;
|
||||||
while(horzEdge)
|
while(horzEdge)
|
||||||
{
|
{
|
||||||
@ -2443,7 +2415,6 @@ void Clipper::UpdateEdgeIntoAEL(TEdge *&e)
|
|||||||
|
|
||||||
bool Clipper::ProcessIntersections(const cInt topY)
|
bool Clipper::ProcessIntersections(const cInt topY)
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
if( !m_ActiveEdges ) return true;
|
if( !m_ActiveEdges ) return true;
|
||||||
try {
|
try {
|
||||||
BuildIntersectList(topY);
|
BuildIntersectList(topY);
|
||||||
@ -2598,7 +2569,6 @@ void Clipper::DoMaxima(TEdge *e)
|
|||||||
|
|
||||||
void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY)
|
void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY)
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
TEdge* e = m_ActiveEdges;
|
TEdge* e = m_ActiveEdges;
|
||||||
while( e )
|
while( e )
|
||||||
{
|
{
|
||||||
@ -3209,7 +3179,6 @@ bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2)
|
|||||||
// This is potentially very expensive! O(n^3)!
|
// This is potentially very expensive! O(n^3)!
|
||||||
void Clipper::FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec) const
|
void Clipper::FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec) const
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
//tests if NewOutRec contains the polygon before reassigning FirstLeft
|
//tests if NewOutRec contains the polygon before reassigning FirstLeft
|
||||||
for (OutRec *outRec : m_PolyOuts)
|
for (OutRec *outRec : m_PolyOuts)
|
||||||
{
|
{
|
||||||
@ -3233,7 +3202,6 @@ void Clipper::FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec) const
|
|||||||
|
|
||||||
void Clipper::JoinCommonEdges()
|
void Clipper::JoinCommonEdges()
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
for (Join &join : m_Joins)
|
for (Join &join : m_Joins)
|
||||||
{
|
{
|
||||||
OutRec *outRec1 = GetOutRec(join.OutPt1->Idx);
|
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
|
// http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Classes/Clipper/Properties/StrictlySimple.htm
|
||||||
void Clipper::DoSimplePolygons()
|
void Clipper::DoSimplePolygons()
|
||||||
{
|
{
|
||||||
CLIPPERLIB_PROFILE_FUNC();
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while (i < m_PolyOuts.size())
|
while (i < m_PolyOuts.size())
|
||||||
{
|
{
|
||||||
|
@ -461,10 +461,6 @@ if(WIN32)
|
|||||||
target_link_libraries(libslic3r Psapi.lib)
|
target_link_libraries(libslic3r Psapi.lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SLIC3R_PROFILE)
|
|
||||||
target_link_libraries(libslic3r Shiny)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
# This flag prevents the need for minimum SDK version 10.14
|
# This flag prevents the need for minimum SDK version 10.14
|
||||||
# currently, PS targets v10.12
|
# currently, PS targets v10.12
|
||||||
|
@ -8,17 +8,6 @@
|
|||||||
#include "SVG.hpp"
|
#include "SVG.hpp"
|
||||||
#endif /* CLIPPER_UTILS_DEBUG */
|
#endif /* CLIPPER_UTILS_DEBUG */
|
||||||
|
|
||||||
// Profiling support using the Shiny intrusive profiler
|
|
||||||
//#define CLIPPER_UTILS_PROFILE
|
|
||||||
#if defined(SLIC3R_PROFILE) && defined(CLIPPER_UTILS_PROFILE)
|
|
||||||
#include <Shiny/Shiny.h>
|
|
||||||
#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)
|
#define CLIPPER_OFFSET_SHORTEST_EDGE_FACTOR (0.005f)
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
@ -53,8 +53,6 @@
|
|||||||
using slic3r_tbb_filtermode = tbb::filter;
|
using slic3r_tbb_filtermode = tbb::filter;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Shiny/Shiny.h>
|
|
||||||
|
|
||||||
using namespace std::literals::string_view_literals;
|
using namespace std::literals::string_view_literals;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -735,8 +733,6 @@ namespace DoExport {
|
|||||||
|
|
||||||
void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb)
|
void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb)
|
||||||
{
|
{
|
||||||
PROFILE_CLEAR();
|
|
||||||
|
|
||||||
CNumericLocalesSetter locales_setter;
|
CNumericLocalesSetter locales_setter;
|
||||||
|
|
||||||
// Does the file exist? If so, we hope that it is still valid.
|
// 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();
|
BOOST_LOG_TRIVIAL(info) << "Exporting G-code finished" << log_memory_info();
|
||||||
print->set_done(psGCodeExport);
|
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()
|
// free functions called by GCode::_do_export()
|
||||||
@ -1048,8 +1040,6 @@ std::vector<const PrintInstance*> sort_object_instances_by_model_order(const Pri
|
|||||||
|
|
||||||
void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb)
|
void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb)
|
||||||
{
|
{
|
||||||
PROFILE_FUNC();
|
|
||||||
|
|
||||||
// modifies m_silent_time_estimator_enabled
|
// modifies m_silent_time_estimator_enabled
|
||||||
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
|
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
#include "LocalesUtils.hpp"
|
#include "LocalesUtils.hpp"
|
||||||
|
|
||||||
#include <Shiny/Shiny.h>
|
|
||||||
#include <fast_float/fast_float.h>
|
#include <fast_float/fast_float.h>
|
||||||
|
|
||||||
namespace Slic3r {
|
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<const char*, const char*> &command)
|
const char* GCodeReader::parse_line_internal(const char *ptr, const char *end, GCodeLine &gline, std::pair<const char*, const char*> &command)
|
||||||
{
|
{
|
||||||
PROFILE_FUNC();
|
|
||||||
|
|
||||||
assert(is_decimal_separator_point());
|
assert(is_decimal_separator_point());
|
||||||
|
|
||||||
// command and args
|
// command and args
|
||||||
const char *c = ptr;
|
const char *c = ptr;
|
||||||
{
|
{
|
||||||
PROFILE_BLOCK(command_and_args);
|
|
||||||
// Skip the whitespaces.
|
// Skip the whitespaces.
|
||||||
command.first = skip_whitespaces(c);
|
command.first = skip_whitespaces(c);
|
||||||
// Skip the command.
|
// 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);
|
for (; ! is_end_of_line(*c); ++ c);
|
||||||
|
|
||||||
// Copy the raw string including the comment, without the trailing newlines.
|
// Copy the raw string including the comment, without the trailing newlines.
|
||||||
if (c > ptr) {
|
if (c > ptr)
|
||||||
PROFILE_BLOCK(copy_raw_string);
|
|
||||||
gline.m_raw.assign(ptr, c);
|
gline.m_raw.assign(ptr, c);
|
||||||
}
|
|
||||||
|
|
||||||
// Skip the trailing newlines.
|
// Skip the trailing newlines.
|
||||||
if (*c == '\r')
|
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<const char*, const char*> &command)
|
void GCodeReader::update_coordinates(GCodeLine &gline, std::pair<const char*, const char*> &command)
|
||||||
{
|
{
|
||||||
PROFILE_FUNC();
|
|
||||||
if (*command.first == 'G') {
|
if (*command.first == 'G') {
|
||||||
int cmd_len = int(command.second - command.first);
|
int cmd_len = int(command.second - command.first);
|
||||||
if ((cmd_len == 2 && (command.first[1] == '0' || command.first[1] == '1')) ||
|
if ((cmd_len == 2 && (command.first[1] == '0' || command.first[1] == '1')) ||
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
|
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
|
|
||||||
#include <Shiny/Shiny.h>
|
|
||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
//! macro used to mark string used at localization,
|
//! macro used to mark string used at localization,
|
||||||
@ -1037,8 +1035,6 @@ void PrintObject::process_external_surfaces()
|
|||||||
|
|
||||||
void PrintObject::discover_vertical_shells()
|
void PrintObject::discover_vertical_shells()
|
||||||
{
|
{
|
||||||
PROFILE_FUNC();
|
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "Discovering vertical shells..." << log_memory_info();
|
BOOST_LOG_TRIVIAL(info) << "Discovering vertical shells..." << log_memory_info();
|
||||||
|
|
||||||
struct DiscoverVerticalShellsCacheEntry
|
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) {
|
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);
|
const PrintRegion ®ion = this->printing_region(region_id);
|
||||||
if (! region.config().ensure_vertical_shell_thickness.value)
|
if (! region.config().ensure_vertical_shell_thickness.value)
|
||||||
// This region will be handled by discover_horizontal_shells().
|
// This region will be handled by discover_horizontal_shells().
|
||||||
@ -1200,7 +1194,6 @@ void PrintObject::discover_vertical_shells()
|
|||||||
(const tbb::blocked_range<size_t>& range) {
|
(const tbb::blocked_range<size_t>& range) {
|
||||||
// printf("discover_vertical_shells from %d to %d\n", range.begin(), range.end());
|
// 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) {
|
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();
|
m_print->throw_if_canceled();
|
||||||
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
||||||
static size_t debug_idx = 0;
|
static size_t debug_idx = 0;
|
||||||
@ -1225,8 +1218,6 @@ void PrintObject::discover_vertical_shells()
|
|||||||
ExPolygons shell_ex;
|
ExPolygons shell_ex;
|
||||||
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
||||||
float min_perimeter_infill_spacing = float(infill_line_spacing) * 1.05f;
|
float min_perimeter_infill_spacing = float(infill_line_spacing) * 1.05f;
|
||||||
{
|
|
||||||
PROFILE_BLOCK(discover_vertical_shells_region_layer_collect);
|
|
||||||
#if 0
|
#if 0
|
||||||
// #ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
// #ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
||||||
{
|
{
|
||||||
@ -1297,16 +1288,12 @@ void PrintObject::discover_vertical_shells()
|
|||||||
}
|
}
|
||||||
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
||||||
#if 0
|
#if 0
|
||||||
{
|
|
||||||
PROFILE_BLOCK(discover_vertical_shells_region_layer_shell_);
|
|
||||||
// shell = union_(shell, true);
|
// shell = union_(shell, true);
|
||||||
shell = union_(shell, false);
|
shell = union_(shell, false);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
||||||
shell_ex = union_safety_offset_ex(shell);
|
shell_ex = union_safety_offset_ex(shell);
|
||||||
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
||||||
}
|
|
||||||
|
|
||||||
//if (shell.empty())
|
//if (shell.empty())
|
||||||
// continue;
|
// continue;
|
||||||
@ -1433,10 +1420,6 @@ void PrintObject::discover_vertical_shells()
|
|||||||
}
|
}
|
||||||
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
|
||||||
} // for each region
|
} // 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.
|
// This method applies bridge flow to the first internal solid layer above sparse infill.
|
||||||
|
@ -203,7 +203,7 @@ void name_tbb_thread_pool_threads_set_locale()
|
|||||||
const size_t nthreads_hw = tbb::this_task_arena::max_concurrency();
|
const size_t nthreads_hw = tbb::this_task_arena::max_concurrency();
|
||||||
size_t nthreads = nthreads_hw;
|
size_t nthreads = nthreads_hw;
|
||||||
|
|
||||||
#ifdef SLIC3R_PROFILE
|
#if 0
|
||||||
// Shiny profiler is not thread safe, thus disable parallelization.
|
// Shiny profiler is not thread safe, thus disable parallelization.
|
||||||
disable_multi_threading();
|
disable_multi_threading();
|
||||||
nthreads = 1;
|
nthreads = 1;
|
||||||
|
@ -133,6 +133,4 @@
|
|||||||
#include "libslic3r.h"
|
#include "libslic3r.h"
|
||||||
#include "libslic3r_version.h"
|
#include "libslic3r_version.h"
|
||||||
|
|
||||||
#include <Shiny/Shiny.h>
|
|
||||||
|
|
||||||
#include <admesh/stl.h>
|
#include <admesh/stl.h>
|
||||||
|
@ -127,7 +127,7 @@ static struct RunOnInit {
|
|||||||
|
|
||||||
void disable_multi_threading()
|
void disable_multi_threading()
|
||||||
{
|
{
|
||||||
// Disable parallelization so the Shiny profiler works
|
// Disable parallelization to simplify debugging.
|
||||||
#ifdef TBB_HAS_GLOBAL_CONTROL
|
#ifdef TBB_HAS_GLOBAL_CONTROL
|
||||||
{
|
{
|
||||||
static tbb::global_control gc(tbb::global_control::max_allowed_parallelism, 1);
|
static tbb::global_control gc(tbb::global_control::max_allowed_parallelism, 1);
|
||||||
|
@ -244,7 +244,6 @@ set(SLIC3R_GUI_SOURCES
|
|||||||
Utils/PresetUpdater.hpp
|
Utils/PresetUpdater.hpp
|
||||||
Utils/Process.cpp
|
Utils/Process.cpp
|
||||||
Utils/Process.hpp
|
Utils/Process.hpp
|
||||||
Utils/Profile.hpp
|
|
||||||
Utils/UndoRedo.cpp
|
Utils/UndoRedo.cpp
|
||||||
Utils/UndoRedo.hpp
|
Utils/UndoRedo.hpp
|
||||||
Utils/HexFile.cpp
|
Utils/HexFile.cpp
|
||||||
|
@ -114,7 +114,6 @@ void CopyrightsDialog::fill_entries()
|
|||||||
{ "Expat" , "1998-2000 Thai Open Source Software Center Ltd and Clark Cooper"
|
{ "Expat" , "1998-2000 Thai Open Source Software Center Ltd and Clark Cooper"
|
||||||
"2001-2016 Expat maintainers" , "http://www.libexpat.org/" },
|
"2001-2016 Expat maintainers" , "http://www.libexpat.org/" },
|
||||||
{ "AVRDUDE" , "2018 Free Software Foundation, Inc." , "http://savannah.nongnu.org/projects/avrdude" },
|
{ "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"
|
{ "Real-Time DXT1/DXT5 C compression library"
|
||||||
, "Based on original by fabian \"ryg\" giesen v1.04. "
|
, "Based on original by fabian \"ryg\" giesen v1.04. "
|
||||||
"Custom version, modified by Yann Collet" , "https://github.com/Cyan4973/RygsDXTc" },
|
"Custom version, modified by Yann Collet" , "https://github.com/Cyan4973/RygsDXTc" },
|
||||||
|
@ -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 <Shiny/Shiny.h>
|
|
||||||
#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_
|
|
Loading…
Reference in New Issue
Block a user