1 #ifndef DALI_ADAPTOR_OBJECT_PROFILER_H
2 #define DALI_ADAPTOR_OBJECT_PROFILER_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <cstdint> // uint32_t
23 #include <cstddef> // size_t
24 #include <dali/public-api/common/vector-wrapper.h>
25 #include <dali/public-api/object/object-registry.h>
26 #include <dali/public-api/object/type-registry.h>
27 #include <dali/public-api/signals/connection-tracker.h>
30 #include <dali/public-api/adaptor-framework/timer.h>
40 * Class to profile the number of instances of Objects in the system
42 class ObjectProfiler : public ConnectionTracker
48 * @param objectRegistry The objectRegistry
49 * @param timeInterval to specify the frequency of reporting
51 ObjectProfiler( Dali::ObjectRegistry objectRegistry, uint32_t timeInterval );
59 * Display a list of types with the current number of instances in the system
61 void DisplayInstanceCounts();
65 * If timer is running, display the instance counts
70 * Callback used when objects are created. Increases instance count for that object type
71 * @param[in] handle of the created object
73 void OnObjectCreated( BaseHandle handle );
76 * Callback used when objects are created. Decreases instance count for that object type
77 * @param[in] object The object being destroyed
79 void OnObjectDestroyed( const Dali::RefObject* object );
82 * Get the memory size of the given object
84 std::size_t GetMemorySize( const std::string& name, uint32_t count );
88 using InstanceCountPair = std::pair< const std::string, uint32_t >;
89 using InstanceTypePair = std::pair< BaseObject*, std::string >;
91 Dali::ObjectRegistry mObjectRegistry;
93 std::vector< InstanceCountPair > mInstanceCountContainer;
94 std::vector< InstanceTypePair > mInstanceTypes;
101 #endif // DALI_ADAPTOR_OBJECT_PROFILER_H