1 /**
2 Exposes performance related data.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.performance;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 /**
23 Exposes performance related data.
24 
25 This class provides access to a number of different monitors related to performance, such as memory usage, draw calls, and FPS. These are the same as the values displayed in the $(I Monitor) tab in the editor's $(I Debugger) panel. By using the $(D getMonitor) method of this class, you can access this data from your code. Note that a few of these monitors are only available in debug mode and will always return 0 when used in a release build.
26 Many of these monitors are not updated in real-time, so there may be a short delay between changes.
27 */
28 @GodotBaseClass struct PerformanceSingleton
29 {
30 	enum string _GODOT_internal_name = "Performance";
31 public:
32 @nogc nothrow:
33 	union { godot_object _godot_object; GodotObject _GODOT_base; }
34 	alias _GODOT_base this;
35 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
36 	package(godot) __gshared bool _classBindingInitialized = false;
37 	package(godot) static struct _classBinding
38 	{
39 		__gshared:
40 		godot_object _singleton;
41 		immutable char* _singletonName = "Performance";
42 		@GodotName("get_monitor") GodotMethod!(double, long) getMonitor;
43 	}
44 	bool opEquals(in PerformanceSingleton other) const { return _godot_object.ptr is other._godot_object.ptr; }
45 	PerformanceSingleton opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
46 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
47 	mixin baseCasts;
48 	static PerformanceSingleton _new()
49 	{
50 		static godot_class_constructor constructor;
51 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Performance");
52 		if(constructor is null) return typeof(this).init;
53 		return cast(PerformanceSingleton)(constructor());
54 	}
55 	@disable new(size_t s);
56 	/// 
57 	enum Monitor : int
58 	{
59 		/**
60 		Frames per second.
61 		*/
62 		timeFps = 0,
63 		/**
64 		Time it took to complete one frame.
65 		*/
66 		timeProcess = 1,
67 		/**
68 		Time it took to complete one physics frame.
69 		*/
70 		timePhysicsProcess = 2,
71 		/**
72 		Static memory currently used, in bytes. Not available in release builds.
73 		*/
74 		memoryStatic = 3,
75 		/**
76 		Dynamic memory currently used, in bytes. Not available in release builds.
77 		*/
78 		memoryDynamic = 4,
79 		/**
80 		Available static memory. Not available in release builds.
81 		*/
82 		memoryStaticMax = 5,
83 		/**
84 		Available dynamic memory. Not available in release builds.
85 		*/
86 		memoryDynamicMax = 6,
87 		/**
88 		Largest amount of memory the message queue buffer has used, in bytes. The message queue is used for deferred functions calls and notifications.
89 		*/
90 		memoryMessageBufferMax = 7,
91 		/**
92 		Number of objects currently instanced (including nodes).
93 		*/
94 		objectCount = 8,
95 		/**
96 		Number of resources currently used.
97 		*/
98 		objectResourceCount = 9,
99 		/**
100 		Number of nodes currently instanced. This also includes the root node, as well as any nodes not in the scene tree.
101 		*/
102 		objectNodeCount = 10,
103 		/**
104 		3D objects drawn per frame.
105 		*/
106 		renderObjectsInFrame = 11,
107 		/**
108 		Vertices drawn per frame. 3D only.
109 		*/
110 		renderVerticesInFrame = 12,
111 		/**
112 		Material changes per frame. 3D only
113 		*/
114 		renderMaterialChangesInFrame = 13,
115 		/**
116 		Shader changes per frame. 3D only.
117 		*/
118 		renderShaderChangesInFrame = 14,
119 		/**
120 		Render surface changes per frame. 3D only.
121 		*/
122 		renderSurfaceChangesInFrame = 15,
123 		/**
124 		Draw calls per frame. 3D only.
125 		*/
126 		renderDrawCallsInFrame = 16,
127 		/**
128 		Video memory used. Includes both texture and vertex memory.
129 		*/
130 		renderVideoMemUsed = 17,
131 		/**
132 		Texture memory used.
133 		*/
134 		renderTextureMemUsed = 18,
135 		/**
136 		Vertex memory used.
137 		*/
138 		renderVertexMemUsed = 19,
139 		/**
140 		
141 		*/
142 		renderUsageVideoMemTotal = 20,
143 		/**
144 		Number of active $(D RigidBody2D) nodes in the game.
145 		*/
146 		physics2dActiveObjects = 21,
147 		/**
148 		Number of collision pairs in the 2D physics engine.
149 		*/
150 		physics2dCollisionPairs = 22,
151 		/**
152 		Number of islands in the 2D physics engine.
153 		*/
154 		physics2dIslandCount = 23,
155 		/**
156 		Number of active $(D RigidBody) and $(D VehicleBody) nodes in the game.
157 		*/
158 		physics3dActiveObjects = 24,
159 		/**
160 		Number of collision pairs in the 3D physics engine.
161 		*/
162 		physics3dCollisionPairs = 25,
163 		/**
164 		Number of islands in the 3D physics engine.
165 		*/
166 		physics3dIslandCount = 26,
167 		/**
168 		
169 		*/
170 		audioOutputLatency = 27,
171 		/**
172 		
173 		*/
174 		monitorMax = 28,
175 	}
176 	/// 
177 	enum Constants : int
178 	{
179 		timeFps = 0,
180 		timeProcess = 1,
181 		timePhysicsProcess = 2,
182 		memoryStatic = 3,
183 		memoryDynamic = 4,
184 		memoryStaticMax = 5,
185 		memoryDynamicMax = 6,
186 		memoryMessageBufferMax = 7,
187 		objectCount = 8,
188 		objectResourceCount = 9,
189 		objectNodeCount = 10,
190 		renderObjectsInFrame = 11,
191 		renderVerticesInFrame = 12,
192 		renderMaterialChangesInFrame = 13,
193 		renderShaderChangesInFrame = 14,
194 		renderSurfaceChangesInFrame = 15,
195 		renderDrawCallsInFrame = 16,
196 		renderVideoMemUsed = 17,
197 		renderTextureMemUsed = 18,
198 		renderVertexMemUsed = 19,
199 		renderUsageVideoMemTotal = 20,
200 		physics2dActiveObjects = 21,
201 		physics2dCollisionPairs = 22,
202 		physics2dIslandCount = 23,
203 		physics3dActiveObjects = 24,
204 		physics3dCollisionPairs = 25,
205 		physics3dIslandCount = 26,
206 		audioOutputLatency = 27,
207 		monitorMax = 28,
208 	}
209 	/**
210 	Returns the value of one of the available monitors. You should provide one of this class's constants as the argument, like this:
211 	
212 	
213 	print(Performance.get_monitor(Performance.TIME_FPS)) # Prints the FPS to the console
214 	
215 	
216 	*/
217 	double getMonitor(in long monitor) const
218 	{
219 		checkClassBinding!(typeof(this))();
220 		return ptrcall!(double)(_classBinding.getMonitor, _godot_object, monitor);
221 	}
222 }
223 /// Returns: the PerformanceSingleton
224 @property @nogc nothrow pragma(inline, true)
225 PerformanceSingleton Performance()
226 {
227 	checkClassBinding!PerformanceSingleton();
228 	return PerformanceSingleton(PerformanceSingleton._classBinding._singleton);
229 }