Skip to content

Commit

Permalink
Added instumentation to vsg::Options
Browse files Browse the repository at this point in the history
  • Loading branch information
robertosfield committed Dec 20, 2023
1 parent 06b9aac commit 76a8018
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/vsg/io/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <vsg/io/FileSystem.h>
#include <vsg/maths/transform.h>
#include <vsg/state/StateCommand.h>
#include <vsg/utils/Instrumentation.h>

namespace vsg
{
Expand Down Expand Up @@ -96,6 +97,9 @@ namespace vsg
/// scene graph creation routines can use the inherited state information to avoid setting state in the local subgraph.
StateCommands inheritedState;

/// Hook for assigning Instrumentation to enable profiling of record traversal.
ref_ptr<Instrumentation> instrumentation;

protected:
virtual ~Options();
};
Expand Down
3 changes: 2 additions & 1 deletion src/vsg/io/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Options::Options(const Options& options) :
sceneCoordinateConvention(options.sceneCoordinateConvention),
formatCoordinateConventions(options.formatCoordinateConventions),
shaderSets(options.shaderSets),
inheritedState(options.inheritedState)
inheritedState(options.inheritedState),
instrumentation(options.instrumentation)
{
getOrCreateAuxiliary();
// copy any meta data.
Expand Down
8 changes: 8 additions & 0 deletions src/vsg/io/read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ using namespace vsg;

ref_ptr<Object> vsg::read(const Path& filename, ref_ptr<const Options> options)
{
CPU_INSTRUMENTATION_L1(options ? options->instrumentation.get() : nullptr);

auto read_file = [&]() -> ref_ptr<Object> {
if (options && !options->readerWriters.empty())
{
Expand Down Expand Up @@ -81,6 +83,8 @@ ref_ptr<Object> vsg::read(const Path& filename, ref_ptr<const Options> options)

PathObjects vsg::read(const Paths& filenames, ref_ptr<const Options> options)
{
CPU_INSTRUMENTATION_L1(options ? options->instrumentation.get() : nullptr);

ref_ptr<OperationThreads> operationThreads;
if (options) operationThreads = options->operationThreads;

Expand Down Expand Up @@ -150,6 +154,8 @@ PathObjects vsg::read(const Paths& filenames, ref_ptr<const Options> options)

ref_ptr<Object> vsg::read(std::istream& fin, ref_ptr<const Options> options)
{
CPU_INSTRUMENTATION_L1(options ? options->instrumentation.get() : nullptr);

if (options && !options->readerWriters.empty())
{
for (auto& readerWriter : options->readerWriters)
Expand All @@ -164,6 +170,8 @@ ref_ptr<Object> vsg::read(std::istream& fin, ref_ptr<const Options> options)

ref_ptr<Object> vsg::read(const uint8_t* ptr, size_t size, ref_ptr<const Options> options)
{
CPU_INSTRUMENTATION_L1(options ? options->instrumentation.get() : nullptr);

if (options && !options->readerWriters.empty())
{
for (auto& readerWriter : options->readerWriters)
Expand Down
2 changes: 2 additions & 0 deletions src/vsg/io/write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ using namespace vsg;

bool vsg::write(ref_ptr<Object> object, const Path& filename, ref_ptr<const Options> options)
{
CPU_INSTRUMENTATION_L1(options ? options->instrumentation.get() : nullptr);

bool fileWritten = false;
if (options)
{
Expand Down

0 comments on commit 76a8018

Please sign in to comment.