ai_stats.h
Go to the documentation of this file.
1// Copyright 2021 Autodesk, Inc. All rights reserved.
2//
3// Use of this software is subject to the terms of the Autodesk license
4// agreement provided at the time of installation or download, or which
5// otherwise accompanies this software in either electronic or hard copy form.
6
12#pragma once
13#include "ai_api.h"
14#include "ai_string.h"
15
16#include <stddef.h> // NULL
17#include <stdint.h>
18
30{
33};
34
36AI_API const char* AiStatsGetFileName();
37AI_API void AiStatsSetMode(AtStatsMode mode);
38AI_API void AiStatsSetFileName(const char* filename);
39
40#ifdef AI_GPU_COMPILER
41// profiling does not work on GPU
42#define AiProfileBlock(...)
43#else
69#define AiProfileBlock(...) AiProfileBlockRAII Ai_profile_block(__VA_ARGS__)
70#endif
71
77AI_API void AiProfileSetFileName(const char* filename);
78
84
85/*\}*/
86
87
88struct AtNode;
89
96AI_API void AiProfileUpdate(uint64_t start_counter, uint64_t end_counter,
97 const char* name, const AtNode* node);
98
105AI_API uint64_t AiProfileCounter();
106
113ARNOLD_FORCEINLINE void AiProfileEnd(uint64_t start_counter, const char* name, const AtNode* node=NULL)
114{
115 const uint64_t end_counter = AiProfileCounter();
116 if (Ai_unlikely(start_counter != end_counter))
117 AiProfileUpdate(start_counter, end_counter, name, node);
118}
119
121struct AiProfileBlockRAII
122{
123 AiProfileBlockRAII(const char* name, const AtNode* node=NULL) :
124 start_counter(AiProfileCounter()), name(name), node(node) { }
125
126 AiProfileBlockRAII(const AtNode* node) :
127 start_counter(AiProfileCounter()), name(NULL), node(node) { }
128
129 ~AiProfileBlockRAII()
130 {
131 AiProfileEnd(start_counter, name, node);
132 }
133
134private:
135 const uint64_t start_counter;
136 const char* const name;
137 const AtNode* const node;
138};
DLL export prefix for API functions (necessary for multi-platform development)
AtString class for fast comparisons.
Arnold String allows for fast string comparisons.
Definition: ai_string.h:46
AI_API AI_FORCEINLINE uint64_t AiProfileCounter()
Get profile counter.
Definition: ai_stats.cpp:56
AI_API void AiProfileUpdate(uint64_t start_counter, uint64_t end_counter, const char *name, const AtNode *node)
Finalize profile entry.
Definition: ai_stats.cpp:61
AI_API void AiStatsSetMode(AtStatsMode mode)
Set the file mode for outputting structured statistics.
Definition: ai_stats.cpp:18
AI_API void AiProfileSetFileName(const char *filename)
JSON file to which profiling traces should be written to.
Definition: ai_stats.cpp:67
AI_API const char * AiStatsGetFileName()
Get the filename of the structured stats output.
Definition: ai_stats.cpp:51
AtStatsMode
Output mode for structured statistics.
Definition: ai_stats.h:30
AI_API AtStatsMode AiStatsGetMode()
Get the mode for outputting structured statistics.
Definition: ai_stats.cpp:41
AI_API AtString AiProfileGetFileName()
Get the JSON filename to which profiling traces will be written to.
Definition: ai_stats.cpp:72
AI_API void AiStatsSetFileName(const char *filename)
Set the output file that will contain structured stats from this session's renders.
Definition: ai_stats.cpp:28
@ AI_STATS_MODE_OVERWRITE
Overwrite the file if it exists
Definition: ai_stats.h:31
@ AI_STATS_MODE_APPEND
Append data to existing statistics file.
Definition: ai_stats.h:32
This represents a node in Arnold.

© 2022 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com