Skip to content

Commit

Permalink
improve use statistics
Browse files Browse the repository at this point in the history
add android install_version
fix uwp compile
add option --noxlsexport
fix andorid firebase analytics default params
  • Loading branch information
irov committed Aug 19, 2023
1 parent 442d103 commit 9114f02
Show file tree
Hide file tree
Showing 27 changed files with 283 additions and 320 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ public String getBuildUsername() {
private String m_installKey;
private long m_installTimestamp = -1;
private String m_installDate;
private String m_installVersion;
private long m_installRND = -1;
private long m_sessionIndex = -1;
private String m_sessionId;
private long m_sessionTimestamp;
private String m_sessionDate;

private ArrayList<MenginePlugin> m_plugins = new ArrayList<>();
private Map<String, MenginePlugin> m_dictionaryPlugins = new HashMap<>();
Expand Down Expand Up @@ -206,14 +209,16 @@ public String getInstallKey() {
return m_installKey;
}

public long getInstallKeyTimestamp() {
public long getInstallTimestamp() {
return m_installTimestamp;
}

public String getInstallDate() {
return m_installDate;
}

public String getInstallVersion() { return m_installVersion; }

public long getInstallRND() {
return m_installRND;
}
Expand Down Expand Up @@ -243,6 +248,14 @@ public String getSessionId() {
return m_sessionId;
}

public long getSessionTimestamp() {
return m_sessionTimestamp;
}

public String getSessionDate() {
return m_sessionDate;
}

public String getDeviceLanguage() {
String language = Locale.getDefault().getLanguage();

Expand Down Expand Up @@ -652,6 +665,7 @@ public void onCreate() {
String installKey = settings.getString("install_key", null);
long installTimestamp = settings.getLong("install_timestamp", 0);
String installDate = settings.getString("install_date", "");
String installVersion = settings.getString("install_version", "");
long installRND = settings.getLong("install_rnd", -1);
long sessionIndex = settings.getLong("session_index", 0);
String sessionId = settings.getString("session_id", null);
Expand All @@ -662,10 +676,12 @@ public void onCreate() {
installKey = MengineUtils.getRandomUUIDString();
installTimestamp = MengineUtils.getTimestamp();
installDate = MengineUtils.getDateFormat("d MMM yyyy HH:mm:ss");
installVersion = this.getVersionName();

editor.putString("install_key", installKey);
editor.putLong("install_timestamp", installTimestamp);
editor.putString("install_date", installDate);
editor.putString("install_version", installVersion);
}

if (sessionId == null) {
Expand Down Expand Up @@ -695,6 +711,8 @@ public void onCreate() {
m_installRND = installRND;
m_sessionIndex = sessionIndex;
m_sessionId = sessionId;
m_sessionTimestamp = MengineUtils.getTimestamp();
m_sessionDate = MengineUtils.getDateFormat("d MMM yyyy HH:mm:ss");

String gitsha1 = this.getEngineGITSHA1();
this.setState("engine.gitsha1", gitsha1);
Expand All @@ -708,15 +726,12 @@ public void onCreate() {
this.setState("user.install_key", m_installKey);
this.setState("user.install_timestamp", m_installTimestamp);
this.setState("user.install_date", m_installDate);
this.setState("user.install_version", m_installVersion);
this.setState("user.install_rnd", m_installRND);
this.setState("user.session_index", m_sessionIndex);
this.setState("user.session_id", m_sessionId);

String sessionStartDate = MengineUtils.getDateFormat("d MMM yyyy HH:mm:ss");
this.setState("user.session_date", sessionStartDate);

long sessionStartTimestamp = MengineUtils.getTimestamp();
this.setState("user.session_timestamp", sessionStartTimestamp);
this.setState("user.session_timestamp", m_sessionTimestamp);
this.setState("user.session_date", m_sessionDate);

this.setState("application.init", "load");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ public void onAppPrepare(MengineApplication application) throws MenginePluginInv
m_firebaseAnalytics.setUserId(sessionId);

String installKey = application.getInstallKey();
long installKeyTimestamp = application.getInstallKeyTimestamp();
long installTimestamp = application.getInstallTimestamp();
String installVersion = application.getInstallVersion();
long installRND = application.getInstallRND();
long sessionIndex = application.getSessionIndex();

Bundle params = new Bundle();
params.putString("install_key", installKey);
params.putLong("install_key_timestamp", installKeyTimestamp);
params.putLong("install_timestamp", installTimestamp);
params.putString("install_version", installVersion);
params.putLong("install_rnd", installRND);
params.putLong("session_index", sessionIndex);

Expand Down
1 change: 1 addition & 0 deletions src/Config/StdIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Config/Char.h"
#include "Config/StdInt.h"
#include "Config/StdArg.h"
#include "Config/StdIntTypes.h"

#include <cstdio>
#include <cwchar>
Expand Down
29 changes: 23 additions & 6 deletions src/Environment/Windows/Win32GetCallstack.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#include "Win32GetCallstack.h"

#ifndef MENGINE_UNSUPPORT_PRAGMA_WARNING
# pragma warning(push, 0)
#endif
#ifndef MENGINE_PLATFORM_UWP
# ifndef MENGINE_UNSUPPORT_PRAGMA_WARNING
# pragma warning(push, 0)
# endif

#include "Environment/Windows/DbgHelp.h"
# include "Environment/Windows/DbgHelp.h"

#ifndef MENGINE_UNSUPPORT_PRAGMA_WARNING
# pragma warning(pop)
# ifndef MENGINE_UNSUPPORT_PRAGMA_WARNING
# pragma warning(pop)
# endif
#endif

#include "Config/StdString.h"
Expand All @@ -18,6 +20,8 @@ namespace Mengine
namespace Helper
{
//////////////////////////////////////////////////////////////////////////
#ifndef MENGINE_PLATFORM_UWP
//////////////////////////////////////////////////////////////////////////
namespace Detail
{
//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -511,5 +515,18 @@ namespace Mengine
return successful;
}
//////////////////////////////////////////////////////////////////////////
#else
//////////////////////////////////////////////////////////////////////////
bool Win32GetCallstack( DWORD _threadId, PCONTEXT _context, Char * const _stack, size_t _capacity )
{
MENGINE_UNUSED( _threadId );
MENGINE_UNUSED( _context );
MENGINE_UNUSED( _stack );
MENGINE_UNUSED( _capacity );

return false;
}
//////////////////////////////////////////////////////////////////////////
#endif
}
}
4 changes: 4 additions & 0 deletions src/Environment/Windows/Win32Helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ namespace Mengine
//////////////////////////////////////////////////////////////////////////
void Win32Toast( const WChar * _message )
{
MENGINE_UNUSED( _message );

#ifndef MENGINE_PLATFORM_UWP
::MessageBoxW( NULL, _message, L"Mengine", MB_OK );
#endif
}
//////////////////////////////////////////////////////////////////////////
}
Expand Down
2 changes: 0 additions & 2 deletions src/Interface/RenderSystemInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ namespace Mengine

public:
virtual uint32_t getAvailableTextureMemory() const = 0;
virtual uint32_t getTextureMemoryUse() const = 0;
virtual uint32_t getTextureCount() const = 0;
};
//////////////////////////////////////////////////////////////////////////
}
Expand Down
33 changes: 22 additions & 11 deletions src/Interface/StatisticInterface.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "Config/Typedef.h"
#include "Config/Char.h"

#ifndef MENGINE_STATISTIC_MAX_COUNT
Expand All @@ -10,7 +11,13 @@ namespace Mengine
{
//////////////////////////////////////////////////////////////////////////
template<uint32_t ID>
struct Statistic;
struct Statistic
{
static const Char * getName()
{
return "UNDEFINED";
}
};
//////////////////////////////////////////////////////////////////////////
#define MENGINE_STATISTIC_DECLARE_BEGIN()\
static constexpr uint32_t MENGINE_STATISTIC_ENUMERATOR_BEGIN = MENGINE_CODE_LINE
Expand All @@ -37,22 +44,26 @@ namespace Mengine
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_PERFRAME_OBJECTS );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_PERFRAME_TRIANGLES );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_PERFRAME_BATCHES );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_IMAGE_NEW );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_IMAGE_FREE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_IMAGE_COUNT );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_IMAGE_SIZE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_TEXTURE_COUNT );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_TEXTURE_MEMORY_USAGE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_IMAGE_ALLOC_NEW );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_IMAGE_ALLOC_FREE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_IMAGE_ALLOC_COUNT );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_IMAGE_ALLOC_SIZE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_IMAGE_LOCK_COUNT );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_IMAGE_LOCK_PIXEL );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_INDEX_BUFFER_NEW );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_INDEX_BUFFER_FREE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_INDEX_BUFFER_COUNT );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_INDEX_BUFFER_SIZE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_INDEX_BUFFER_ALLOC_NEW );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_INDEX_BUFFER_ALLOC_FREE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_INDEX_BUFFER_ALLOC_COUNT );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_INDEX_BUFFER_ALLOC_SIZE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_INDEX_BUFFER_LOCK_NEW );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_INDEX_BUFFER_LOCK_SIZE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_VERTEX_BUFFER_NEW );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_VERTEX_BUFFER_FREE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_VERTEX_BUFFER_COUNT );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_VERTEX_BUFFER_SIZE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_VERTEX_BUFFER_ALLOC_NEW );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_VERTEX_BUFFER_ALLOC_FREE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_VERTEX_BUFFER_ALLOC_COUNT );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_VERTEX_BUFFER_ALLOC_SIZE );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_VERTEX_BUFFER_LOCK_NEW );
MENGINE_STATISTIC_DECLARE( STATISTIC_RENDER_VERTEX_BUFFER_LOCK_SIZE );
MENGINE_STATISTIC_DECLARE_END();
Expand Down
34 changes: 34 additions & 0 deletions src/Kernel/AssertionStatistic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "AssertionStatistic.h"

#if defined(MENGINE_ASSERTION_DEBUG_ENABLE)
# include "Kernel/StatisticHelper.h"
# include "Kernel/StatisticName.h"
# include "Kernel/Assertion.h"
# include "Kernel/Logger.h"

# include "Config/StdIO.h"

namespace Mengine
{
namespace Detail
{
void assertionStatisticEmpty( const Char * _category, uint32_t _id, const Char * _file, uint32_t _line )
{
int64_t value = STATISTIC_GET_INTEGER( _id );

if( value == 0 )
{
return;
}

Char msg[1024] = {'\0'};
MENGINE_SNPRINTF( msg, 1024, "[Assert] Statistics '%s' not empty ['%" MENGINE_PRLPARAM "']"
, Helper::getStatisticName( _id )
, value
);

Mengine::Helper::Assertion( _category, ASSERTION_LEVEL_ERROR, msg, _file, _line, "Assertion Vocabulary Empty" );
}
}
}
#endif
20 changes: 20 additions & 0 deletions src/Kernel/AssertionStatistic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include "Config/Config.h"

#if defined(MENGINE_ASSERTION_DEBUG_ENABLE)
# include "Config/Char.h"
# include "Config/Typedef.h"

namespace Mengine
{
namespace Detail
{
void assertionStatisticEmpty( const Char * _category, uint32_t _id, const Char * _file, uint32_t _line );
}
}

# define MENGINE_ASSERTION_STATISTIC_EMPTY(ID) Detail::assertionStatisticEmpty(MENGINE_CODE_LIBRARY, ID, MENGINE_CODE_FILE, MENGINE_CODE_LINE)
#else
# define MENGINE_ASSERTION_STATISTIC_EMPTY(ID)
#endif
6 changes: 6 additions & 0 deletions src/Kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ Assertion
AssertionMainThreadGuard.h
AssertionVocabulary.h
AssertionVocabulary.cpp
AssertionStatistic.h
AssertionStatistic.cpp
AssertionNode.h
AssertionType.h
AssertionAllocator.h
Expand Down Expand Up @@ -878,6 +880,10 @@ Core

NotificationName.cpp
NotificationName.h

StatisticName.cpp
StatisticName.h


ExecutorHelper.h
PrototypeHelper.h
Expand Down
43 changes: 43 additions & 0 deletions src/Kernel/StatisticName.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "StatisticName.h"

#include "Kernel/Array.h"

namespace Mengine
{
namespace Helper
{
//////////////////////////////////////////////////////////////////////////
namespace Detail
{
//////////////////////////////////////////////////////////////////////////
template<size_t Index>
constexpr const Char * createStatisticNameTableFunction()
{
const Char * name = Statistic<Index>::getName();

return name;
}
//////////////////////////////////////////////////////////////////////////
template<size_t ... Index>
constexpr auto createStatisticNameTable( std::index_sequence<Index ...> )
{
return Array<const Char *, sizeof ... (Index)>{{Detail::createStatisticNameTableFunction<Index>() ...}};
}
//////////////////////////////////////////////////////////////////////////
template<size_t Size>
constexpr auto createStatisticNameTable()
{
return Detail::createStatisticNameTable( std::make_index_sequence<Size>{} );
}
//////////////////////////////////////////////////////////////////////////
}
//////////////////////////////////////////////////////////////////////////
const Char * getStatisticName( uint32_t _id )
{
const Char * name = Detail::createStatisticNameTable<MENGINE_STATISTIC_MAX_COUNT>()[_id];

return name;
}
//////////////////////////////////////////////////////////////////////////
}
}
11 changes: 11 additions & 0 deletions src/Kernel/StatisticName.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include "Interface/StatisticInterface.h"

namespace Mengine
{
namespace Helper
{
const Char * getStatisticName( uint32_t _id );
}
}
Loading

0 comments on commit 9114f02

Please sign in to comment.